Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At this point in time, the OpenMP specification doesn't give the user any ability to control when threads are destroyed. What you are saying is very interesting and hasn't been brought up during any of the OpenMP language committee meetings to discuss the specification. Can you give more information about what you are doing and what the problem is? It would be helpful in bringing this discussion to the committee.</p> <p><strong>Edit added 3/7 -</strong></p> <p>Okay - here is a simple example that seems to work and it might get around your problem:</p> <pre><code>$&gt; cat prog.c #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;dlfcn.h&gt; int main(void) { void (*f)(void); void *handle; handle = dlopen("./shared.so", RTLD_NOW); if (!handle) { printf("*** dlopen error - %s\n", dlerror()); abort(); } f = dlsym(handle, "foo"); if (!f) { printf("*** dlsym error - %s\n", dlerror()); abort(); } f(); if(dlclose(handle)) { printf("*** dlclose error - %s\n", dlerror()); abort(); } return 0; } $&gt; cat shared.c #include &lt;omp.h&gt; #include &lt;stdio.h&gt; void foo(void) { int i; puts("... in foo\n"); #pragma omp parallel for for (i=0; i&lt;10; i++) printf("t#: %i i: %i\n", omp_get_thread_num(), i); puts("... exiting foo"); } $&gt; gcc -rdynamic -fopenmp prog.c -ldl -o prog $&gt; gcc -c -fopenmp -fPIC -o shared.o shared.c $&gt; ld -shared -o shared.so shared.o $&gt; ./prog ... in foo t#: 2 i: 4 t#: 2 i: 5 t#: 3 i: 6 t#: 3 i: 7 t#: 0 i: 0 t#: 0 i: 1 t#: 4 i: 8 t#: 4 i: 9 t#: 1 i: 2 t#: 1 i: 3 ... exiting foo </code></pre> <p>While there is no OpenMP code in the main program (prog.c), I compiled it using the -fopenmp flag. This means that the OpenMP environment will be set up before the call to the shared library that is actually using OpenMP. This seems to get around the problem with doing a dlclose, since the environment is still there. It also allows the threads gotten by the first use of OpenMP to stay around for subsequent use. Does this work for getting around your problem (or does this only work for this simple example)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload