From b7a35943b26f611fa0b9304e00a700388363173b Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Thu, 2 Jul 2020 17:51:53 -0700 Subject: [PATCH 1/3] switch from CNMeM to `pool_memory_resource` --- java/pom.xml | 15 --------------- .../java/ai/rapids/cudf/NativeDepsLoader.java | 1 - java/src/main/native/CMakeLists.txt | 13 +------------ java/src/main/native/src/RmmJni.cpp | 14 +++++++------- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/java/pom.xml b/java/pom.xml index 039067b9bc7..1e90c402244 100755 --- a/java/pom.xml +++ b/java/pom.xml @@ -380,14 +380,6 @@ def proc = 'ldd ${native.build.path}/libcudfjni.so'.execute() proc.consumeProcessOutput(sout, serr) proc.waitForOrKill(10000) - def librp = ~/librmm\\.so\\s+=>\\s+(.*)librmm.*\\.so\\s+.*/ - def m = librp.matcher(sout) - if (m.find()) { - pom.properties['native.deps.path'] = m.group(1) - } else { - fail("Could not find rmm as a dependency of libcudfjni out> $sout err> $serr") - } - def libcudf = ~/libcudf\\.so\\s+=>\\s+(.*)libcudf.*\\.so\\s+.*/ def cudfm = libcudf.matcher(sout) if (cudfm.find()) { @@ -469,13 +461,6 @@ libcudf.so - - - ${native.deps.path} - - librmm.so - - diff --git a/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java b/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java index 3cd8295c507..d2319c2b58b 100755 --- a/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java +++ b/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java @@ -32,7 +32,6 @@ public class NativeDepsLoader { private static final Logger log = LoggerFactory.getLogger(NativeDepsLoader.class); private static final String[] loadOrder = new String[] { - "rmm", "cudf", "cudfjni" }; diff --git a/java/src/main/native/CMakeLists.txt b/java/src/main/native/CMakeLists.txt index 0f7374f7227..671026af213 100755 --- a/java/src/main/native/CMakeLists.txt +++ b/java/src/main/native/CMakeLists.txt @@ -149,18 +149,8 @@ find_path(RMM_INCLUDE "rmm" "$ENV{CONDA_PREFIX}/include/rmm" "$ENV{CONDA_PREFIX}/include") -find_library(RMM_LIBRARY "rmm" - HINTS "$ENV{RMM_ROOT}/lib" - "$ENV{CONDA_PREFIX}/lib") - -message(STATUS "RMM: RMM_LIBRARY set to ${RMM_LIBRARY}") message(STATUS "RMM: RMM_INCLUDE set to ${RMM_INCLUDE}") -add_library(rmm SHARED IMPORTED ${RMM_LIBRARY}) -if (RMM_INCLUDE AND RMM_LIBRARY) - set_target_properties(rmm PROPERTIES IMPORTED_LOCATION ${RMM_LIBRARY}) -endif (RMM_INCLUDE AND RMM_LIBRARY) - ################################################################################################### # - find JNI ------------------------------------------------------------------------------------- find_package(JNI REQUIRED) @@ -189,7 +179,6 @@ include_directories("${THRUST_INCLUDE}" link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc "${CMAKE_BINARY_DIR}/lib" - "${RMM_LIBRARY}" "${CUDF_LIBRARY}") @@ -230,6 +219,6 @@ endif(PER_THREAD_DEFAULT_STREAM) ################################################################################################### # - link libraries -------------------------------------------------------------------------------- -target_link_libraries(cudfjni cudf rmm ${CUDART_LIBRARY} cuda nvrtc) +target_link_libraries(cudfjni cudf ${CUDART_LIBRARY} cuda nvrtc) diff --git a/java/src/main/native/src/RmmJni.cpp b/java/src/main/native/src/RmmJni.cpp index 1c0c8b4de28..cec310dae49 100644 --- a/java/src/main/native/src/RmmJni.cpp +++ b/java/src/main/native/src/RmmJni.cpp @@ -14,20 +14,17 @@ * limitations under the License. */ -#include -#include #include #include #include #include #include -#include -#include #include #include #include #include +#include #include #include "jni_utils.hpp" @@ -365,14 +362,17 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_Rmm_initializeInternal(JNIEnv *env, j bool use_pool_alloc = allocation_mode & 1; bool use_managed_mem = allocation_mode & 2; if (use_pool_alloc) { - std::vector devices; // Just do default devices for now... if (use_managed_mem) { - auto tmp = new rmm::mr::cnmem_managed_memory_resource(pool_size, devices); + using managed_mr = rmm::mr::managed_memory_resource; + using managed_pool = rmm::mr::pool_memory_resource; + auto tmp = new managed_pool(new managed_mr(), pool_size, pool_size); Initialized_resource.reset(tmp); auto wrapped = make_tracking_adaptor(tmp, RMM_ALLOC_SIZE_ALIGNMENT); Tracking_memory_resource.reset(wrapped); } else { - auto tmp = new rmm::mr::cnmem_memory_resource(pool_size, devices); + using cuda_mr = rmm::mr::cuda_memory_resource; + using cuda_pool = rmm::mr::pool_memory_resource; + auto tmp = new cuda_pool(new cuda_mr(), pool_size, pool_size); Initialized_resource.reset(tmp); auto wrapped = make_tracking_adaptor(tmp, RMM_ALLOC_SIZE_ALIGNMENT); Tracking_memory_resource.reset(wrapped); From a1be4ce8c8b9de29940bf9f6a8d0728f6d9426ec Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Thu, 2 Jul 2020 17:54:32 -0700 Subject: [PATCH 2/3] add to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cedce0bb06c..d756d455747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ ## Improvements +- PR #5632 Switch JNI code to use `pool_memory_resource` from CNMeM - PR #5486 Link Boost libraries statically in the Java build - PR #5479 Link Arrow libraries statically - PR #5414 Use new release of Thrust/CUB in the JNI build From 19bfbd6ed213ade1ade4ccd5dbd032c715f1b97d Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Mon, 6 Jul 2020 09:34:01 -0700 Subject: [PATCH 3/3] address review feedback --- CHANGELOG.md | 2 +- java/README.md | 19 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e24f3c34e5e..6a68e1ae5ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ ## Improvements -- PR #5632 Switch JNI code to use `pool_memory_resource` from CNMeM +- PR #5632 Switch JNI code to use `pool_memory_resource` instead of CNMeM - PR #5486 Link Boost libraries statically in the Java build - PR #5479 Link Arrow libraries statically - PR #5414 Use new release of Thrust/CUB in the JNI build diff --git a/java/README.md b/java/README.md index 803d062bda2..cef43b13fe5 100644 --- a/java/README.md +++ b/java/README.md @@ -56,12 +56,12 @@ When building libcudf, make sure you pass in the cmake options `-DARROW_STATIC_LIB=ON -DBoost_USE_STATIC_LIBS=ON` so that Apache Arrow and Boost libraries are linked statically. -If you use the default cmake options libcudart will be dynamically linked to libcudf and librmm -which are included. If you do this the resulting jar will have a classifier associated with it +If you use the default cmake options libcudart will be dynamically linked to libcudf +which is included. If you do this the resulting jar will have a classifier associated with it because that jar can only be used with a single version of the CUDA runtime. There is experimental work to try and remove that requirement but it is not fully functional -you can build RMM and cuDF with `-DCUDA_STATIC_RUNTIME=ON` when running cmake, and similarly +you can build cuDF with `-DCUDA_STATIC_RUNTIME=ON` when running cmake, and similarly `-DCUDA_STATIC_RUNTIME=ON` when running maven. This will statically link in the CUDA runtime and result in a jar with no classifier that should run on any host that has a version of the driver new enough to support the runtime that this was built with. Unfortunately `libnvrtc` is still @@ -92,16 +92,7 @@ between different threads (see [blog post](https://devblogs.nvidia.com/gpu-pro-tip-cuda-7-streams-simplify-concurrency/)). Since the PTDS option is for each compilation unit, it should be done at the same time across the -whole codebase. To enable PTDS, first build RMM: -```shell script -conda activate cudf_dev -cd src/rmm/build -cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DPER_THREAD_DEFAULT_STREAM=ON -make -j`nproc` -make install -``` - -then build cuDF: +whole codebase. To enable PTDS, first build cuDF: ```shell script cd src/cudf/cpp/build cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DPER_THREAD_DEFAULT_STREAM=ON @@ -109,7 +100,7 @@ make -j`nproc` make install ``` -and finally build the jar: +then build the jar: ```shell script cd src/cudf/java mvn clean install -DPER_THREAD_DEFAULT_STREAM=ON