# Is there a way to convert mathematica code to OpenMP or OpenACC?

I see that Mathematica has limited support for things like OpenCL and CUDA, but what about other standards like OpenMP or OpenACC?

-
Out of curiosity, do you know of a different system offering less limited CUDA support ? –  b.gatessucks Oct 22 '12 at 17:21
@b.gatessucks The double negatives you use confuse me. –  drN Oct 22 '12 at 17:29
@drN I have a CUDA-enabled GPU so if there is a system which supports that better than Mathematica I'd be very interested. –  b.gatessucks Oct 22 '12 at 17:32
@b.gatessucks right on! –  drN Oct 22 '12 at 18:45
Using OpenMP is a bit troublesome since most of Mathematica's internals are not thread-safe. That's (part of) why the parallelism model of the Parallel` package is distributed- rather than shared-memory multiprocessing. That being said, you can generate C code from compiled functions and insert the OpenMP directives yourself if you want, although this should be considered purely experimental. –  Oleksandr R. Oct 23 '12 at 1:52

Just so that this (deserving) question has at least some sort of answer: I used OpenMP in my answer here, specifically in the context of a LibraryLink program written in C. Since this is user-written rather than auto-generated code, we can be sure that our use of OpenMP is correct with respect to thread safety. This is not the best example; especially with OpenMP 3.0, one can do things much more complicated than just parallelizing a small loop. However, I feel that it is sufficient to show that such things can be done without unexpected problems.

-
Is there a particular reason why you made your answer community wiki? J.M. did this too quite often the last times and I'm not sure I could say why. –  halirutan Jul 7 '13 at 17:27
@halirutan because it is not a proper answer by itself, but rather a reference to my answer to another question. Since this question has gone unanswered for so long, clearly nobody is in a position to write a complete answer, but perhaps they could still add useful information into this post. I set CW to indicate that I don't claim ownership over this "answer", but rather offer it to anyone in the community to make whatever modifications they see fit. –  Oleksandr R. Jul 7 '13 at 17:38