469,927 Members | 1,901 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Large Object within Pointer to Function & Switch

Do you know that current C++ Compiler limits to 64KB segments in source
code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB
segments in source code. 4GB segment is ideal for large object using
pointer to function and switch. Please list other C++ Compilers if they
have added a support of 4GB segments.
I am able to write 65,536 functions and 65,536 function's memory address
is stored into pointer to function list. It takes about 256KB. The test
has shown that each function out of 65,536 functions have been executed
successfully with correct result in both debug version and release version.
Switch can contain 65,536 cases in debug version, but C++ Compiler takes
more time to compile than pointer to function. Unfortunately, it will not
compile in release version. Unknown error is not found in any
documentation. (Not important to discuss this issue.)
I think that it is best practice to write small functions through
pointer to function list rather than large switch in one big function. By
the way, small functions can fit in cache. (Correct?).
If you are going to write 1 to 268,435,456 functions, memory address in
pointer to function list will take up to 1GB.
I know what you are going to say -- laugh -- can't be done. I urge you
to try if you are willing to write complex project. Think about holographic
character like Star Trek or character for game what you want to write. This
big object contains body including head, arm, leg, and everything. You need
to write hundred or thousand functions to respond moving arm, leg, and head.
More functions to be responded for mouth talking.
It makes 32-bit CPU machine to be slower to manipulate C++ Compiler for
large object so 64 bit CPU machine may be working with large RAM.

Please tell me what you think the best practice. Live with big object
by adding /bigobj and /Gy to Microsoft C++ Compiler. Check option
documentation for other C++ Compilers. Should write large pointer to
function list in more than 1 million line of source code? Or...Split half
or quarter function to pointer list into two or four module source code?

Please refer me to other newsgroups when I am interested to work large
object using optimization and performance using C++ Compiler's option, but
not through Microsoft alone. Please advise.

Bryan Parkoff
Oct 28 '06 #1
14 1742
Bryan Parkoff wrote:
Do you know that current C++ Compiler
What's that? Where could I find "current C++ Compiler"? Are you
talking of the Standard requirements?
limits to 64KB segments in
source code?
No, I never heard of such thing. But then again, I cannot claim
I've heard everything... The Standard, however, imposes no such
limitation. I know that there are _minimal_ quantities *recommended*
for implementations, but I can't find "segments in source code" among
those.
It is good news that Microsoft Visual C++ 2005 has
Product-specific discussions are generally off-topic here. Each
product most likely has at least one dedicated newsgroup. I know
that VC++ certainly does, even more than one.
expanded to 4GB segments in source code. 4GB segment is ideal for
large object using pointer to function and switch. Please list other
C++ Compilers if they have added a support of 4GB segments.
Please list operating systems you want to learn about. Then please
realise that discussions specific to OS are also off-topic. There
are newsgroups for those things.
[..]
Please refer me to other newsgroups when I am interested to work
large object using optimization and performance using C++ Compiler's
option, but not through Microsoft alone. Please advise.
Try 'comp.os.ms-windows.programmer.*' hierarchy or 'microsoft.public.*'
hierarchy.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 28 '06 #2
Bryan Parkoff wrote:
Do you know that current C++ Compiler limits to 64KB segments in source
code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB
segments in source code. 4GB segment is ideal for large object using
pointer to function and switch. Please list other C++ Compilers if they
have added a support of 4GB segments.
phuff - gcc supports 9,223,372,036,854,775,807 byte segments.

Now I'm looking for a computer with that much memory, one that can write
to all of it in a few seconds.

Oct 28 '06 #3
Gianni Mariani <gi*******@mariani.wswrote:
>Bryan Parkoff wrote:
> Do you know that current C++ Compiler limits to 64KB segments in source
code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB
segments in source code. 4GB segment is ideal for large object using
pointer to function and switch. Please list other C++ Compilers if they
have added a support of 4GB segments.
>phuff - gcc supports 9,223,372,036,854,775,807 byte segments.
How are you guys defining "segment"?

Steve
Oct 28 '06 #4
>> Do you know that current C++ Compiler limits to 64KB segments in
>>source
code? It is good news that Microsoft Visual C++ 2005 has expanded to
4GB
segments in source code. 4GB segment is ideal for large object using
pointer to function and switch. Please list other C++ Compilers if they
have added a support of 4GB segments.
>>phuff - gcc supports 9,223,372,036,854,775,807 byte segments.

How are you guys defining "segment"?
Steve,

Sorry. My mistake. I refer section (not segment). Look this article
below.

Microsoft Article:

By default, an object file can hold up to 65,536 (2^16) addressable
sections. /bigobj increases that address capacity to 4,294,967,296 (2^32).

Most modules will never generate an .obj file that contains more than 65,536
sections. However, machine generated code, or code that makes heavy use of
template libraries may require .obj files that can hold more sections.

An .obj file produced with /bigobj can only be consumed by a linker that
shipped in Visual C++ 2005 (or later). Linkers that shipped prior to Visual
C++ 2005 cannot read .obj files that were produced with /bigobj.

End of article

You know when you attempt to write 65,536 lines or greater on some C++
Compilers. It will fail to compile because of exceeded limit to 64KB
section. I think the point is that each object and source code are limited
to 64KB. Now, big object and big source code can handle 4GB section. It is
wonderful. It helps very much with pointer to function list.

Bryan Parkoff
Oct 28 '06 #5

"Gianni Mariani" <gi*******@mariani.wswrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
Bryan Parkoff wrote:
> Do you know that current C++ Compiler limits to 64KB segments in
source code? It is good news that Microsoft Visual C++ 2005 has expanded
to 4GB segments in source code. 4GB segment is ideal for large object
using pointer to function and switch. Please list other C++ Compilers if
they have added a support of 4GB segments.

phuff - gcc supports 9,223,372,036,854,775,807 byte segments.

Now I'm looking for a computer with that much memory, one that can write
to all of it in a few seconds.
Well, it is going to be 8,388,608 TeraByte. What will you call if 8,388,608
is divided by 1,024 = 8192 "?"Byte. "?" reminds you to invent new name.
18,446,744,073,709,551,616 is the maximum of 64 bit register.
(0x10000000000000000 - 1)

Bryan Parkoff
Oct 28 '06 #6
Bryan Parkoff wrote:
.... What will you call if 8,388,608
is divided by 1,024 = 8192 "?"Byte. "?" reminds you to invent new name.
Kilo (2^10), Mega (2^20), Giga (2^30), Tera (2^40), Peta (2^50), Exa
(2^60), Zetta (2^70), Yotta (2^80)
Oct 29 '06 #7
Gianni Mariani wrote:
Bryan Parkoff wrote:
... What will you call if 8,388,608
>is divided by 1,024 = 8192 "?"Byte. "?" reminds you to invent new
name.

Kilo (2^10), Mega (2^20), Giga (2^30), Tera (2^40), Peta (2^50), Exa
(2^60), Zetta (2^70), Yotta (2^80)
http://en.wikipedia.org/wiki/Kibi
Oct 29 '06 #8
Bryan Parkoff wrote:
Microsoft Article:
By default, an object file can hold up to 65,536 (2^16) addressable
sections. /bigobj increases that address capacity to 4,294,967,296 (2^32).
(blahblah)
You know when you attempt to write 65,536 lines or greater on some C++
It will fail to compile because of exceeded limit to 64KB section.
The article talks about Microsoft compilers for Windows, not "some".

And there is no direct relation between the number of lines of the source
file and the limits of whatever structure in an object file (unless it
embeds the lines in such limited structure as part of debug information).

--
Salu2
Oct 29 '06 #9
Gianni Mariani wrote:
Kilo (2^10), Mega (2^20), Giga (2^30), Tera (2^40), Peta (2^50), Exa
(2^60), Zetta (2^70), Yotta (2^80)
This usage is obsolete. See http://en.wikipedia.org/wiki/Binary_prefix

--
Salu2
Oct 29 '06 #10

Bryan Parkoff wrote in message ...

Huh?

http://www.parashift.com/c++-faq-lite/how-to-post.html

Oct 29 '06 #11
Bryan Parkoff <no****@nospam.comreplies to my post,
>How are you guys defining "segment"?
>Steve,
Sorry. My mistake. I refer section (not segment). Look
this article below.

Microsoft Article: [snip]
Thanks, that's very interesting. Apparently it's some limitation
on resolving function calls in the linker.

(I wouldn't think it'd be too much trouble for an implementation
to remove this limit entirely, but I've seen stranger limitations.)

Steve
Oct 29 '06 #12

"BobR" <Re***********@worldnet.att.netwrote in message
news:cb*********************@bgtnsc05-news.ops.worldnet.att.net...
>
Bryan Parkoff wrote in message ...

Huh?

http://www.parashift.com/c++-faq-lite/how-to-post.html
Well,

I did follow guideline, but I ask people to rephrase their opinion. My
question is -- is it best practice to write 64K functions or more into
pointer to function list? Is it best to create small or big function? It
is simple question. It seems that none wish to answer this question. They
may feel sorry when they face problem near the future so they will ask the
same question since in the past.
I have researched to get more information how C++ Compiler can handle
the limitation for general OS, but none implement to provide good
documentation nor FAQs. I do see when they claim to be 1,024 maximum for
functions. However you should be able to exceed limit and perform test to
prove that it is working perfectly. Didn't you?

Bryan Parkoff
Oct 29 '06 #13

Bryan Parkoff wrote:
"BobR" <Re***********@worldnet.att.netwrote in message
news:cb*********************@bgtnsc05-news.ops.worldnet.att.net...

Bryan Parkoff wrote in message ...

Huh?

http://www.parashift.com/c++-faq-lite/how-to-post.html

Well,

I did follow guideline, but I ask people to rephrase their opinion. My
question is -- is it best practice to write 64K functions or more into
pointer to function list? Is it best to create small or big function? It
is simple question. It seems that none wish to answer this question. They
may feel sorry when they face problem near the future so they will ask the
same question since in the past.
I have researched to get more information how C++ Compiler can handle
the limitation for general OS, but none implement to provide good
documentation nor FAQs. I do see when they claim to be 1,024 maximum for
functions. However you should be able to exceed limit and perform test to
prove that it is working perfectly. Didn't you?
Maybe it's because we don't understand the question. I'm certainly
finding it difficult to understand.

Are you asking about objects as instances of classes or objects as in
object files, the results of compilation? The subject line seems to
imply the first, the content the second.

Why would you want a switch statement that had 65,535 cases in it? Why
would you want to write your own message dispatcher like this?

When you say "64K functions" your talking about the number of
functions? I find it hard to imagine that anybody would write that many
functions even on a huge system and expect them all to be called
through a single switch statement. If you find that you want to do this
then I suspect you'd be better off thinking about redesigning your
solution rather than worrying about compiler limits.

Function size is a tricky one. Functions should be the right size, and
normally the right size is small, but of course there are many
exceptions and edge cases where to split a function just becomes
arbitrary. Personally I always go for the easiest to maintain size, and
not worry too much about how the compiler will aggregate
up/inline/unroll functions unless I've proven that there isn't a better
algorithm I can use to speed things up. Finding a better method
generally gives much better performance boosts than worrying unduly
about function versus cache sizes.
K

Oct 29 '06 #14

Bryan Parkoff wrote in message ...
>
"BobR" wrote in message...
>Huh?
http://www.parashift.com/c++-faq-lite/how-to-post.html

Well,

I did follow guideline, but I ask people to rephrase their opinion. My
question is -- is it best practice to write 64K functions or more into
pointer to function list?
Several years ago I read a recommended paper on Unix programming. It stated
at one point "programs should do only one thing, but, do that one thing very
well". If you have hit a limit, you need to split up the task. Even the most
'function intensive' programs I've seen on GNU/Linux did not come close to
64k functions. Heck, If you look at the Linux kernel, with *everything*
turned on, it does not come close to that limit.

Is it best to create small or big function?
I came up to C++ from Assembler, so, naturally I've taken a look at the
assembler output stage of GCC. I noticed that the usual habit (necessity)
when entering a function is to do a 'pusha'(push all, x86). I thought, "that
seems excessive, in Assembler I only push-pop when and what I need". If I
*only* looked at that I would say, always put as much in one function as you
can.
But, C++ is a much stranger animal. The general advice is - do not
pre-optimise, just write clean, clear code. Then, if there is a problem with
speed, profile the program, identify the bottlenecks and only work on those
areas.

So what do I do? If I see a section of code that gets used many times, it
goes in a function(usually a member of a class). You should make a function
do one thing (and do it well), big or small is not the target.
It is simple question. It seems that none wish to answer this question.
You do have answers from others.

They may feel sorry when they face problem near the future so they will ask
the
>same question since in the past.
You may have problems if you spend all your time worrying about some limit,
instead of studying good design.
I have researched to get more information how C++ Compiler can handle
the limitation for general OS, but none implement to provide good
documentation nor FAQs.
Sounds like a personal problem, I've never seen any of the experts in these
NGs whine about some limit. (and some of them work on HUGE projects.)

I do see when they claim to be 1,024 maximum for
functions. However you should be able to exceed limit and perform test to
prove that it is working perfectly. Didn't you?
If *your* compiler can't do what you want, get a better one. www.gnu.org

MinGW (GNU compiler): http://www.mingw.org/ (windows)

Dev-C++ IDE: http://www.bloodshed.net/ (with MinGW, easy install)
MinGWStudio http://www.parinyasoft.com/
--
Bob R
POVrookie
Oct 29 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Patrick | last post: by
6 posts views Thread by Ian Robertson | last post: by
35 posts views Thread by Frederick Gotham | last post: by
14 posts views Thread by Jeroen | last post: by
10 posts views Thread by sumsin | last post: by
3 posts views Thread by Giovanni Gherdovich | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.