Large Object within Pointer to Function & Switch

B

Bryan Parkoff

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
 
V

Victor Bazarov

Bryan said:
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
 
G

Gianni Mariani

Bryan said:
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.
 
B

Bryan Parkoff

Do you know that current C++ Compiler limits to 64KB segments in
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
 
?

=?ISO-8859-15?Q?Juli=E1n?= Albo

Bryan said:
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).
 
B

Bryan Parkoff

Gianni Mariani said:
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
 
G

Gianni Mariani

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)
 
S

Steve Pope

Bryan Parkoff said:
How are you guys defining "segment"?

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
 
B

Bryan Parkoff

BobR said:
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
 
?

=?iso-8859-1?q?Kirit_S=E6lensminde?=

Bryan said:
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
 
B

BobR

Bryan Parkoff wrote in message ...
in message...

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top