openmp parallel for loop with two or more reductions

前端 未结 2 1810
醉话见心
醉话见心 2021-02-07 09:03

Hi just wondering if this is the right way to go going about having a regular for loop but with two reductions , is this the right approach below? Would this work with more then

2条回答
  •  时光说笑
    2021-02-07 09:49

    You can do reduction by specifying more than one variable separated by a comma, i.e. a list:

    #pragma omp parallel for default(shared) reduction(+:sum,result) ...

    Private thread variables will be created for sum and result that will be combined using + and assigned to the original global variables at the end of the thread block.

    Also, variable y should be marked private.

    See https://computing.llnl.gov/tutorials/openMP/#REDUCTION

提交回复
热议问题