Add workaround for clang PCH-bug
At the moment, to extend the AST-tree of the device code, we use PCH-files to extend the exist device code with new lines of code. In detail, if we want to create a new PTX-file, we use the CUDA code (.cu file) and a PCH-file with the existing AST as input and generate an new PCH-file, which contains the whole AST. Then, the PCH-file will compiled to a PTX-file. A bug in clang prevent, that we can’t generate more than 5 new PCH-files. The bug is not easy to fix, so I write a small workaround. Instead using a PCH-file, which contains the AST, we generate a new complete AST from all .cu-files every time. The workaround is temporary and should removed, if clang is patched.
This commit is contained in:
parent
454c359c51
commit
c18f074cbd
@ -24,6 +24,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#define PCHMODE 0
|
||||
|
||||
namespace cling {
|
||||
|
||||
IncrementalCUDADeviceCompiler::IncrementalCUDADeviceCompiler(
|
||||
@ -190,6 +192,11 @@ namespace cling {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if PCHMODE == 0
|
||||
llvm::sys::fs::remove(m_GenericFileName + std::to_string(m_Counter)
|
||||
+".cu.pch");
|
||||
#endif
|
||||
|
||||
++m_Counter;
|
||||
return true;
|
||||
}
|
||||
@ -223,12 +230,23 @@ namespace cling {
|
||||
+".cu.pch";
|
||||
argv.push_back(outputname.c_str());
|
||||
// If a previos file exist, include it.
|
||||
#if PCHMODE == 1
|
||||
std::string previousFile;
|
||||
if(m_Counter){
|
||||
previousFile = m_GenericFileName + std::to_string(m_Counter-1) +".cu.pch";
|
||||
argv.push_back("-include-pch");
|
||||
argv.push_back(previousFile.c_str());
|
||||
}
|
||||
#else
|
||||
std::vector<std::string> previousFiles;
|
||||
if(m_Counter){
|
||||
for(unsigned int i = 0; i <= m_Counter-1; ++i){
|
||||
previousFiles.push_back(m_GenericFileName + std::to_string(i) +".cu");
|
||||
argv.push_back("-include");
|
||||
argv.push_back(previousFiles[i].c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
argv.push_back(m_CuArgs.ptxSmVersion.c_str());
|
||||
argv.push_back("-pthread");
|
||||
argv.push_back("--cuda-device-only");
|
||||
|
Loading…
x
Reference in New Issue
Block a user