Re: openmp reduction
От: remark Россия http://www.1024cores.net/
Дата: 10.09.10 09:44
Оценка:
Здравствуйте, barmale-y, Вы писали:

BY>Как понимать вот это утверждение о том, что переменные в операторе reduction должны быть декларированы как shared [url=здесь]https://computing.llnl.gov/tutorials/openMP/#REDUCTION[/url]]:


В MSDN это описано более вразумительно. Возможно на computing.llnl.gov копия из более старого стандарта OpenMP.

The restrictions to the reduction clause are as follows:

The type of the variables in the reduction clause must be valid for the reduction operator except that pointer types and reference types are never permitted.

A variable that is specified in the reduction clause must not be const-qualified.

Variables that are private within a parallel region or that appear in the reduction clause of a parallel directive cannot be specified in a reduction clause on a work-sharing directive that binds to the parallel construct.

#pragma omp parallel private(y)
{ /* ERROR - private variable y cannot be specified
             in a reduction clause */
   #pragma omp for reduction(+: y)
   for (i=0; i<n; i++)
      y += b[i];
}

/* ERROR - variable x cannot be specified in both
           a shared and a reduction clause */
#pragma omp parallel for shared(x) reduction(+: x)



1024cores &mdash; all about multithreading, multicore, concurrency, parallelism, lock-free algorithms
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.