@@ -20,7 +20,6 @@ limitations under the License.
2020#include < functional>
2121#include < memory>
2222#include < string>
23- #include < variant>
2423#include < vector>
2524
2625#include " absl/base/call_once.h"
@@ -30,7 +29,6 @@ limitations under the License.
3029#include " absl/strings/str_cat.h"
3130#include " absl/strings/str_format.h"
3231#include " xla/tsl/platform/status_macros.h"
33- #include " third_party/gpus/cuda/include/cuda.h"
3432#include " llvm/ADT/FloatingPointMode.h"
3533#include " llvm/Analysis/CGSCCPassManager.h"
3634#include " llvm/Analysis/LazyCallGraph.h"
@@ -59,6 +57,7 @@ limitations under the License.
5957#include " llvm/Transforms/IPO/AlwaysInliner.h"
6058#include " llvm/Transforms/IPO/Internalize.h"
6159#include " llvm/Transforms/Scalar.h"
60+ #include " third_party/gpus/cuda/include/cuda.h"
6261#include " xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.h"
6362#include " xla/service/gpu/llvm_gpu_backend/load_ir_module.h"
6463#include " xla/service/gpu/llvm_gpu_backend/nvptx_libdevice_path.h"
@@ -239,7 +238,13 @@ std::vector<std::string> GetNVPTXBackendOptions(
239238 return backend_llvm_opts;
240239}
241240
242- std::string GetSmName (se::CudaComputeCapability compute_capability) {
241+ constexpr se::CudaComputeCapability kSupportedVersions [] = {
242+ {12 , 1 }, {12 , 0 }, {11 , 0 }, {10 , 3 }, {10 , 0 }, {9 , 0 }, {8 , 9 }, {8 , 7 },
243+ {8 , 6 }, {8 , 0 }, {7 , 5 }, {7 , 2 }, {7 , 0 }, {6 , 2 }, {6 , 1 }, {6 , 0 },
244+ {5 , 3 }, {5 , 2 }, {5 , 0 }, {3 , 7 }, {3 , 5 }, {3 , 2 }, {3 , 0 }};
245+
246+ se::CudaComputeCapability ResolveSupportedComputeCapability (
247+ se::CudaComputeCapability compute_capability) {
243248 using CudaComputeCapabilities =
244249 se::CudaComputeCapability::CudaComputeCapabilities;
245250
@@ -248,10 +253,6 @@ std::string GetSmName(se::CudaComputeCapability compute_capability) {
248253 se::CudaComputeCapability::FeatureExtension::kNone ;
249254 // If the current compute capability isn't known, fallback to the
250255 // most recent version before it.
251- constexpr stream_executor::CudaComputeCapability kSupportedVersions [] = {
252- {12 , 1 }, {12 , 0 }, {11 , 0 }, {10 , 3 }, {10 , 0 }, {9 , 0 }, {8 , 9 }, {8 , 7 },
253- {8 , 6 }, {8 , 0 }, {7 , 5 }, {7 , 2 }, {7 , 0 }, {6 , 2 }, {6 , 1 }, {6 , 0 },
254- {5 , 3 }, {5 , 2 }, {5 , 0 }, {3 , 7 }, {3 , 5 }, {3 , 2 }, {3 , 0 }};
255256 // Initialize to the least supported version, which acts as a safe fallback
256257 auto target_compute_capability =
257258 kSupportedVersions [std::size (kSupportedVersions ) - 1 ];
@@ -284,6 +285,13 @@ std::string GetSmName(se::CudaComputeCapability compute_capability) {
284285 se::CudaComputeCapability::FeatureExtension::kFamilyCompatibleFeatures ;
285286 }
286287
288+ return target_compute_capability;
289+ }
290+
291+ std::string GetSmName (se::CudaComputeCapability compute_capability) {
292+ se::CudaComputeCapability target_compute_capability =
293+ ResolveSupportedComputeCapability (compute_capability);
294+
287295 // If the current CC isn't supported by LLVM and it is newer then
288296 // the max supported LLVM version, do not warn about it. The end
289297 // user can't do anything about this. E.g., PTX compiled for SM75 will
0 commit comments