Merge branch 'dev/mattd/r13-nvvm-update-master' into 'master'

Update compute capability checks to test for >=sm75.

See merge request cuda-samples/cuda-samples!126
This commit is contained in:
Rob Armstrong 2025-07-28 10:17:45 -07:00
commit 2ab16e6d15
7 changed files with 20 additions and 18 deletions

View File

@ -4,7 +4,9 @@ libNVVM and NVVM IR Samples
Introduction Introduction
------------ ------------
The following samples illustrate the use of libNVVM and NVVM IR. The following samples illustrate the use of libNVVM and NVVM IR. Running and
testing these samples requires an NVIDIA driver compatible with the CUDA
Toolkit being used for compilation.
- cuda-shared-memory - A directory containing NVVM IR programs that demonstrate - cuda-shared-memory - A directory containing NVVM IR programs that demonstrate
CUDA 'shared' memory usage. CUDA 'shared' memory usage.
@ -71,7 +73,7 @@ A Note About the cuda-c-linking Sample
This sample requires a development package (or locally-built) LLVM library This sample requires a development package (or locally-built) LLVM library
between versions 7 to 14 inclusive. LLVM 15 defaults to using opaque pointers, between versions 7 to 14 inclusive. LLVM 15 defaults to using opaque pointers,
which are currently not supported in libNVVM. which are not supported in libNVVM for pre-Blackwell architectures.
The LLVM_HOME environment variable is required for users who wish to build the The LLVM_HOME environment variable is required for users who wish to build the
cuda-c-linking sample and have a locally built copy of LLVM that they wish to cuda-c-linking sample and have a locally built copy of LLVM that they wish to

View File

@ -1,4 +1,4 @@
# Copyright (c) 1993-2023, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 1993-2025, NVIDIA CORPORATION. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@ -29,7 +29,7 @@ if (LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL "15" OR
LLVM_PACKAGE_VERSION VERSION_LESS "7") LLVM_PACKAGE_VERSION VERSION_LESS "7")
message(STATUS "The cuda-c-linking sample is expected to build with " message(STATUS "The cuda-c-linking sample is expected to build with "
"LLVM development libraries v7 to v14, opaque pointers are " "LLVM development libraries v7 to v14, opaque pointers are "
"not yet supported in libNVVM.") "not supported in libNVVM for pre-Blackwell architectures.")
return() return()
endif () endif ()

View File

@ -1,4 +1,4 @@
// Copyright (c) 1993-2023, NVIDIA CORPORATION. All rights reserved. // Copyright (c) 1993-2025, NVIDIA CORPORATION. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions // modification, are permitted provided that the following conditions
@ -216,8 +216,8 @@ int main(int argc, char **argv)
checkCudaErrors(cuDeviceGetAttribute(&devMajor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device)); checkCudaErrors(cuDeviceGetAttribute(&devMajor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
checkCudaErrors(cuDeviceGetAttribute(&devMinor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device)); checkCudaErrors(cuDeviceGetAttribute(&devMinor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
outs() << "Device Compute Capability: " << devMajor << "." << devMinor << "\n"; outs() << "Device Compute Capability: " << devMajor << "." << devMinor << "\n";
if (devMajor < 5) { if (devMajor < 7 && devMinor < 5) {
errs() << "ERROR: Device 0 is not sm_50 or later.\n"; errs() << "ERROR: Device 0 is not sm_75 or later.\n";
return 1; return 1;
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved. // Copyright (c) 2014-2025, NVIDIA CORPORATION. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions // modification, are permitted provided that the following conditions
@ -181,8 +181,8 @@ static CUdevice cudaDeviceInit(int *major, int *minor)
checkCudaErrors(cuDeviceGetAttribute(major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice)); checkCudaErrors(cuDeviceGetAttribute(major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice));
checkCudaErrors(cuDeviceGetAttribute(minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice)); checkCudaErrors(cuDeviceGetAttribute(minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice));
printf("compute capability = %d.%d\n", *major, *minor); printf("compute capability = %d.%d\n", *major, *minor);
if (*major < 5) { if (*major < 7 && *minor < 5) {
fprintf(stderr, "Device 0 is not sm_50 or later\n"); fprintf(stderr, "Device 0 is not sm_75 or later\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return cuDevice; return cuDevice;

View File

@ -22,6 +22,6 @@ interleaved.
For example, For example,
$ ptxgen a.ll -arch=compute_50 b.bc $ ptxgen a.ll -arch=compute_75 b.bc
links a.ll and b.bc, and generates PTX code for the compute_50 architecture. links a.ll and b.bc, and generates PTX code for the compute_75 architecture.

View File

@ -1,4 +1,4 @@
// Copyright (c) 1993-2023, NVIDIA CORPORATION. All rights reserved. // Copyright (c) 1993-2025, NVIDIA CORPORATION. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions // modification, are permitted provided that the following conditions
@ -74,8 +74,8 @@ static CUdevice cudaDeviceInit(int *devMajor, int *devMinor)
// Obtain the device's compute capability. // Obtain the device's compute capability.
checkCudaErrors(cuDeviceGetAttribute(devMajor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice)); checkCudaErrors(cuDeviceGetAttribute(devMajor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice));
if (*devMajor < 5) { if (*devMajor < 7 && *devMinor < 5) {
fprintf(stderr, "Device 0 is not sm_50 or later\n"); fprintf(stderr, "Device 0 is not sm_75 or later\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
checkCudaErrors(cuDeviceGetAttribute(devMinor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice)); checkCudaErrors(cuDeviceGetAttribute(devMinor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice));

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved. // Copyright (c) 2014-2025, NVIDIA CORPORATION. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions // modification, are permitted provided that the following conditions
@ -172,8 +172,8 @@ static CUdevice cudaDeviceInit(int *major, int *minor)
checkCudaErrors(cuDeviceGetAttribute(major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice)); checkCudaErrors(cuDeviceGetAttribute(major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice));
checkCudaErrors(cuDeviceGetAttribute(minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice)); checkCudaErrors(cuDeviceGetAttribute(minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice));
printf("compute capability = %d.%d\n", *major, *minor); printf("compute capability = %d.%d\n", *major, *minor);
if (*major < 5) { if (*major < 7 && *minor < 5) {
fprintf(stderr, "Device 0 is not sm_50 or later\n"); fprintf(stderr, "Device 0 is not sm_75 or later\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }