c++ - Possible data race condition using openMP, corrupted data -
i have code works fine when running on 1 thread. have been using open mp parralellize code. problem when use more 1 thread start corrupted results. best guess have data race condition somewhere in code cannot find it. thoughts or advice appreciated. in advance.
omp_set_num_threads( 12 ); double average = 0; int x; #pragma omp parallel schedule(static) reduction(+:average) for(x = 0; x<k_folds_folds; x++) //need paralellize loop { double result = logistic_regression_test(xtraining[x], xtest[x], ytraining[x], ytest[x]); average += result; }
the code works fine when comment out omp_set_num_threads. k_folds_folds = 15 , logistic_regression_test function bunch of stuff , returns double. possible problem somewhere within function? function create local variables @ same memory location every time, if multiple threads executing function? explain corrupted data if each function called in parallel changing same memory addresses.
Comments
Post a Comment