c++ - Parallel OpenMP reduction vs. function definition? -


i'm using openmp problem i'm declaring/defining function follow:

void compute_image(double pixel[nb], double &sum) {         #pragma omp parallel reduction(+:sum)     (int j=0;j<640;j++)     {     if ...     sum=sum+pixel[0];     ....     } .... } 

what realise :

error   2   error c3030: 'sum' : variable in 'reduction' clause/directive cannot have reference type    c:\users...\test.cpp    930 

actually, cannot rid of openmp. solution?

instead of reduction, put sum=sum+pixel[0] under #pragma omp atomic or #pragma omp critical line.

another option have double local_sum = sum; before omp section, reduce on local_sum, , have sum = local_sum; after loop.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -