Skip to content
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

Provide ./build.sh flag to control CUDA async malloc support #901

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ function(ConfigureBench BENCH_NAME)
target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
endif()

if(NO_CUDA_MALLOC_ASYNC_SUPPORT)
target_compile_definitions(${TEST_NAME}
PUBLIC "NO_RMM_CUDA_MALLOC_ASYNC_SUPPORT")
endif()

target_compile_options(${BENCH_NAME} PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Wall -Werror
-Wno-error=deprecated-declarations>)
if(DISABLE_DEPRECATION_WARNING)
Expand Down
22 changes: 15 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ARGS=$*
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

VALIDARGS="clean librmm rmm -v -g -n -s --ptds -h"
HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"<args>\"] [-h]
VALIDARGS="clean librmm rmm -v -g -n -s --ptds --no-async -h"
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-async] [--cmake-args=\"<args>\"] [-h]
clean - remove all existing build artifacts and configuration (start over)
librmm - build and install the librmm C++ code
rmm - build and install the rmm Python package
Expand All @@ -28,6 +28,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"<ar
-n - no install step
-s - statically link against cudart
--ptds - enable per-thread default stream
--no-async - disable CUDA malloc async support
--cmake-args=\\\"<args>\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument)
-h - print this text

Expand All @@ -43,6 +44,7 @@ BUILD_TYPE=Release
INSTALL_TARGET=install
CUDA_STATIC_RUNTIME=OFF
PER_THREAD_DEFAULT_STREAM=OFF
NO_CUDA_MALLOC_ASYNC_SUPPORT=OFF
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
RAN_CMAKE=0

# Set defaults for vars that may not have been defined externally
Expand Down Expand Up @@ -88,6 +90,7 @@ function ensureCMakeRan {
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
-DCUDA_STATIC_RUNTIME="${CUDA_STATIC_RUNTIME}" \
-DPER_THREAD_DEFAULT_STREAM="${PER_THREAD_DEFAULT_STREAM}" \
-DNO_CUDA_MALLOC_ASYNC_SUPPORT="${NO_CUDA_MALLOC_ASYNC_SUPPORT}" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${CMAKE_ARGS}
RAN_CMAKE=1
Expand Down Expand Up @@ -128,6 +131,9 @@ fi
if hasArg --ptds; then
PER_THREAD_DEFAULT_STREAM=ON
fi
if hasArg --no-async; then
NO_CUDA_MALLOC_ASYNC_SUPPORT=ON
fi

# If clean given, run it prior to any other steps
if hasArg clean; then
Expand Down Expand Up @@ -159,14 +165,16 @@ fi
if (( NUMARGS == 0 )) || hasArg rmm; then
cd "${REPODIR}/python"
export INSTALL_PREFIX
if [[ ${INSTALL_TARGET} != "" ]]; then
echo "building rmm..."
echo "building rmm..."
if [[ ${NO_CUDA_MALLOC_ASYNC_SUPPORT} == ON ]]; then
python setup.py build_ext_no_async --inplace
else
python setup.py build_ext --inplace
fi

if [[ ${INSTALL_TARGET} != "" ]]; then
echo "installing rmm..."
python setup.py install --single-version-externally-managed --record=record.txt
else
echo "building rmm..."
python setup.py build_ext --inplace
fi

fi
2 changes: 2 additions & 0 deletions include/rmm/mr/device/cuda_async_memory_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
#include <limits>

#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync
#ifndef NO_RMM_CUDA_MALLOC_ASYNC_SUPPORT
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
#define RMM_CUDA_MALLOC_ASYNC_SUPPORT
#endif
#endif

namespace rmm::mr {

Expand Down
8 changes: 8 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,18 @@ def finalize_options(self):
# Skip calling super() and jump straight to setuptools
setuptools.command.build_ext.build_ext.finalize_options(self)

class build_ext_no_async(build_ext_no_debug):
def build_extensions(self):
# Disable async support
self.compiler.compiler_so.append("-DNO_RMM_CUDA_MALLOC_ASYNC_SUPPORT")
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
super().build_extensions()



cmdclass = dict()
cmdclass.update(versioneer.get_cmdclass())
cmdclass["build_ext"] = build_ext_no_debug
cmdclass["build_ext_no_async"] = build_ext_no_async

setup(
name="rmm",
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function(ConfigureTestInternal TEST_NAME)
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
target_compile_definitions(${TEST_NAME}
PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}")
if(NO_CUDA_MALLOC_ASYNC_SUPPORT)
target_compile_definitions(${TEST_NAME}
PUBLIC "NO_RMM_CUDA_MALLOC_ASYNC_SUPPORT")
endif()
target_compile_options(${TEST_NAME} PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Wall -Werror
-Wno-error=deprecated-declarations>)

Expand Down