2

I need to call Atan on millions of values per second. Is there a good library to perform this operation in batch very fast. For example, a library that streams the low level logic using something like SSE?

I have profiled the application, and I know that this call to Atan is a bottleneck.

I know that there is support for this in OpenCL, but I would prefer to do this operation on the CPU. The target machine might not support OpenCL.

I also looked into using OpenCV, but it's accuracy for Atan angles is only ~0.3 degrees. I need accurate results.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Sean
  • 1,373
  • 2
  • 14
  • 26
  • What accuracy do you need and what are your input values (int, float, double, other ? single value, or y / x pair ?) – Paul R May 25 '10 at 20:31
  • Single or double precision is OK. I would like accuracy of about 1/3600 of a degree. – Sean May 25 '10 at 20:56
  • I did some beter performance tracing with dotTrace, and found that the bottleneck actually wasn't the Atan call, but the assignment operation that I was using on the same line. I'm still interested, however, in any good trig libraries for streaming / batched operations. – Sean May 25 '10 at 20:58
  • Let me guess. Is your assignment statement indexing a vector in debug code, as in this example: http://stackoverflow.com/questions/1932222/c-vector-vs-array-time/1933356#1933356 – Mike Dunlavey May 25 '10 at 22:08

1 Answers1

1

Why don't you try Brahma? To my understanding, it's a free and open source GPGPU library that doesn't depend on OpenCL, instead converting code to HLSL/GLSL shaders via LINQ.

EDIT: Sample code:

ComputationProvider provider = new ComputationProvider();
CompiledQuery query = provider.Compile<DataParallelArray<float>>(
    data => from value in data
            select (float)Math.Atan(value)); // Do your calculations here...

DataParallelArray<float> input = new DataParallelArray<float>(provider, new float[] { 0, 1, 2, 3, 4, 5, 6, 7, }); // etc...
IQueryable result = provider.Run(query, input);

foreach (float value in result)
    Console.WriteLine(value);
YellPika
  • 2,872
  • 2
  • 28
  • 31