Support for the define argument (-D) in the CUDA mode
This commit is contained in:
parent
2489cf13b1
commit
0d9d8be5b9
@ -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,
|
||||
|
40
test/CUDADeviceCode/CUDADefineArg.C
Normal file
40
test/CUDADeviceCode/CUDADefineArg.C
Normal 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
|
Loading…
Reference in New Issue
Block a user