34 ms·
> but Rust does not provide the Intel _mm256_cos_pd() instruction yet. That might be part of the reason. Even with experience it's really hard to optimize code
by Fronzie 7y ago
> but Rust does not provide the Intel _mm256_cos_pd() instruction yet.
That might be part of the reason. Even with experience it's really hard to optimize code without detailed profiling.
Either with a profiler that shows clock-ticks per instruction or by making very small changes to your code and keep a log of the total running time after each change.
- tom_mellior 7y ago> > but Rust does not provide the Intel _mm256_cos_pd() instruction yet. > That might be part of the reason. Yes, a cosine calculation should dominate all the rest of the computation. Grepping through https://www.agner.org/optimize/instruction_tables.pdf https://www.agner.org/optimize/instruction_tables.pdf, the latency of FCOS is listed as at least 10x the latency of a floating-point add or multiply across pretty much all microarchitectures. I'm also unsure about re-packing the results of the cosine just to allow a single multiply, the results of which are then unpacked again. It might be faster to just do that multiply in scalar code, though that's exactly the thing that would need to be measured.