www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can we turn off array's bounds-check?

reply "uframer" <uframer sina100.com.cn> writes:
I find it's disturbing when i'm using D in the program for my thesis. In an 
ant-based algorithm the basic operation is array access, it will be called 
even over 10e8 times! So you guys know why i want to turn the check off.
Any ideas? 
May 24 2005
next sibling parent reply clayasaurus <clayasaurus gmail.com> writes:
uframer wrote:
 I find it's disturbing when i'm using D in the program for my thesis. In an 
 ant-based algorithm the basic operation is array access, it will be called 
 even over 10e8 times! So you guys know why i want to turn the check off.
 Any ideas? 
 
 
Have you tried passing the -release and -O options to the dmd compiler?
May 24 2005
parent reply "uframer" <uframer sina100.com.cn> writes:
Yes, i have tried that, but the effect is unclear. The D program's time 
consumption is about 10 times of the cpp one's. Sigh!
"clayasaurus" <clayasaurus gmail.com> 
??????:d70som$675$1 digitaldaemon.com...
 uframer wrote:
 I find it's disturbing when i'm using D in the program for my thesis. In 
 an ant-based algorithm the basic operation is array access, it will be 
 called even over 10e8 times! So you guys know why i want to turn the 
 check off.
 Any ideas?
Have you tried passing the -release and -O options to the dmd compiler?
May 25 2005
next sibling parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
How are you doing it?

Using -release should turn off array boundary checking.  Have you tried 
-inline as well?

-[Unknown]


 Yes, i have tried that, but the effect is unclear. The D program's time 
 consumption is about 10 times of the cpp one's. Sigh!
May 25 2005
prev sibling parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"uframer" <uframer sina100.com.cn> wrote in message 
news:d71btq$1s3u$1 digitaldaemon.com...
 Yes, i have tried that, but the effect is unclear. The D program's time 
 consumption is about 10 times of the cpp one's. Sigh!
Compile with -profile and look at trace.log to see where the time goes. You'll probably want to run profiled builds on smaller problems than a release build since tracing adds lots of overhead to the app.
May 25 2005
prev sibling next sibling parent David Medlock <noone nowhere.com> writes:
uframer wrote:
 I find it's disturbing when i'm using D in the program for my thesis. In an 
 ant-based algorithm the basic operation is array access, it will be called 
 even over 10e8 times! So you guys know why i want to turn the check off.
 Any ideas? 
 
 
Use a pointer. for most arrays there is a property .ptr char[100] mychars; char* p = mychars.ptr; The pointer does not have a bounds check i believe.
May 25 2005
prev sibling parent reply "uframer" <uframer sina100.com.cn> writes:
Thank you all!
I think i have fixed the problem.
"uframer" <uframer sina100.com.cn>
写入消息新闻:d70qtf$1gv$1 digitaldaemon.com...
I find it's disturbing when i'm using D in the program for my thesis. In an 
ant-based algorithm the basic operation is array access, it will be called 
even over 10e8 times! So you guys know why i want to turn the check off.
 Any ideas?
 
May 25 2005
parent reply pragma <pragma_member pathlink.com> writes:
In article <d720ps$2pcd$1 digitaldaemon.com>, uframer says...
Thank you all!
I think i have fixed the problem.
"uframer" <uframer sina100.com.cn>
写入消息新闻:d70qtf$1gv$1 digitaldaemon.com...
I find it's disturbing when i'm using D in the program for my thesis. In an 
ant-based algorithm the basic operation is array access, it will be called 
even over 10e8 times! So you guys know why i want to turn the check off.
 Any ideas?
Please, share your solution. We'd all like to learn how to better overcome such problems in our own code. :) - EricAnderton at yahoo
May 25 2005
parent reply Dave <Dave_member pathlink.com> writes:
In article <d725kb$2tuf$1 digitaldaemon.com>, pragma says...
In article <d720ps$2pcd$1 digitaldaemon.com>, uframer says...
Thank you all!
I think i have fixed the problem.
"uframer" <uframer sina100.com.cn>
写入消息新闻:d70qtf$1gv$1 digitaldaemon.com...
I find it's disturbing when i'm using D in the program for my thesis. In an 
ant-based algorithm the basic operation is array access, it will be called 
even over 10e8 times! So you guys know why i want to turn the check off.
 Any ideas?
Please, share your solution. We'd all like to learn how to better overcome such problems in our own code. :) - EricAnderton at yahoo
Yes - and also please post the two sets of source code along with the different performance measurements you got. This would be interesting to many of us as well. - Dave
May 25 2005
parent "uframer" <uframer sina100.com.cn> writes:
Oops, i'm really a bad coder!
I think i should apologize for the blame on D. The performance problem does 
not mainly come from difference between D and Cpp, but from a subtle 
structure difference between the two versions that would alter the ants' 
random behavior significantly.:(
And , -release helps, it reduces the time consumption by about 30%. 
May 27 2005