School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,136 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,897 people online right now. Registration is fast and FREE... Join Now!




Complex Arithmetic

 

Complex Arithmetic, a little more complex

jmckennon

4 Nov, 2009 - 07:48 AM
Post #1

New D.I.C Head
*

Joined: 15 Mar, 2009
Posts: 18

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!?

User is offlineProfile CardPM
+Quote Post


JackOfAllTrades

RE: Complex Arithmetic

4 Nov, 2009 - 08:25 AM
Post #2

I exist to Google your problems.
Group Icon

Joined: 23 Aug, 2008
Posts: 5,322



Thanked: 454 times
Dream Kudos: 50
Expert In: Being annoyed with lazy people.

My Contributions
OpenCL. Don't know anything about it...I think I'll move this to Other Languages.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:02PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month