[cfe-dev] [Openmp-dev] [OpenMP] Parameter packs

Kelvin Li via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 16 07:55:45 PDT 2018


I do not think it is very difficult.  The experts on the list can correct 
me if there
are some complications involved.

A reference implementation can always help the standardization process.

Kelvin


David Greene <dag at cray.com> wrote on 2018/10/15 11:08:49 AM:

> From: David Greene <dag at cray.com>
> To: Kelvin Li <kli at ca.ibm.com>
> Cc: "cfe-dev at lists.llvm.org" <cfe-dev at lists.llvm.org>, Openmp-dev 
> <openmp-dev-bounces at lists.llvm.org>, "openmp-dev at lists.llvm.org" 
> <openmp-dev at lists.llvm.org>
> Date: 2018/10/15 11:15 AM
> Subject: Re: [Openmp-dev] [OpenMP] Parameter packs
> 
> Good to hear.  Is it technically difficult to do in clang?  If not,
> would an experimental implementation help the committee?
> 
>                                -David
> 
> Kelvin Li via Openmp-dev <openmp-dev at lists.llvm.org> writes:
> 
> > 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."
> >
> > 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
> >> INVALID URI REMOVED
> >>
> > 
> 
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
> > INVALID URI REMOVED
> 
u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_openmp-2Ddev&d=DwIFAw&c=jf_iaSHvJObTbx-
> siA1ZOg&r=yebGUrvFJWJ7GtM9woczVA&m=mjlomL7F-
> 
du_g3pBBm4fwgsDuDM41jGNr3ndgflnJfQ&s=gSADVaIIvC4wmZn4vCIKIvoa1jQ9wps2fbpp91-
> T25c&e=
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181016/fa9baa06/attachment.html>


More information about the cfe-dev mailing list