clang  14.0.0git
CGOpenMPRuntimeAMDGCN.cpp
Go to the documentation of this file.
1 //===-- CGOpenMPRuntimeAMDGCN.cpp - Interface to OpenMP AMDGCN Runtimes --===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This provides a class for OpenMP runtime code generation specialized to
10 // AMDGCN targets from generalized CGOpenMPRuntimeGPU class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "CGOpenMPRuntimeAMDGCN.h"
15 #include "CGOpenMPRuntimeGPU.h"
16 #include "CodeGenFunction.h"
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/DeclOpenMP.h"
19 #include "clang/AST/StmtOpenMP.h"
20 #include "clang/AST/StmtVisitor.h"
21 #include "clang/Basic/Cuda.h"
22 #include "llvm/ADT/SmallPtrSet.h"
23 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
24 #include "llvm/IR/IntrinsicsAMDGPU.h"
25 
26 using namespace clang;
27 using namespace CodeGen;
28 using namespace llvm::omp;
29 
31  : CGOpenMPRuntimeGPU(CGM) {
32  if (!CGM.getLangOpts().OpenMPIsDevice)
33  llvm_unreachable("OpenMP AMDGCN can only handle device code.");
34 }
35 
37  CGBuilderTy &Bld = CGF.Builder;
38  // return constant compile-time target-specific warp size
39  unsigned WarpSize = CGF.getTarget().getGridValue().GV_Warp_Size;
40  return Bld.getInt32(WarpSize);
41 }
42 
44  CGBuilderTy &Bld = CGF.Builder;
45  llvm::Function *F =
46  CGF.CGM.getIntrinsic(llvm::Intrinsic::amdgcn_workitem_id_x);
47  return Bld.CreateCall(F, llvm::None, "nvptx_tid");
48 }
CodeGenFunction.h
Attr.h
DeclOpenMP.h
clang::CodeGen::CodeGenModule::getLangOpts
const LangOptions & getLangOpts() const
Definition: CodeGenModule.h:703
clang::CodeGen::CGBuilderTy
Definition: CGBuilder.h:43
clang::CodeGen::CodeGenFunction::Builder
CGBuilderTy Builder
Definition: CodeGenFunction.h:274
clang::CodeGen::CGOpenMPRuntimeGPU
Definition: CGOpenMPRuntimeGPU.h:24
StmtOpenMP.h
clang::CodeGen::CodeGenFunction::getTarget
const TargetInfo & getTarget() const
Definition: CodeGenFunction.h:1989
clang::CodeGen::CGOpenMPRuntimeAMDGCN::getGPUWarpSize
llvm::Value * getGPUWarpSize(CodeGenFunction &CGF) override
Get the GPU warp size.
Definition: CGOpenMPRuntimeAMDGCN.cpp:36
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:235
clang::CodeGen::CodeGenModule
This class organizes the cross-function state that is used while generating LLVM code.
Definition: CodeGenModule.h:284
Value
Value
Definition: UninitializedValues.cpp:102
clang::CodeGen::CGOpenMPRuntimeAMDGCN::CGOpenMPRuntimeAMDGCN
CGOpenMPRuntimeAMDGCN(CodeGenModule &CGM)
Definition: CGOpenMPRuntimeAMDGCN.cpp:30
StmtVisitor.h
clang::CodeGen::CGOpenMPRuntimeAMDGCN::getGPUThreadID
llvm::Value * getGPUThreadID(CodeGenFunction &CGF) override
Get the id of the current thread on the GPU.
Definition: CGOpenMPRuntimeAMDGCN.cpp:43
Cuda.h
clang::CodeGen::CodeGenFunction::CGM
CodeGenModule & CGM
Definition: CodeGenFunction.h:266
clang::TargetInfo::getGridValue
virtual const llvm::omp::GV & getGridValue() const
Definition: TargetInfo.h:1429
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::CGOpenMPRuntime::CGM
CodeGenModule & CGM
Definition: CGOpenMPRuntime.h:305
clang::CodeGen::CodeGenModule::getIntrinsic
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
Definition: CodeGenModule.cpp:5043
CGOpenMPRuntimeGPU.h
CGOpenMPRuntimeAMDGCN.h