Skip to content

Commit

Permalink
Remove rmm/nvcc dependencies (#175)
Browse files Browse the repository at this point in the history
Including [rmm](https://github.com/rapidsai/rmm)'s CMakeLists.txt (by using add_subdirectory() method with FetchContent in CMakeList.txt), though it is not used/linked to `libcucim.so`, polluted main libcucim's CMake environment variables (cuCIM was including old `rmm` version whose CMakeLists.txt was not modernized) so PTX code was always included in libcucim.so causing the issue in #170.

Since cuCIM currently doesn't use `rmm`, This patch removes rmm dependency completely and makes sure that `libcucim.so` doesn't have PTX code.

- Remove `superbuild_depend(rmm)` and add `superbuild_depend(googletest)`
- Remove CUDA language in CMakeLists.txt
- Fix compilation warnings/errors caused by switching to GCC compiler (instead of nvcc).
  • Loading branch information
gigony authored Dec 3, 2021
1 parent 28ac81f commit ab4ed64
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 159 deletions.
32 changes: 12 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set(PROJECT_VERSION_BUILD dev)

# Append local cmake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cpp/cmake/modules")
project(libcucim VERSION ${VERSION} DESCRIPTION "libcucim" LANGUAGES CXX CUDA)
project(libcucim VERSION ${VERSION} DESCRIPTION "libcucim" LANGUAGES CXX)

################################################################################
# Include utilities
Expand Down Expand Up @@ -62,19 +62,7 @@ endif ()

find_package(CUDAToolkit REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17) # Clion issue: https://youtrack.jetbrains.com/issue/CPP-19165 (fixed)
set(CMAKE_CUDA_STANDARD_REQUIRED YES)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
cucim_define_cuda_architectures(60;70;75;80;86)
# https://github.com/Kitware/CMake/blob/master/Modules/Compiler/NVIDIA-CUDA.cmake#L11
# https://gitlab.kitware.com/cmake/cmake/-/issues/19017
# For CUDA >= 10.2, we cannot use --compiler-options as '-forward-unknown-to-host-compiler' wouldbe added by default to nvcc options.
# For the reason, we add "${CMAKE_CXX_FLAGS}" instead of "--compiler-options ${CMAKE_CXX_FLAGS}" here.
# ==> We changed to use "${CMAKE_CUDA_FLAGS}" instead of "${CMAKE_CXX_FLAGS}" ${CMAKE_CXX_FLAGS} can have wrong options such as '-march=nocona'
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -use_fast_math -Xptxas=-v")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -G")
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -lineinfo")
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO} -lineinfo")

# Include CUDA headers explicitly for VSCode intelli-sense
include_directories(AFTER SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
Expand Down Expand Up @@ -113,14 +101,23 @@ option(CUCIM_SUPPORT_NVTX "Support NVTX" ON)
# whether added before or after this command is invoked, and for the ones in sub-directories added after.
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) # TODO: create two library, one with CXX11 ABI and one without it.

################################################################################
# Define basic dependencies
################################################################################
# Include pthread
# (https://cmake.org/cmake/help/v3.18/module/FindThreads.html)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)

################################################################################
# Define dependencies
################################################################################
superbuild_depend(fmt)
#superbuild_depend(boost)
superbuild_depend(abseil)
superbuild_depend(rmm) # this imports googletest internally
#superbuild_depend(googletest)
# superbuild_depend(rmm) # this imports googletest internally
superbuild_depend(googletest)
superbuild_depend(googlebenchmark)
superbuild_depend(openslide)
superbuild_depend(catch2)
Expand Down Expand Up @@ -156,13 +153,8 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/examples/cpp/CMakeLists.txt.examples.re
################################################################################
set(INSTALL_TARGETS
${CUCIM_PACKAGE_NAME}
# ${CUCIM_PACKAGE_NAME}-header-only
# rmm
fmt-header-only
# spdlog_header_only # required by rmm
cucim_benchmarks
# cufile_stub
# cucim_tests
)

install(TARGETS ${INSTALL_TARGETS}
Expand Down
11 changes: 0 additions & 11 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
################################################################################

add_executable(cucim_benchmarks main.cpp config.h)
#set_source_files_properties(main.cpp PROPERTIES LANGUAGE CUDA) # failed with CLI11 library

set_target_properties(cucim_benchmarks
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
)
target_compile_features(cucim_benchmarks PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
Expand Down Expand Up @@ -63,11 +57,6 @@ set_target_properties(cucim_primitives_benchmarks
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
)
target_compile_features(cucim_primitives_benchmarks PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
Expand Down
17 changes: 2 additions & 15 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ add_library(${CUCIM_PACKAGE_NAME}
src/io/format/image_format.cpp
src/logger/logger.cpp
src/logger/timer.cpp
src/memory/memory_manager.cu
src/memory/memory_manager.cpp
src/plugin/image_format.cpp
src/plugin/plugin_config.cpp
src/profiler/profiler.cpp
Expand All @@ -114,17 +114,12 @@ set_target_properties(${CUCIM_PACKAGE_NAME}
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)

# Note: Looks like the following line causes error on CMake 3.18.4 (it is working on 3.18.2). Keeping it for now.
set(CUCIM_REQUIRED_FEATURES cxx_std_17 cuda_std_17)
set(CUCIM_REQUIRED_FEATURES cxx_std_17)
target_compile_features(${CUCIM_PACKAGE_NAME} PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
target_compile_options(${CUCIM_PACKAGE_NAME}
Expand All @@ -150,13 +145,7 @@ target_link_libraries(${CUCIM_PACKAGE_NAME}
PUBLIC
${CMAKE_DL_LIBS}
$<BUILD_INTERFACE:deps::fmt>
# $<BUILD_INTERFACE:deps::boost>
# $<BUILD_INTERFACE:deps::rmm>
# $<BUILD_INTERFACE:deps::gds>
$<INSTALL_INTERFACE:cucim::fmt-header-only>
## $<INSTALL_INTERFACE:cucim::boost>
# $<INSTALL_INTERFACE:cucim::rmm>
## $<INSTALL_INTERFACE:cucim::gds>
PRIVATE
CUDA::cudart
deps::abseil
Expand All @@ -179,8 +168,6 @@ target_include_directories(${CUCIM_PACKAGE_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/${CUCIM_PACKAGE_NAME}/3rdparty>
# $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/gds/lib> # for GDS header
# $<BUILD_INTERFACE:${THRUST_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${CUCIM_PACKAGE_NAME}/3rdparty> # for 3rdparty libraries such as dlpack, nvtx3, and fmt
PRIVATE
Expand Down
3 changes: 3 additions & 0 deletions cpp/cmake/deps/nvtx3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ if (NOT TARGET deps::nvtx3)
# Create shared library
cucim_set_build_shared_libs(ON) # since nvtx3 is header-only library, this may not needed.

set(BUILD_TESTS OFF)
set(BUILD_BENCHMARKS OFF)

add_subdirectory(${deps-nvtx3_SOURCE_DIR}/cpp ${deps-nvtx3_BINARY_DIR} EXCLUDE_FROM_ALL)
cucim_restore_build_shared_libs()

Expand Down
1 change: 1 addition & 0 deletions cpp/include/cucim/io/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class EXPORT_VISIBLE Device
public:
explicit Device();
Device(const Device& device);
Device& operator=(const Device& device) = default;
explicit Device(const std::string& device_name);
Device(const char* device_name);
Device(DeviceType type, DeviceIndex index);
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/cucim/memory/memory_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CUCIM_API void get_pointer_attributes(PointerAttributes& attr, const void* ptr);
* @param dst_device Destination device of the memory.
* @return `true` if succeed.
*/
bool move_raster_from_host(void** target, size_t size, const cucim::io::Device& dst_device);
CUCIM_API bool move_raster_from_host(void** target, size_t size, const cucim::io::Device& dst_device);

/**
* @brief Move device memory of `size` bytes to a new memory in `out_device`.
Expand All @@ -90,7 +90,7 @@ bool move_raster_from_host(void** target, size_t size, const cucim::io::Device&
* @param dst_device Destination device of the memory.
* @return `true` if succeed.
*/
bool move_raster_from_device(void** target, size_t size, const cucim::io::Device& dst_device);
CUCIM_API bool move_raster_from_device(void** target, size_t size, const cucim::io::Device& dst_device);

} // namespace cucim::memory
#endif // CUCIM_MEMORY_MANAGER_H
19 changes: 1 addition & 18 deletions cpp/plugins/cucim.kit.cumed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/VERSION VERSION)
# Append local cmake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")

project(cumed VERSION ${VERSION} DESCRIPTION "cumed" LANGUAGES CXX CUDA)
project(cumed VERSION ${VERSION} DESCRIPTION "cumed" LANGUAGES CXX)
set(CUCIM_PLUGIN_NAME "cucim.kit.cumed")

################################################################################
Expand Down Expand Up @@ -72,19 +72,7 @@ endif()
find_package(CUDAToolkit REQUIRED)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17) # Clion issue: https://youtrack.jetbrains.com/issue/CPP-19165 (fixed)
set(CMAKE_CUDA_STANDARD_REQUIRED YES)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
cucim_define_cuda_architectures(60;70;75;80;86)
# https://github.com/Kitware/CMake/blob/master/Modules/Compiler/NVIDIA-CUDA.cmake#L11
# https://gitlab.kitware.com/cmake/cmake/-/issues/19017
# For CUDA >= 10.2, we cannot use --compiler-options as '-forward-unknown-to-host-compiler' would be added by default to nvcc options.
# For the reason, we add "${CMAKE_CXX_FLAGS}" instead of "--compiler-options ${CMAKE_CXX_FLAGS}" here.
# ==> We changed to use "${CMAKE_CUDA_FLAGS}" instead of "${CMAKE_CXX_FLAGS}" ${CMAKE_CXX_FLAGS} can have wrong options such as '-march=nocona'
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -use_fast_math -Xptxas=-v")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -G")
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -lineinfo")
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO} -lineinfo")

# Include CUDA headers explicitly for VSCode intelli-sense
include_directories(AFTER SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
Expand Down Expand Up @@ -169,11 +157,6 @@ set_target_properties(${CUCIM_PLUGIN_NAME}
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)
Expand Down
6 changes: 0 additions & 6 deletions cpp/plugins/cucim.kit.cumed/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@
# Add executable: cumed_benchmarks
################################################################################
add_executable(cumed_benchmarks main.cpp config.h)
#set_source_files_properties(main.cpp PROPERTIES LANGUAGE CUDA) # failed with CLI11 library

set_target_properties(cumed_benchmarks
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
)
target_compile_features(cumed_benchmarks PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
Expand Down
6 changes: 0 additions & 6 deletions cpp/plugins/cucim.kit.cumed/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ add_executable(cumed_tests
main.cpp
test_basic.cpp
)
set_source_files_properties(test_basic.cpp PROPERTIES LANGUAGE CUDA) # failed with CLI11 library

set_target_properties(cumed_tests
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
)
target_compile_features(cumed_tests PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
Expand Down
21 changes: 1 addition & 20 deletions cpp/plugins/cucim.kit.cuslide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/VERSION VERSION)
# Append local cmake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")

project(cuslide VERSION ${VERSION} DESCRIPTION "cuslide" LANGUAGES C CXX CUDA)
project(cuslide VERSION ${VERSION} DESCRIPTION "cuslide" LANGUAGES C CXX)
set(CUCIM_PLUGIN_NAME "cucim.kit.cuslide")

################################################################################
Expand Down Expand Up @@ -72,19 +72,7 @@ endif()
find_package(CUDAToolkit REQUIRED)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17) # Clion issue: https://youtrack.jetbrains.com/issue/CPP-19165 (fixed)
set(CMAKE_CUDA_STANDARD_REQUIRED YES)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
cucim_define_cuda_architectures(60;70;75;80;86)
# https://github.com/Kitware/CMake/blob/master/Modules/Compiler/NVIDIA-CUDA.cmake#L11
# https://gitlab.kitware.com/cmake/cmake/-/issues/19017
# For CUDA >= 10.2, we cannot use --compiler-options as '-forward-unknown-to-host-compiler' would be added by default to nvcc options.
# For the reason, we add "${CMAKE_CXX_FLAGS}" instead of "--compiler-options ${CMAKE_CXX_FLAGS}" here.
# ==> We changed to use "${CMAKE_CUDA_FLAGS}" instead of "${CMAKE_CXX_FLAGS}" ${CMAKE_CXX_FLAGS} can have wrong options such as '-march=nocona'
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -use_fast_math -Xptxas=-v")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -G")
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -lineinfo")
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO} -lineinfo")

# Include CUDA headers explicitly for VSCode intelli-sense
include_directories(AFTER SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
Expand Down Expand Up @@ -123,7 +111,6 @@ add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) # TODO: create two library, one with
################################################################################
# Define dependencies
################################################################################
#superbuild_depend(cucim)
superbuild_depend(fmt)
superbuild_depend(libjpeg-turbo) # libjpeg-turbo should be located before libtiff as libtiff depends on libjpeg-turbo
superbuild_depend(libopenjpeg)
Expand Down Expand Up @@ -211,11 +198,6 @@ set_target_properties(${CUCIM_PLUGIN_NAME}
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)
Expand All @@ -228,7 +210,6 @@ target_link_libraries(${CUCIM_PLUGIN_NAME}
PRIVATE
CUDA::cudart
deps::fmt
#cucim::rmm
cucim::cucim
deps::libtiff
deps::libjpeg-turbo
Expand Down
5 changes: 0 additions & 5 deletions cpp/plugins/cucim.kit.cuslide/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ set_target_properties(cuslide_benchmarks
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
)
target_compile_features(cuslide_benchmarks PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
Expand Down
8 changes: 1 addition & 7 deletions cpp/plugins/cucim.kit.cuslide/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@ add_executable(cuslide_tests
test_read_rawtiff.cpp
test_philips_tiff.cpp
)
set_source_files_properties(test_read_rawtiff.cpp PROPERTIES LANGUAGE CUDA) # failed with CLI11 library

set_target_properties(cuslide_tests
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED YES
CUDA_EXTENSIONS NO
CUDA_SEPARABLE_COMPILATION ON
CUDA_RUNTIME_LIBRARY Shared
)
target_compile_features(cuslide_tests PRIVATE ${CUCIM_REQUIRED_FEATURES})
# Use generator expression to avoid `nvcc fatal : Value '-std=c++17' is not defined for option 'Werror'`
Expand All @@ -52,6 +45,7 @@ target_compile_definitions(cuslide_tests
)
target_link_libraries(cuslide_tests
PRIVATE
CUDA::cudart
cucim::cucim
${CUCIM_PLUGIN_NAME}
deps::catch2
Expand Down
Loading

0 comments on commit ab4ed64

Please sign in to comment.