473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1922
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Patrick | last post by:
I want to achieve the following behaviour but I am having trouble getting there...bare with me im knew to c++ , so its probably rather trivial! To have a class ClassA, and composed within this...
6
by: Ian Robertson | last post by:
I am trying to write a function that takes a reference to an object as its arguement. The object is created in another function and I am trying to pass the object to another function from within...
35
by: Frederick Gotham | last post by:
(Before I begin, please don't suggest to me to use "std::vector" rather than actual arrays.) I understand that an object can have resources (e.g. dynamically allocated memory), and so we have to...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
14
by: Jeroen | last post by:
Hi all, I've got a question about writing a library. Let me characterize that library by the following: * there is a class A which is available to the user * there is a class B that is used...
9
by: grbgooglefan | last post by:
I am trying to pass a C++ object to Python function. This Python function then calls another C++ function which then uses this C++ object to call methods of that object's class. I tried...
10
by: sumsin | last post by:
The C++ Object Model book says that 'Nonstatic data members are allocated directly within each class object. Static data members are stored outside the individual class object. Static and...
3
by: Giovanni Gherdovich | last post by:
Hello, in the following code I have a pointer (to function), say p, of type double (*)(double, double, void*) and I try to fix the second argument of the function *p to a given value (using...
2
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.