I have written a library in C using a variety of the #pragma omp directives to parallelize execution. I am on Mac OS X 10.6. I have then wrapped these functions in a JNI library and called them from my Java application.
It seems that calls to native functions containing OpenMP directives crash with EXC_BAD_ACCCESS if they are called from a Java thread besides the main one - in other words,
public static void main(String[] args) { nativeCall(); }
works, but calling the library on another thread, say the EventQueue
public static void main(String[] args) {
SwingUtilities.invokeLater(
new Runnable(){
public void run() { nativeCall(); }
});}
crashes with EXC_BAD_ACCESS.
I am a newcomer to OpenMP so I am not sure what could be causing this. What is special about the java "main" thread? Does it run in some privileged mode such that only it can access the resources necessary to initialize OpenMP parallelization tasks? I am also not intimately familiar with the inner workings of the JVM on OS X so I am not sure what the relationship between Java threads and native threads is.
Any help is appreciated!