Click here to Skip to main content
15,887,585 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Link error Pin
Cedric Moonen13-Oct-09 0:20
Cedric Moonen13-Oct-09 0:20 
Questionfast fast fast Pin
__erfan__12-Oct-09 22:43
__erfan__12-Oct-09 22:43 
AnswerRe: fast fast fast Pin
CPallini12-Oct-09 22:57
mveCPallini12-Oct-09 22:57 
GeneralRe: fast fast fast Pin
__erfan__12-Oct-09 23:09
__erfan__12-Oct-09 23:09 
GeneralRe: fast fast fast Pin
CPallini13-Oct-09 0:01
mveCPallini13-Oct-09 0:01 
AnswerRe: fast fast fast Pin
Rajesh R Subramanian12-Oct-09 23:05
professionalRajesh R Subramanian12-Oct-09 23:05 
GeneralRe: fast fast fast Pin
__erfan__12-Oct-09 23:12
__erfan__12-Oct-09 23:12 
AnswerRe: fast fast fast Pin
Rolf Kristensen13-Oct-09 0:07
Rolf Kristensen13-Oct-09 0:07 
You could consider doing 4 double operations in each for-loop. This would allow modern CPU's to perform the operation in parallel.

Taken from Software Optimization Guide for AMD64 Processors[^]:


Rationale and Examples
This is especially important to break long dependency chains into smaller executing units in floating-point code, whether it is mapped to x87, SSE, or SSE2 instructions, because of the longer latency of
floating-point operations. Because most languages (including ANSI C) guarantee that floating-point expressions are not reordered, compilers cannot usually perform such optimizations unless they offer a switch to allow noncompliant reordering of floating-point expressions according to algebraic rules.
Reordered code that is algebraically identical to the original code does not necessarily produce identical computational results due to the lack of associativity of floating-point operations. There are
well-known numerical considerations in applying these optimizations (consult a book on numerical analysis). In some cases, these optimizations may lead to unexpected results. In the vast majority of
cases, the final result differs only in the least-significant bits.

Listing 10. Avoid
double a[100], sum;
int i;
sum = 0.0f;
for (i = 0; i < 100; i++) {
   sum += a[i];
}


Listing 11. Preferred
double a[100], sum1, sum2, sum3, sum4, sum;
int i;
sum1 = 0.0;
sum2 = 0.0;
sum3 = 0.0;
sum4 = 0.0;
for (i = 0; i < 100; i + 4) {
   sum1 += a[i];
   sum2 += a[i+1];
   sum3 += a[i+2];
   sum4 += a[i+3];
}
sum = (sum4 + sum3) + (sum1 + sum2);


Notice that the four-way unrolling is chosen to exploit the four-stage fully pipelined floating-point adder. Each stage of the floating-point adder is occupied on every clock cycle, ensuring maximum sustained utilization.

JokeRe: fast fast fast Pin
CPallini13-Oct-09 0:14
mveCPallini13-Oct-09 0:14 
GeneralRe: fast fast fast Pin
__erfan__13-Oct-09 0:27
__erfan__13-Oct-09 0:27 
QuestionStored Procedure Pin
MsmVc12-Oct-09 22:14
MsmVc12-Oct-09 22:14 
AnswerRe: Stored Procedure Pin
Rajesh R Subramanian12-Oct-09 22:16
professionalRajesh R Subramanian12-Oct-09 22:16 
GeneralRe: Stored Procedure Pin
MsmVc12-Oct-09 22:19
MsmVc12-Oct-09 22:19 
Questionhow to caputre screen including movie play ? Pin
rambojanggoon12-Oct-09 21:19
rambojanggoon12-Oct-09 21:19 
AnswerRe: how to caputre screen including movie play ? Pin
Rajesh R Subramanian12-Oct-09 21:25
professionalRajesh R Subramanian12-Oct-09 21:25 
AnswerRe: how to caputre screen including movie play ? Pin
Hans Dietrich12-Oct-09 23:58
mentorHans Dietrich12-Oct-09 23:58 
AnswerRe: how to caputre screen including movie play ? Pin
kilt13-Oct-09 2:14
kilt13-Oct-09 2:14 
QuestionEvents waiting on c++ Pin
shiranraviv12-Oct-09 20:42
shiranraviv12-Oct-09 20:42 
AnswerRe: Events waiting on c++ Pin
CPallini12-Oct-09 21:03
mveCPallini12-Oct-09 21:03 
GeneralRe: Events waiting on c++ Pin
shiranraviv12-Oct-09 21:06
shiranraviv12-Oct-09 21:06 
QuestionRe: Events waiting on c++ Pin
CPallini12-Oct-09 21:15
mveCPallini12-Oct-09 21:15 
AnswerRe: Events waiting on c++ Pin
shiranraviv12-Oct-09 21:44
shiranraviv12-Oct-09 21:44 
AnswerRe: Events waiting on c++ Pin
Rajesh R Subramanian12-Oct-09 21:15
professionalRajesh R Subramanian12-Oct-09 21:15 
Questionshift oerator Pin
hrishiS12-Oct-09 20:14
hrishiS12-Oct-09 20:14 
AnswerRe: shift oerator Pin
CPallini12-Oct-09 20:58
mveCPallini12-Oct-09 20:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.