c++ - openMP excessive synchronization -
i trying add openmp parallelization quite big project , found out openmp synchronization outside parallel blocks.
this synchronization done of variables, not used in parallel block , done continuously, not before entering block.
i made example proving this:
#include <cmath> int main() { double dummy1 = 1.234; int const size = 1000000; int const size1 = 2500; int const size2 = 500; for(unsigned int i=0; i<size; ++i){ //for (unsigned int j=0; j<size1; j++){ // dummy1 = pow(dummy1/2 + 1, 1.5); //} #pragma omp parallel (unsigned int j=0; j<size2; j++){ double dummy2 = 2.345; dummy2 = pow(dummy2/2 + 1, 1.5); } } }
if run code (with cycle commented), runtimes 6.75s parallelization , 30.6s without. great.
but if uncomment cycle , run again, excessive synchronization kicks in , results 67.9s parallelization , 73s without. if increase size1 slower results parallelization without it.
is there way disable synchronization , force before second cycle? or other way how improve speed?
note outer neither first cycle in real example parallelizable. outer 1 in fact ode solver , first inner 1 updating of loads of inner values.
i using gcc (suse linux) 4.8.5
thanks answers.
Comments
Post a Comment