I try to call OpenMP
codes in my R
package. The OpenMP region in a fun.c
file under the src
directory is like:
static void mp_func(double *x, double *a, double *b,
double *den, int *P) {
#pragma omp parallel for num_threads(P[0]) default(none) \
firstprivate(length, q, a, b, isLog, lowTail, cdf, R_NaN) private(i) \
reduction(||:naflag)
for (i = 0; i < length; i++){
...
if(some condition) den[i] = R_NaN;
...
if(some condition) den[i] = R_NegInf;
}
}
However, when I run R CMD CHECK
, `it gives error message that:
enclosing parallel;
and
R_NaN not specified in enclosing parallel;
I don't think including R_NaN
and R_NegInf
in the private
clause is possible, so how can I solve it? Should I wrap all operation part into a function and call this function in the OpenMP region?