admin管理员组

文章数量:1122846

I have a fortran function that solves an eigenproblem using ARPACK. I am trying to use this function in a parallel context. The function is called from a C file.

I was hoping this would work:

#pragma omp parallel for
for (int i=0; i < N; i++)
{
    double *var1 ... ;
    my_arpack_function(var1 ...); // Function call, with only vars local to the block passed
}

the function itself is not parallelized, but each thread makes their own call to the function. I was hoping this would work but it fails.

The following works, though eliminates any benefits of paralellization

#pragma omp parallel for ordered
for (int i=0; i < N; i++)
{
    double *var1 ... ;
    #pragma omp ordered
    {
        my_arpack_function(var1 ...); // Function call, with only vars local to the block passed
    }    
}

It is known that ARPACK is not thread-safe, which is likely the reason for this failure. Is there any way I can force a private instance of all variables used by the function?

本文标签: cHow should ARPACK be called within an openmpparallelized for loopStack Overflow