Support for the define argument (-D) in the CUDA mode

This commit is contained in:
Simeon Ehrig 2019-02-13 11:57:28 +01:00 committed by SFT
parent 2489cf13b1
commit 0d9d8be5b9
2 changed files with 47 additions and 0 deletions

View File

@ -153,6 +153,13 @@ namespace cling {
*/
std::vector<std::string> additionalPtxOpt;
// search for defines (-Dmacros=value) in the args and add them to the PTX
// compiler args
for (const char* arg : invocationOptions.CompilerOpts.Remaining) {
std::string s = arg;
if (s.compare(0, 2, "-D") == 0) additionalPtxOpt.push_back(s);
}
m_CuArgs.reset(new IncrementalCUDADeviceCompiler::CUDACompilerArgs(
cppStdVersion, optLevel, smVersion, ptxSmVersion, fatbinSmVersion,
fatbinArch, invocationOptions.Verbose(), debug, additionalPtxOpt,

View File

@ -0,0 +1,40 @@
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
// The Test checks whether a define argument (-DTEST=3) is passed to the PTX
// compiler. If it works, it should not throw an error.
// RUN: cat %s | %cling -DTEST=3 -x cuda -Xclang -verify 2>&1 | FileCheck %s
// REQUIRES: cuda-runtime
#include <iostream>
// Check if cuda driver is available
int version;
cudaDriverGetVersion(&version)
// CHECK: (cudaError_t) (cudaError::cudaSuccess) : (unsigned int) 0
// Check if a CUDA compatible device (GPU) is available.
int device_count = 0;
cudaGetDeviceCount(&device_count)
// CHECK: (cudaError_t) (cudaError::cudaSuccess) : (unsigned int) 0
device_count > 0
// CHECK: (bool) true
TEST
// CHECK: (int) 3
.rawInput 1
__global__ void g(){
int i = TEST;
}
.rawInput 0
// expected-no-diagnostics
.q