-
Notifications
You must be signed in to change notification settings - Fork 234
Convert part of RMM to a precompiled library #1896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0bbb038
008a99b
0637f84
bfd63a5
4113e98
ee37f7c
dd26598
d22cd09
d8173db
a29a2f9
dbd6b85
dd18602
9278dbb
c2b1911
219e068
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,31 +83,40 @@ include(cmake/thirdparty/get_nvtx.cmake) | |
| # ################################################################################################## | ||
| # * library targets -------------------------------------------------------------------------------- | ||
|
|
||
| add_library(rmm INTERFACE) | ||
| add_library(rmm src/aligned.cpp src/cuda_device.cpp src/cuda_stream_pool.cpp | ||
| src/cuda_stream_view.cpp src/cuda_stream.cpp) | ||
| add_library(rmm::rmm ALIAS rmm) | ||
|
|
||
| target_include_directories( | ||
| rmm | ||
| INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
| "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>" "$<INSTALL_INTERFACE:include>") | ||
| PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
| "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>" | ||
| INTERFACE "$<INSTALL_INTERFACE:include>") | ||
|
|
||
| if(CUDA_STATIC_RUNTIME) | ||
| message(STATUS "RMM: Enabling static linking of cudart") | ||
| target_link_libraries(rmm INTERFACE CUDA::cudart_static) | ||
| target_link_libraries(rmm PUBLIC CUDA::cudart_static) | ||
| else() | ||
| target_link_libraries(rmm INTERFACE CUDA::cudart) | ||
| target_link_libraries(rmm PUBLIC CUDA::cudart) | ||
| endif() | ||
|
|
||
| target_link_libraries(rmm INTERFACE CCCL::CCCL) | ||
| target_link_libraries(rmm INTERFACE dl) | ||
| target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) | ||
| target_link_libraries(rmm INTERFACE rapids_logger::rapids_logger) | ||
| target_compile_features(rmm INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>) | ||
| target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) | ||
| target_link_libraries(rmm PUBLIC CCCL::CCCL ${CMAKE_DL_LIBS} nvtx3::nvtx3-cpp | ||
| rapids_logger::rapids_logger) | ||
|
|
||
| set_target_properties( | ||
| rmm | ||
| PROPERTIES BUILD_RPATH "\$ORIGIN" | ||
| INSTALL_RPATH "\$ORIGIN" | ||
| CXX_STANDARD 17 | ||
| CXX_STANDARD_REQUIRED ON | ||
| CXX_VISIBILITY_PRESET hidden | ||
| POSITION_INDEPENDENT_CODE ON | ||
| INTERFACE_POSITION_INDEPENDENT_CODE ON) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may be able to drop this eventually depending on how much of rmm stops being header-only. Ideally we wouldn't be proscribing this for consumers I think, @robertmaynard any thoughts?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally once RMM is a proper library we can drop |
||
| target_compile_definitions(rmm PUBLIC LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) | ||
|
|
||
| # Enable NVTX if necessary | ||
| if(RMM_NVTX) | ||
| target_compile_definitions(rmm INTERFACE RMM_NVTX) | ||
| target_compile_definitions(rmm PUBLIC RMM_NVTX) | ||
| endif() | ||
|
|
||
| # ################################################################################################## | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2020-2024, NVIDIA CORPORATION. | ||
| * Copyright (c) 2020-2025, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
|
|
@@ -22,7 +22,7 @@ | |
| #include <cstddef> | ||
| #include <cstdint> | ||
|
|
||
| namespace RMM_NAMESPACE { | ||
| namespace RMM_EXPORT rmm { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the idea to get rid of RMM_NAMESPACE altogether eventually?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, see: #1896 (comment) |
||
|
|
||
| /** | ||
| * @addtogroup utilities | ||
|
|
@@ -49,10 +49,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; | |
| * | ||
| * @return True if the input is a power of two with non-negative integer exponent, false otherwise. | ||
| */ | ||
| [[nodiscard]] constexpr bool is_pow2(std::size_t value) noexcept | ||
| { | ||
| return (value != 0U) && ((value & (value - 1)) == 0U); | ||
| } | ||
| [[nodiscard]] bool is_pow2(std::size_t value) noexcept; | ||
harrism marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * @brief Returns whether or not `alignment` is a valid memory alignment. | ||
|
|
@@ -61,10 +58,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; | |
| * | ||
| * @return True if the alignment is valid, false otherwise. | ||
| */ | ||
| [[nodiscard]] constexpr bool is_supported_alignment(std::size_t alignment) noexcept | ||
| { | ||
| return is_pow2(alignment); | ||
| } | ||
| [[nodiscard]] bool is_supported_alignment(std::size_t alignment) noexcept; | ||
|
|
||
| /** | ||
| * @brief Align up to nearest multiple of specified power of 2 | ||
|
|
@@ -74,11 +68,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; | |
| * | ||
| * @return the aligned value | ||
| */ | ||
| [[nodiscard]] constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept | ||
| { | ||
| assert(is_supported_alignment(alignment)); | ||
| return (value + (alignment - 1)) & ~(alignment - 1); | ||
| } | ||
| [[nodiscard]] std::size_t align_up(std::size_t value, std::size_t alignment) noexcept; | ||
|
|
||
| /** | ||
| * @brief Align down to the nearest multiple of specified power of 2 | ||
|
|
@@ -88,11 +78,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; | |
| * | ||
| * @return the aligned value | ||
| */ | ||
| [[nodiscard]] constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept | ||
| { | ||
| assert(is_supported_alignment(alignment)); | ||
| return value & ~(alignment - 1); | ||
| } | ||
| [[nodiscard]] std::size_t align_down(std::size_t value, std::size_t alignment) noexcept; | ||
|
|
||
| /** | ||
| * @brief Checks whether a value is aligned to a multiple of a specified power of 2 | ||
|
|
@@ -102,11 +88,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; | |
| * | ||
| * @return true if aligned | ||
| */ | ||
| [[nodiscard]] constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept | ||
| { | ||
| assert(is_supported_alignment(alignment)); | ||
| return value == align_down(value, alignment); | ||
| } | ||
| [[nodiscard]] bool is_aligned(std::size_t value, std::size_t alignment) noexcept; | ||
|
|
||
| /** | ||
| * @brief Checks whether the provided pointer is aligned to a specified @p alignment | ||
|
|
@@ -116,13 +98,9 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; | |
| * | ||
| * @return true if the pointer is aligned | ||
| */ | ||
| [[nodiscard]] inline bool is_pointer_aligned( | ||
| void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) noexcept | ||
| { | ||
| // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) | ||
| return is_aligned(reinterpret_cast<std::uintptr_t>(ptr), alignment); | ||
| } | ||
| [[nodiscard]] bool is_pointer_aligned(void* ptr, | ||
| std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) noexcept; | ||
|
|
||
| /** @} */ // end of group | ||
|
|
||
| } // namespace RMM_NAMESPACE | ||
| } // namespace RMM_EXPORT rmm | ||
Uh oh!
There was an error while loading. Please reload this page.