diff --git a/.gitmodules b/.gitmodules index 42ee841..3b339d9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "external/cudawrappers"] path = external/cudawrappers url = https://github.com/nlesc-recruit/cudawrappers + branch = main diff --git a/CMakeLists.txt b/CMakeLists.txt index a6b9e2f..7727881 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,14 @@ set(CMAKE_BUILD_TYPE Release) include(GNUInstallDirs) list(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) +set(CUDA_MIN_VERSION 10.0) +find_package(CUDAToolkit ${CUDA_MIN_VERSION} REQUIRED) + add_subdirectory(external/cudawrappers) add_executable(vector_add_example vector_add.cpp) +target_embed_source(vector_add_example vector_add_kernel.cu) target_link_libraries(vector_add_example PRIVATE cudawrappers::cu cudawrappers::nvrtc) diff --git a/vector_add.cpp b/vector_add.cpp index 045e205..b3afae3 100644 --- a/vector_add.cpp +++ b/vector_add.cpp @@ -31,8 +31,12 @@ void vector_add() { my_stream.memcpyHtoDAsync(d_b, b, bytesize); // compile kernel + extern const char _binary_vector_add_kernel_cu_start, + _binary_vector_add_kernel_cu_end; + const std::string kernel(&_binary_vector_add_kernel_cu_start, + &_binary_vector_add_kernel_cu_end); std::vector options = {}; - nvrtc::Program program("vector_add_kernel.cu"); + nvrtc::Program program(kernel, "vector_add_kernel.cu"); try { program.compile(options); } catch (nvrtc::Error &error) { @@ -40,7 +44,7 @@ void vector_add() { throw; } - cu::Module module = cu::Module((void *)program.getPTX().data()); + cu::Module module(static_cast(program.getPTX().data())); cu::Function function(module, "vector_add");