c++ - call function in openmp parallelized loop -
i new openmp , have loop want parallelize openmp. inside parallel loop subroutine called. here code:
#pragma omp parallel shared(dir,utilitiespath,frequency,solvent,method,dispersion) private(beginning,file_cp2k,file_geo,file_energy) for(i=1;i<=n_conformers;i=i+1) { time(&beginning); file_cp2k="conformer"+ qstring::number(i) +".inp"; file_geo= "conformer" + qstring::number(i) + "_geomm.sdf"; file_energy=dir+ "conformer" + qstring::number(i) + "_enerse"; cout<<"loop "<<i<<" time "<<beginning<< endl; int n_atom=makecp2koptinput(file_geo, file_cp2k, dir,utilitiespath, frequency, solvent, method,dispersion); }
i following error:
* error in `./chemalivemolopt': double free or corruption (fasttop): 0x00000000018d7c00 * aborted (core dumped)
if remove call subroutine there no problem.
how should proceed parallelize loop properly?
thanks
all code openmp-enabled loop executes must thread safe. subroutine not thread safe. thread safety means synchronize access global/shared objects.
this not easy topic, recommend study thread safety , mutex-based synchronization in order solve problem.
Comments
Post a Comment