|
In C and C++ complex arithmetic is pretty easy. Operator overloading and all that makes it pretty straightforward to do. I am faced with a bit more "complex" of a task however.
I am working with OpenCL right now. I have an equation (The Teukolsky equation for those of you who are curious) that has 4000 temporary variables that are used to determine what is known as the "Source Term" of the equation. These temporary variables are of the complex type.
In openCL, you can create classes and structs and whatnot, but when it comes time to run the parallelized portions of code, you must run them in a kernel. Easy, right?
Well, I've come to find out, you cannot append any libraries to a kernel file. No printf statements, no structs, nothing. THis leaves me with the predicament: how do I do complex arithmetic from within a kernel? Since there are a lot of variables, writing separate functions for add, subtract etc etc is not worth doing at all, as they are called thousands of times and this would eliminate any sort of gain I am hoping to get from parallelizing this portion of code.
Does anyone have any ideas as to how I would do this!?
|