mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
CUDA: gencode signature that list multiple code types now supported.
Fixes #17263
This commit is contained in:
@@ -239,20 +239,32 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
|
||||
// It translates to -arch=<virtual> -code=<real>.
|
||||
cmSystemTools::ReplaceString(arch_name, "sm_", "compute_");
|
||||
}
|
||||
for (std::vector<std::string>::iterator ci = codes.begin();
|
||||
ci != codes.end(); ++ci) {
|
||||
std::string entry = arch_name + "," + *ci;
|
||||
for (auto const& c : codes) {
|
||||
std::string entry = arch_name + "," + c;
|
||||
result.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Now add entries for the -gencode=<arch>,<code> pairs.
|
||||
for (std::vector<std::string>::iterator ei = gencode.begin();
|
||||
ei != gencode.end(); ++ei) {
|
||||
std::string entry = *ei;
|
||||
// Now add entries for the following signatures:
|
||||
// -gencode=<arch>,<code>
|
||||
// -gencode=<arch>,[<code1>,<code2>]
|
||||
// -gencode=<arch>,"<code1>,<code2>"
|
||||
for (auto const& e : gencode) {
|
||||
std::string entry = e;
|
||||
cmSystemTools::ReplaceString(entry, "arch=", "");
|
||||
cmSystemTools::ReplaceString(entry, "code=", "");
|
||||
result.push_back(entry);
|
||||
cmSystemTools::ReplaceString(entry, "[", "");
|
||||
cmSystemTools::ReplaceString(entry, "]", "");
|
||||
cmSystemTools::ReplaceString(entry, "\"", "");
|
||||
|
||||
std::vector<std::string> codes = cmSystemTools::tokenize(entry, ",");
|
||||
if (codes.size() >= 2) {
|
||||
auto gencode_arch = cm::cbegin(codes);
|
||||
for (auto ci = gencode_arch + 1; ci != cm::cend(codes); ++ci) {
|
||||
std::string code_entry = *gencode_arch + "," + *ci;
|
||||
result.push_back(code_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ endif()
|
||||
# Resolve the device symbols into that static library
|
||||
# Verify that we can't use those device symbols from anything that links
|
||||
# to the static library
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
|
||||
|
@@ -9,7 +9,8 @@ project (CudaOnlySeparateCompilation CUDA)
|
||||
#and executables.
|
||||
#We complicate the matter by also testing that multiple static libraries
|
||||
#all containing cuda separable compilation code links properly
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"")
|
||||
string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
|
||||
|
Reference in New Issue
Block a user