OpenMP reduction with template type

后端 未结 1 1376
执念已碎
执念已碎 2021-01-20 14:39
template 
static T sum(const std::array& a)
{
    T result;

    // type of          


        
1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-20 15:38

    It's unspecified (for OpenMP 3.0 or later) or undefined (for OpenMP 2.5)

    reduction is one of data-sharing attribute clauses, and OpenMP Application Program Interface Version 2.5 says:

    2.8.3 Data-Sharing Attribute Clauses
    ---- C/C++ ----
    If a variable referenced in a data-sharing attribute clause has a type derived from a template, and there are no other references to that variable in the program, then any behavior related to that variable is undefined.
    ---- C/C++ ----

    OpenMP Application Program Interface Version 3.0 says:

    2.9.3 Data-Sharing Attribute Clauses
    ---- C/C++ ----
    If a variable referenced in a data-sharing attribute clause has a type derived from a template, and there are no other references to that variable in the program, then any behavior related to that variable is unspecified.
    ---- C/C++ ----

    0 讨论(0)
提交回复
热议问题