clang  14.0.0git
CGOpenMPRuntimeNVPTX.cpp
Go to the documentation of this file.
1 //===---- CGOpenMPRuntimeNVPTX.cpp - Interface to OpenMP NVPTX 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 NVPTX
10 // targets from generalized CGOpenMPRuntimeGPU class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "CGOpenMPRuntimeNVPTX.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/IR/IntrinsicsNVPTX.h"
24 
25 using namespace clang;
26 using namespace CodeGen;
27 using namespace llvm::omp;
28 
30  : CGOpenMPRuntimeGPU(CGM) {
31  if (!CGM.getLangOpts().OpenMPIsDevice)
32  llvm_unreachable("OpenMP NVPTX can only handle device code.");
33 }
34 
36  return CGF.EmitRuntimeCall(
37  llvm::Intrinsic::getDeclaration(
38  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
39  "nvptx_warp_size");
40 }
41 
43  CGBuilderTy &Bld = CGF.Builder;
44  llvm::Function *F;
45  F = llvm::Intrinsic::getDeclaration(
46  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x);
47  return Bld.CreateCall(F, llvm::None, "nvptx_tid");
48 }
CodeGenFunction.h
CGOpenMPRuntimeNVPTX.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::EmitRuntimeCall
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
clang::CodeGen::CGOpenMPRuntimeNVPTX::getGPUWarpSize
llvm::Value * getGPUWarpSize(CodeGenFunction &CGF) override
Get the GPU warp size.
Definition: CGOpenMPRuntimeNVPTX.cpp:35
clang::CodeGen::CGOpenMPRuntimeNVPTX::getGPUThreadID
llvm::Value * getGPUThreadID(CodeGenFunction &CGF) override
Get the id of the current thread on the GPU.
Definition: CGOpenMPRuntimeNVPTX.cpp:42
clang::CodeGen::CodeGenModule::getModule
llvm::Module & getModule() const
Definition: CodeGenModule.h:709
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
StmtVisitor.h
clang::CodeGen::CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVPTX
CGOpenMPRuntimeNVPTX(CodeGenModule &CGM)
Definition: CGOpenMPRuntimeNVPTX.cpp:29
Cuda.h
clang::CodeGen::CodeGenFunction::CGM
CodeGenModule & CGM
Definition: CodeGenFunction.h:266
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::CGOpenMPRuntime::CGM
CodeGenModule & CGM
Definition: CGOpenMPRuntime.h:305
CGOpenMPRuntimeGPU.h