From 1a1f56545bb2cf4556f31e491ea75db28fc9ccf0 Mon Sep 17 00:00:00 2001 From: Bram Veenboer <bram.veenboer@gmail.com> Date: Tue, 3 Oct 2023 16:32:10 +0200 Subject: [PATCH] Use target_embed_source to embed correlator kernel --- libtcc/CMakeLists.txt | 6 ++---- libtcc/Correlator.cc | 13 ++----------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/libtcc/CMakeLists.txt b/libtcc/CMakeLists.txt index e3bf999..3c89eac 100644 --- a/libtcc/CMakeLists.txt +++ b/libtcc/CMakeLists.txt @@ -10,6 +10,7 @@ target_include_directories( $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>) # Add links target_link_libraries(tcc PRIVATE cudawrappers::cu cudawrappers::nvrtc) +target_embed_source(tcc kernel/TCCorrelator.cu) # Install libraries and headers install( TARGETS tcc @@ -20,7 +21,4 @@ install( install( EXPORT tcc-config NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) -# Embed CUDA code -include(${CMAKE_SOURCE_DIR}/cmake/Utils.cmake) -include_cuda_code(tcc kernel/TCCorrelator.cu) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) \ No newline at end of file diff --git a/libtcc/Correlator.cc b/libtcc/Correlator.cc index 09e5452..53c0680 100644 --- a/libtcc/Correlator.cc +++ b/libtcc/Correlator.cc @@ -7,7 +7,7 @@ #include <link.h> -extern const char _binary_libtcc_TCCorrelator_cu_start, _binary_libtcc_TCCorrelator_cu_end; +extern const char _binary_kernel_TCCorrelator_cu_start, _binary_kernel_TCCorrelator_cu_end; namespace tcc { @@ -78,17 +78,8 @@ cu::Module Correlator::compileModule(unsigned nrBits, //std::for_each(options.begin(), options.end(), [] (const std::string &e) { std::cout << e << ' '; }); std::cout << std::endl; -#if 0 - nvrtc::Program program("tcc/TCCorrelator.cu"); -#else - // embed the CUDA source code in libtcc.so, so that it need not be installed separately - // for runtime compilation - // copy into std::string for '\0' termination - const std::string source = -#include "TCCorrelator.cu" - ; + const std::string source(_binary_kernel_TCCorrelator_cu_start, _binary_kernel_TCCorrelator_cu_end); nvrtc::Program program(source, "TCCorrelator.cu"); -#endif try { program.compile(options); -- GitLab