[Bug target/105640] [OpenMP] Context selectors missing for PowerPC

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 18 10:02:16 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105640

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Regarding LLVM, I have no idea, but doing some searching, I do see:

* clang/test/OpenMP/declare_variant_clauses_ast_print.cpp:
//PRINT: #pragma omp declare variant(foo_v2) match(construct={dispatch},
device={arch(ppc)}) adjust_args(need_device_ptr:AAA)

* clang/test/OpenMP/declare_variant_messages.c:
#pragma omp begin declare variant match(device={isa(sse2020), arch(ppc)})

 * * *

Otherwise, the following archs are supported according to
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:

__OMP_TRAIT_PROPERTY(device, arch, arm)
__OMP_TRAIT_PROPERTY(device, arch, armeb)
__OMP_TRAIT_PROPERTY(device, arch, aarch64)
__OMP_TRAIT_PROPERTY(device, arch, aarch64_be)
__OMP_TRAIT_PROPERTY(device, arch, aarch64_32)
__OMP_TRAIT_PROPERTY(device, arch, ppc)
__OMP_TRAIT_PROPERTY(device, arch, ppcle)
__OMP_TRAIT_PROPERTY(device, arch, ppc64)
__OMP_TRAIT_PROPERTY(device, arch, ppc64le)
__OMP_TRAIT_PROPERTY(device, arch, x86)
__OMP_TRAIT_PROPERTY(device, arch, x86_64)
__OMP_TRAIT_PROPERTY(device, arch, amdgcn)
__OMP_TRAIT_PROPERTY(device, arch, nvptx)
__OMP_TRAIT_PROPERTY(device, arch, nvptx64)


It is not quite clear what is permitted as ISA. That file has:

OMP_TRAIT_PROPERTY(device_isa___ANY, device, device_isa,
                   "<any, entirely target dependent>")

and later in the .cc code:

    // We overwrite the isa trait as it is actually up to the OMPContext hook
to
    // check the raw string(s).
    if (Property == TraitProperty::device_isa___ANY)
      IsActiveTrait = llvm::all_of(VMI.ISATraits, [&](StringRef RawString) {
        return Ctx.matchesISATrait(RawString);

which in turn uses:

bool TargetOMPContext::matchesISATrait(StringRef RawString) const {
  auto It = FeatureMap.find(RawString);
  if (It != FeatureMap.end())
    return It->second;
  if (!FeatureValidityCheck(RawString))
    DiagUnknownTrait(RawString);
  return false;

which in turn is initialized via

void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
                                       const FunctionDecl *FD) const {
  if (FD)
    getFunctionFeatureMap(FeatureMap, GlobalDecl().getWithDecl(FD));
  else
    Target->initFeatureMap(FeatureMap, getDiagnostics(),
                           Target->getTargetOpts().CPU,
                           Target->getTargetOpts().Features);
}

In my understanding, that matches:
  clang/lib/Basic/Targets/NVPTX.h:    Features[CudaArchToString(GPU)] = true;
  clang/lib/Basic/Targets/NVPTX.h:    Features["ptx" +
std::to_string(PTXVersion)] = true;
where the former comes from
  static const CudaArchToStringMap arch_names
in clang/lib/Basic/Cuda.cpp

and for PowerPC, there is clang/lib/Basic/Targets/PPC.cpp


More information about the Gcc-bugs mailing list