mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-10-25 22:28:17 +08:00
Fixing jitlto regression, including missing cuDLA source files for bug #235, and updating changelogs
This commit is contained in:
@@ -87,7 +87,7 @@ message(STATUS "Using rpath: ${CMAKE_INSTALL_RPATH}")
|
||||
# On Windows, locate the nvvm.dll so we can install it.
|
||||
if (WIN32)
|
||||
find_file(NVVM_DLL nvvm64_40_0.dll PATHS "${LIBNVVM_HOME}/bin")
|
||||
if(NOT NVVM_DLL)
|
||||
if (NOT NVVM_DLL)
|
||||
message(FATAL_ERROR "Found nvvm .h/.lib, but not .dll")
|
||||
endif()
|
||||
install(FILES ${NVVM_DLL} DESTINATION bin)
|
||||
@@ -98,10 +98,18 @@ add_definitions(-DLIBDEVICE_MAJOR_VERSION=1)
|
||||
add_definitions(-DLIBDEVICE_MINOR_VERSION=0)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/common/include")
|
||||
|
||||
# Include the LLVM dev package which is required to build cuda-c-linking.
|
||||
find_package(LLVM CONFIG PATHS "$ENV{LLVM_HOME}")
|
||||
if (LLVM_FOUND)
|
||||
add_subdirectory(cuda-c-linking)
|
||||
# If you wish to build the cuda-c-linking sample and have the LLVM dependencies
|
||||
# met, then set the ENABLE_CUDA_C_LINKING_SAMPLE variable. This variable can be
|
||||
# set locally or by adding "-DENABLE_CUDA_C_LINKING_SAMPLE=1" to your cmake
|
||||
# invocation. See the note about "cuda-c-linking" in README.md.
|
||||
if (ENABLE_CUDA_C_LINKING_SAMPLE)
|
||||
# Include the LLVM dev package which is required to build cuda-c-linking.
|
||||
find_package(LLVM CONFIG PATHS "$ENV{LLVM_HOME}")
|
||||
if (LLVM_FOUND)
|
||||
add_subdirectory(cuda-c-linking)
|
||||
else ()
|
||||
message(STATUS "Skipping the build of the cuda-c-linking sample: Failed to locate the LLVM package.")
|
||||
endif ()
|
||||
else ()
|
||||
message(STATUS "Skipping the build of the cuda-c-linking sample.")
|
||||
endif ()
|
||||
|
||||
@@ -44,7 +44,7 @@ identify all of these paths.
|
||||
locally. This is only required for building the cuda-c-linking
|
||||
sample (see the cuda-c-linking note below).
|
||||
|
||||
After setting the environment variables and adding the path to the cmake tool
|
||||
After setting the environment variables and adding the path to the CMake tool
|
||||
via the PATH environment variable, sample script utils/build.sh (for Linux) or
|
||||
utils/build.bat (for Windows) may be executed. This script will use build
|
||||
directory "build" to build the samples, and then install them in the "install"
|
||||
@@ -70,6 +70,11 @@ cuda-c-linking sample and have a locally built copy of LLVM that they wish to
|
||||
use. That sample requires the development package of LLVM with the LLVM header
|
||||
files and libraries.
|
||||
|
||||
If the LLVM dependencies are met, the user can enable the building of this
|
||||
sample by setting the CMake variable "ENABLE_CUDA_C_LINKING_SAMPLE" from either
|
||||
the command line invocation of CMake or by modifying the CMakeLists.txt in this
|
||||
directory.
|
||||
|
||||
Windows users should download LLVM 14 sources from llvm.org and build+install
|
||||
LLVM locally. Using the llvm.org provided Windows installer lacks some of
|
||||
the required components the cuda-c-linking sample depends on.
|
||||
@@ -78,8 +83,8 @@ For Ubuntu users, the "llvm-dev" package contains the LLVM headers and libraries
|
||||
this sample requires, the user should not have to explicitly define an LLVM_HOME
|
||||
in this case.
|
||||
|
||||
Windows users will want to build this sample using the same cmake build mode
|
||||
Windows users will want to build this sample using the same CMake build mode
|
||||
as they built LLVM with. For instance if they built LLVM in Release mode,
|
||||
then this sample should also be built in Release mode. The utils/build.bat can
|
||||
be updated to reflect this: Add "-DCMAKE_BUILD_TYPE=Release" to the cmake
|
||||
be updated to reflect this: Add "-DCMAKE_BUILD_TYPE=Release" to the CMake
|
||||
invocation.
|
||||
|
||||
@@ -23,8 +23,9 @@ Files
|
||||
Building
|
||||
--------
|
||||
|
||||
This sample is built as part of the libnvvm samples tree. Please see the
|
||||
README file at the root of the libnvvm samples tree for build instructions.
|
||||
This sample is optionally built as part of the libnvvm samples from the CUDA
|
||||
samples tree. Please see the README file at the root of the libnvvm samples
|
||||
for build instructions.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
@@ -40,7 +40,7 @@ retrieve a device pointer first, which can be done using cuModuleGetGlobal().
|
||||
size_t size_xxx; // size of xxx
|
||||
result = cuModuleGetGlobal(&devp_xxx, &size_xxx, hModule, "xxx");
|
||||
|
||||
Whether of not the pointer points to a managed memory may be queried
|
||||
Whether or not the pointer points to managed memory may be queried
|
||||
by calling cuPointerGetAttribute() with the pointer attribute
|
||||
CU_POINTER_ATTRIBUTE_IS_MANAGED.
|
||||
|
||||
|
||||
@@ -34,6 +34,12 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define ERROR_IF(expr) \
|
||||
if (expr) { \
|
||||
fprintf(stderr, "Failed check at %s:%d\n", __FILE__, __LINE__); \
|
||||
exit(EXIT_FAILURE); \
|
||||
}
|
||||
|
||||
// If 'err' is non-zero, emit an error message and exit.
|
||||
#define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__)
|
||||
static void __checkCudaErrors(CUresult err, const char *filename, int line) {
|
||||
@@ -221,7 +227,7 @@ static CUresult buildKernel(CUcontext *phContext, CUdevice *phDevice,
|
||||
return CUDA_SUCCESS;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(void) {
|
||||
const unsigned int nThreads = 1;
|
||||
const unsigned int nBlocks = 1;
|
||||
|
||||
@@ -245,7 +251,7 @@ int main(int argc, char **argv) {
|
||||
int attrVal;
|
||||
checkCudaErrors(cuDeviceGetAttribute(
|
||||
&attrVal, CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, hDevice));
|
||||
assert(attrVal == 1);
|
||||
ERROR_IF(attrVal != 1);
|
||||
}
|
||||
|
||||
// Get the address of the variable xxx, yyy in the managed memory.
|
||||
@@ -260,23 +266,10 @@ int main(int argc, char **argv) {
|
||||
|
||||
checkCudaErrors(cuPointerGetAttribute(
|
||||
&attrVal, CU_POINTER_ATTRIBUTE_IS_MANAGED, devp_xxx));
|
||||
assert(attrVal == 1);
|
||||
ERROR_IF(attrVal != 1);
|
||||
checkCudaErrors(cuPointerGetAttribute(
|
||||
&attrVal, CU_POINTER_ATTRIBUTE_IS_MANAGED, devp_yyy));
|
||||
assert(attrVal == 1);
|
||||
}
|
||||
|
||||
// The "physical" memory location of the memory that the devp_yyy addresses is
|
||||
// the device memory type.
|
||||
{
|
||||
unsigned int attrVal;
|
||||
|
||||
checkCudaErrors(cuPointerGetAttribute(
|
||||
&attrVal, CU_POINTER_ATTRIBUTE_MEMORY_TYPE, devp_xxx));
|
||||
assert(attrVal == CU_MEMORYTYPE_DEVICE);
|
||||
checkCudaErrors(cuPointerGetAttribute(
|
||||
&attrVal, CU_POINTER_ATTRIBUTE_MEMORY_TYPE, devp_yyy));
|
||||
assert(attrVal == CU_MEMORYTYPE_DEVICE);
|
||||
ERROR_IF(attrVal != 1);
|
||||
}
|
||||
|
||||
// Since CUdeviceptr is opaque, it is safe to use cuPointerGetAttribute to get
|
||||
@@ -296,8 +289,8 @@ int main(int argc, char **argv) {
|
||||
printf("The initial value of xxx initialized by the device = %d\n", *p_xxx);
|
||||
printf("The initial value of yyy initialized by the device = %d\n", *p_yyy);
|
||||
|
||||
assert(*p_xxx == 10);
|
||||
assert(*p_yyy == 100);
|
||||
ERROR_IF(*p_xxx != 10);
|
||||
ERROR_IF(*p_yyy != 100);
|
||||
|
||||
// The host adds 1 and 11 to xxx and yyy.
|
||||
*p_xxx += 1;
|
||||
|
||||
Reference in New Issue
Block a user