   SSE
  Hello,I have the following code: /* SIZE is of the order of 1 million */double opt[SIZE];const double X;double SSi;const double factor = ...;const double p0=...,p1=...;for (int i=0; i<=imax; ++i,SSi*=factor) { const double intrinsic = X-SSi>0.0? X-SSi: 0.0; const double valueAtNode = p0*opt + p1*opt[i+1]; opt = valueAtNode>intrinsic? valueAtNode : intrinsic;}on intel core2 processors, I would like to see if there's a perf improvement by using SSE intrinsic functions with Intel compiler?
  I think the biggest bottleneck will be memory bandwidth. Using SSE will give you computational improvements (such as using MAXPD for the calculation of intrinsic) but you will have an unaligned 128bit load on the valueAtNode line. You can also get a speed improvement by dividing the array into a number of segments and give each chunk to a CPU (so if there's two CPUs give half to each, if there's four give a quarter and so on). You won't need to use the prefetch instructions as the memory access can easily be streamed by the CPUs memory management unit. But, as I said, you will quickly reach a maximum speed due to memory contraints.Skizz   ;Quote:Original post by julhichHello,I have the following code: /* SIZE is of the order of 1 million */double opt[SIZE];That won't normally fit on the stack. Make sure your code works before you attempt to optimize it.Quote: const double intrinsic = X-SSi>0.0? X-SSi: 0.0;It seems likely that this value will give 'X-SSi' for just the first few iterations and '0.0' for all the others (I assume factor > 1.0). You *might* be better off first figuring out where the crossover occurs and then doing two separate loops.Quote: const double valueAtNode = p0*opt + p1*opt[i+1]; opt = valueAtNode>intrinsic? valueAtNode : intrinsic;}This (reading and then writing to the same location within the loop) introduces a dependency that limits parallelization, if I'm thinking clearly.Quote:on intel core2 processors, I would like to see if there's a perf improvement by using SSE intrinsic functions with Intel compiler?Is it currently slow enough that you could actually "see" any potential performance improvement?Also, what does this calculation *do*?   ;Quote:Original post by ZahlmanIs it currently slow enough that you could actually "see" any potential performance improvement? Perhaps not that related to this thread, but concerns optimisations nevertheless:  The Top 10 Myths of Video Game Optimization.   