Coverage Report

Created: 2020-11-24 06:42

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
Line
Count
Source (jump to first uncovered line)
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
29
CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVPTX(CodeGenModule &CGM)
30
210
    : CGOpenMPRuntimeGPU(CGM) {
31
210
  if (!CGM.getLangOpts().OpenMPIsDevice)
32
0
    llvm_unreachable("OpenMP NVPTX can only handle device code.");
33
210
}
34
35
621
llvm::Value *CGOpenMPRuntimeNVPTX::getGPUWarpSize(CodeGenFunction &CGF) {
36
621
  return CGF.EmitRuntimeCall(
37
621
      llvm::Intrinsic::getDeclaration(
38
621
          &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
39
621
      "nvptx_warp_size");
40
621
}
41
42
506
llvm::Value *CGOpenMPRuntimeNVPTX::getGPUThreadID(CodeGenFunction &CGF) {
43
506
  CGBuilderTy &Bld = CGF.Builder;
44
506
  llvm::Function *F;
45
506
  F = llvm::Intrinsic::getDeclaration(
46
506
      &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x);
47
506
  return Bld.CreateCall(F, llvm::None, "nvptx_tid");
48
506
}
49
50
1.60k
llvm::Value *CGOpenMPRuntimeNVPTX::getGPUNumThreads(CodeGenFunction &CGF) {
51
1.60k
  CGBuilderTy &Bld = CGF.Builder;
52
1.60k
  llvm::Function *F;
53
1.60k
  F = llvm::Intrinsic::getDeclaration(
54
1.60k
      &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x);
55
1.60k
  return Bld.CreateCall(F, llvm::None, "nvptx_num_threads");
56
1.60k
}