Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenMP and tensor_eval() #23

Open
andrea-afk opened this issue Apr 12, 2020 · 1 comment
Open

OpenMP and tensor_eval() #23

andrea-afk opened this issue Apr 12, 2020 · 1 comment

Comments

@andrea-afk
Copy link

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

@awalther1
Copy link
Contributor

Hi,

thanks for your message. I will have a look at this as soon as possible.

Best

Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants