ADOL-C
ADOL-C copied to clipboard
OpenMP and tensor_eval()
I have problems parallelizing some part of code with OpenMP. This is an example:
#include <iostream>
#include <omp.h>
#include <adolc/adolc.h>
#include <adolc/adolc_openmp.h>
int main(){
int max_t = omp_get_num_threads();
double x[max_t];
double y[max_t];
#pragma omp parallel for ADOLC_OPENMP_NC
for(int i = 0; i < 10000; ++i)
{
int numt = omp_get_thread_num();
double** tensor2 = myalloc(1,3);
double** S = myalloc(1,1);
S[0][0] = 1.0;
adouble a_y, a_x;
trace_on(numt);
a_x <<= x[numt];
a_y = pow(2*a_x,3);
a_y >>= y[numt];
trace_off();
double o = 1.0*i;
// function(numt,1,1,&o,&y[numt]);
// zos_forward(numt,1,1,1,&o,&y[numt]);
// fos_reverse(numt,1,1,&o,&y[numt]);
tensor_eval(numt,1,1,2,1,&o,tensor2,S);
std::cout << tensor2[0][2] << std::endl;
// std::cout << y[numt] << std::endl;
}
return 0;
}
When executing with #pragma omp parallel for ADOLC_OPENMP_NC
it gives me Segmentation fault (core dumped)
, no problem with function()
or zos_forward()
and fos_reverse()
.
Thanks for your patience.
OS: Ubuntu 19.10 Adol-C version: tested with v2.7.2
Hi,
thanks for your message. I will have a look at this as soon as possible.
Best
Andrea