views:

68

answers:

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.

+1  A: 

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
Very interesting. I hadn't heard of Brahma.
Sean
It doesn't look like it provides trig functions?
Sean
Edited answer. Brahma does in fact support trig functions. All System.Math functions are supported as long as their is an equivalent in HLSL/GLSL.
YellPika
A: 

Check out this thread on fast trig functions in Java.

http://stackoverflow.com/questions/523531/fast-transcendent-trigonometric-functions-for-java

bbudge