Page MenuHomePhabricator

[OpenMP] Add match_{all,any,none} declare variant selector extensions.

Authored by jdoerfert on Apr 3 2020, 9:50 AM.



By default, all traits in the OpenMP context selector have to match for
it to be acceptable. Though, we sometimes want a single property out of
multiple to match (=any) or no match at all (=none). We offer these
choices as extensions via


to the user. The choice will affect the entire context selector not only
the traits following the match property.

The first user will be D75788. There we can replace

#pragma omp begin declare variant match(device={arch(nvptx64)})
#define __CUDA__

#include <__clang_cuda_cmath.h>

// TODO: Hack until we support an extension to the match clause that allows "or".

#undef __CUDA__
#pragma omp end declare variant

#pragma omp begin declare variant match(device={arch(nvptx)})
#define __CUDA__

#include <__clang_cuda_cmath.h>

#undef __CUDA__
#pragma omp end declare variant

with the much simpler

#pragma omp begin declare variant match(device={arch(nvptx, nvptx64)}, implementation={extension(match_any)})
#define __CUDA__

#include <__clang_cuda_cmath.h>

#undef __CUDA__
#pragma omp end declare variant

Diff Detail

Event Timeline

jdoerfert created this revision.Apr 3 2020, 9:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2020, 9:50 AM
jdoerfert updated this revision to Diff 254983.Apr 3 2020, 7:21 PM

Allow the new match clauses to be used in begin/end declare variant as well (with their respective effect)

mikerice added inline comments.Apr 5 2020, 4:42 PM

One of the lit tests fails because this is called before semantic checks on the score expression. This function tries to evaluate the score as a constant and if it isn't will crash. Probably not specific to this change but how can we deal with that?

int foo(void);
#pragma omp begin declare variant match(implementation={vendor(score(foo()) ibm)})
#pragma omp end declare variant

Line too long?


Comment on nullptr would be nice.

jdoerfert updated this revision to Diff 255212.Apr 5 2020, 5:23 PM

Rebase and fix a problem with evaluation of non-constants

jdoerfert marked an inline comment as done.Apr 5 2020, 8:37 PM

Will fix the other two nits too.


Saw that too late but it's fixed now. We will ignore non-constant scores and evaluae non-constant user conditions as false. Note that both are not valid inputs we will diagnose later anyway.

mikerice accepted this revision.Apr 6 2020, 9:34 AM

Looks okay to me.

This revision is now accepted and ready to land.Apr 6 2020, 9:34 AM
This revision was automatically updated to reflect the committed changes.