[ADOL-C] OpenMP within an active section

Chris Dembia cld72 at cornell.edu
Mon Mar 27 14:57:09 EDT 2017


Hey all:

I would like to use OpenMP with ADOL-C. I have looked at the OpenMP examples in the ADOL-C source code, and I have read the relevant section of the manual. However, I would like to use OpenMP *within* the active section, not surrounding the active section. For example:


------

int N = 5;
short int tag = 0;
trace_on(tag);

double* px = new double[N];
for (int i = 0; i < N; ++i) px[i] = 1.5;
adouble* x = new adouble[N];
double* py = new double[N];
adouble* y = new adouble[N];

for (int i = 0; i < N; ++i) x[i] <<= px[i];

#pragma omp parallel ADOLC_OPENMP_NC
{
    #pragma omp for
    for (int i = 0; i < N; ++i) {
        y[i] = x[i]*x[i];
    }
}

for (int i = 0; i < N; ++i) y[i] >>= py[i];

trace_off();

double** J = myalloc(N, N);
int success = jacobian(tag, N, N, px, J);
assert(success == 3);

for (int i = 0; i < N; ++i) {
    std::cout << "J[" << i << "][" << i << "]: " << J[i][i]
            << std::endl;
}


------

This code compiled and ran, but produced an incorrect Jacobian (all zeros). Commenting out the pragmas produced the correct Jacobian.

Is this possible?

Thank you,
Chris Dembia


More information about the ADOL-C mailing list