[Openmp-dev] [OpenMP] Parameter packs

Joachim Protze via Openmp-dev openmp-dev at lists.llvm.org
Mon Oct 15 08:16:18 PDT 2018


On 10/15/2018 05:03 PM, Kelvin Li via Openmp-dev wrote:
> The OpenMP specification has the following restriction:
> 
> "Variadic parameter packs cannot be expanded into a directive or its 
> clauses except as part of an expression argument to be evaluated by the 
> base language, such as into a function call inside an if clause."
> 

Glad to see that this is covered by spec text. Unfortunately, searching 
the document for "parameter pack" has no match, because of the line 
break between the two words :/

> The language committee has some discussions on it in the last 
> face-to-face meeting.  We will look into relaxing this restriction to 
> provide better usage with C++ templates.
> 
> Kelvin
> 
> 
> "Openmp-dev" <openmp-dev-bounces at lists.llvm.org> wrote on 2018/10/15 
> 10:45:30 AM:
> 
>  > From: David Greene via Openmp-dev <openmp-dev at lists.llvm.org>
>  > To: "cfe-dev at lists.llvm.org" <cfe-dev at lists.llvm.org>, "openmp-
>  > dev at lists.llvm.org" <openmp-dev at lists.llvm.org>
>  > Date: 2018/10/15 10:46 AM
>  > Subject: [Openmp-dev] [OpenMP] Parameter packs
>  > Sent by: "Openmp-dev" <openmp-dev-bounces at lists.llvm.org>
>  >
>  > Should this compile?
>  >
>  > #include <tuple>
>  >
>  > constexpr std::size_t N = 100;
>  >
>  > double A[N];
>  >
>  > template<typename ...Args>
>  > void loop(Args ...args) {
>  > #pragma omp parallel firstprivate(args...)
>  >   for (std::size_t i = 0; i < N; ++i) {
>  >     A[i] = (i + ... + args);
>  >   }
>  > }
>  >
>  > int main(void) {
>  >   std::apply([] (const auto & ...args) { loop(args...); },
>  >                  std::tuple<int, double, float>(10, 2.6, 3.4));
>  >   std::apply([] (const auto & ...args) { loop(args...); },
>  >                  std::tuple<int, long, char, double, short>(10, 100,
>  > 'b', 2.6, 3));
>  >   return 0;
>  > }
>  >
>  > clang++ errors with:
>  >
>  > firstprivate.cpp:10:39: error: expected ',' or ')' in 'firstprivate' 
> clause
>  > #pragma omp parallel firstprivate(args...)
>  >                   ^
>  > firstprivate.cpp:10:39: error: expected expression
>  > 2 errors generated.
>  >
>  > g++ gives a similar error.  I was not terribly surprised by this.
>  > However, it sure would be nice if it worked.
>  >
>  >   -David
>  > _______________________________________________
>  > Openmp-dev mailing list
>  > Openmp-dev at lists.llvm.org
>  > https://urldefense.proofpoint.com/v2/url?
>  > 
> u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_openmp-2Ddev&d=DwIGaQ&c=jf_iaSHvJObTbx-
>  > 
> siA1ZOg&r=yebGUrvFJWJ7GtM9woczVA&m=2EY3U33AkbJ5xLUmwJHWUGdi3b2YZ6eYCasI_AnITmo&s=5ovzADp3MTFkziuO0pgVRB4f6eqcyYS8Rujz1vEheF0&e=
>  >
> 
> 
> 
> _______________________________________________
> Openmp-dev mailing list
> Openmp-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev
> 



More information about the Openmp-dev mailing list