 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Xiaozhu Guest
|
Posted: Fri Aug 27, 2004 4:00 pm Post subject: icc -axW problem |
|
|
I trid to use icc -axW to optimize the code, but it becomes much slower...
8sec/37sec before and after using this option.
my cpu is Intel(R) Pentium(R) 4 CPU 2.40GHz
the test code is just one loop:
for(int i=0; i<100000000; i++){
p=sin(double(i));
}
What is wrong? Thanks!
|
|
| Back to top |
|
 |
Thomas Matthews Guest
|
Posted: Fri Aug 27, 2004 8:32 pm Post subject: Re: icc -axW problem |
|
|
Xiaozhu wrote:
| Quote: | I trid to use icc -axW to optimize the code, but it becomes much slower...
8sec/37sec before and after using this option.
my cpu is Intel(R) Pentium(R) 4 CPU 2.40GHz
the test code is just one loop:
for(int i=0; i<100000000; i++){
p=sin(double(i));
}
What is wrong? Thanks!
|
From what you have supplied us, the whole loop
can be optimized away since the value of "p"
is not used anywhere inside the loop nor outside
of the loop.
Another optimization is to remove the assignment
statement. The loop may be a timing loop and thus
needed.
By the way, the argument to the sin function is
in units of radians and there no more than PI/2
radians in a circle. Any number larger than this
causes a modulo on the radians (extra work for
the sin function).
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
|
|
| Back to top |
|
 |
Xiaozhu Guest
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|