diff --git a/CMakeLists.txt b/CMakeLists.txt index aff47134..e981aedb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ if(STRATA_ENABLE_CUDA) # `enable_language(CUDA)` gives the .cu compile rules but NOT the imported targets, so `CUDA::cudart` has to # be brought in explicitly for the host-side tests that call cudaMalloc themselves. find_package(CUDAToolkit REQUIRED) + option(STRATA_EXPERIMENTAL_SM60 "community build for GPUs below compute capability 7.5: Pascal sm_60, Volta sm_70 (#236)" OFF) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) set(CMAKE_CUDA_ARCHITECTURES 120 CACHE STRING "CUDA architectures" FORCE) endif() @@ -79,16 +80,22 @@ if(STRATA_ENABLE_CUDA) if(_base STREQUAL "native" OR _base STREQUAL "all" OR _base STREQUAL "all-major") continue() endif() - # STRATA_EXPERIMENTAL_SM60: a Pascal (sm_60, GP100-class) build. It sits below every architecture - # these kernels were written for, so two intrinsics are replaced for it - `__dp4a` (6.1+) and - # `__nanosleep` (7.0+) - in include/strata/kernels/dp4a.hpp, which is bit-exact for the first and - # merely a shorter pause for the second. RTX 20/30/40/50 cards must use the release engine instead. + # STRATA_EXPERIMENTAL_SM60: a Pascal (sm_60, GP100-class) or Volta (sm_70, V100 / Titan V, #236) build. + # These sit below every architecture the kernels were written for, so two intrinsics are replaced below + # their arch - `__dp4a` (6.1+) and `__nanosleep` (7.0+) - in include/strata/kernels/dp4a.hpp, which is + # bit-exact for the first and merely a shorter pause for the second (sm_70 has both). Community-tested, + # not in the ready-made engine; RTX 20/30/40/50 cards must use the release engine instead. It needs a CUDA + # 12.x toolkit: CUDA 13 dropped sm_60 and sm_70 (nvcc fails CMake's compiler test with "compute_70"). if(_base LESS 75 AND NOT STRATA_EXPERIMENTAL_SM60) message(FATAL_ERROR "Strata needs an NVIDIA GPU of compute capability 7.5 or newer (RTX 20 / 30 / 40 / 50 series), but " - "CMAKE_CUDA_ARCHITECTURES is '${CMAKE_CUDA_ARCHITECTURES}'. (A Pascal build is " + "CMAKE_CUDA_ARCHITECTURES is '${CMAKE_CUDA_ARCHITECTURES}'. (A Pascal sm_60 or Volta sm_70 build is " "-DSTRATA_EXPERIMENTAL_SM60=ON; upstream does not support it.)") endif() + if(_base LESS 60) + message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES '${CMAKE_CUDA_ARCHITECTURES}': even the experimental build " + "needs compute capability 6.0 (sm_60) or newer") + endif() # #220 / #224: RTX 50 engines built with CUDA 12.8 crashed in the prompt path on Linux (13.0 and newer did not) if(_base GREATER_EQUAL 120 AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0) message(WARNING "Building for sm_${_base} (RTX 50) with CUDA ${CMAKE_CUDA_COMPILER_VERSION}: engines built with " @@ -166,6 +173,10 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP) add_library(strata_core STATIC src/core/device.cu src/core/pinned.cu src/platform/memory.cpp src/core/graph.cpp src/core/weights.cpp src/core/layout.cpp) target_include_directories(strata_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + if(STRATA_ENABLE_CUDA AND STRATA_EXPERIMENTAL_SM60) + # the runtime device check (src/core/device.cu) admits the cards this build was made for (#236) + target_compile_definitions(strata_core PRIVATE STRATA_EXPERIMENTAL_SM60=1) + endif() # The selected runtime is PUBLIC because graph.cpp is a HOST translation unit that calls cudaGraphLaunch and # cudaEventQuery: the .cu sources get cudart through the CUDA language rules, a .cpp does not, and the # linker error ("unresolved external symbol cudaGraphInstantiate") names the function rather than the cause. diff --git a/src/core/device.cu b/src/core/device.cu index c1dfbb1c..010aee0f 100644 --- a/src/core/device.cu +++ b/src/core/device.cu @@ -135,10 +135,18 @@ DeviceInfo device_info(int ordinal) { d.arch = base_arch(p.gcnArchName); if (const std::string why = arch_problem(p, ordinal); !why.empty()) throw CudaError(why, -1); #else - if (d.cc_major * 10 + d.cc_minor < 75) { + // #236: the experimental build (-DSTRATA_EXPERIMENTAL_SM60=ON: Pascal sm_60, Volta sm_70) runs on the cards it + // was built for - refusing them below 7.5 there made the flag useless; the release engine keeps 7.5 +#if defined(STRATA_EXPERIMENTAL_SM60) + constexpr int kMinCc = 60; + const char* const kNeed = "6.0 or newer (this is the experimental Pascal / Volta build)"; +#else + constexpr int kMinCc = 75; + const char* const kNeed = "7.5 or newer (RTX 20 / 30 / 40 / 50 series)"; +#endif + if (d.cc_major * 10 + d.cc_minor < kMinCc) { throw CudaError("device " + d.name + " reports compute capability " + std::to_string(d.cc_major) + - "." + std::to_string(d.cc_minor) + - "; Strata needs compute capability 7.5 or newer (RTX 20 / 30 / 40 / 50 series)", + "." + std::to_string(d.cc_minor) + "; Strata needs compute capability " + kNeed, -1); } #endif