From 2f772dc7b9e0e56328e58584b98bd217ffabb1dc Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Tue, 27 Oct 2020 15:28:17 -0400 Subject: [PATCH 01/51] initial work on scikit-build --- .gitignore | 3 + ci/release/update-version.sh | 1 + cmake/cmake | 1 + python/CMakeLists.txt | 42 +++++++ python/cmake | 1 + python/pyproject.toml | 18 ++- python/rmm/_cuda/CMakeLists.txt | 43 +++++++ python/rmm/_lib/CMakeLists.txt | 30 +++++ python/rmm/tests/CMakeLists.txt | 28 +++++ python/setup.py | 196 ++------------------------------ 10 files changed, 172 insertions(+), 191 deletions(-) create mode 120000 cmake/cmake create mode 100644 python/CMakeLists.txt create mode 120000 python/cmake create mode 100644 python/rmm/_cuda/CMakeLists.txt create mode 100644 python/rmm/_lib/CMakeLists.txt create mode 100644 python/rmm/tests/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 0e2619266..2c603209d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,9 @@ pip-delete-this-directory.txt # Ignore dynamically generated .pxd files python/rmm/_cuda/gpu.pxd +# Ignore _skbuild directory +_skbuild/ + # Unit test / coverage reports htmlcov/ .tox/ diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 6b7342961..9d40b2712 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -30,6 +30,7 @@ function sed_runner() { } sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt + sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile diff --git a/cmake/cmake b/cmake/cmake new file mode 120000 index 000000000..b6868d450 --- /dev/null +++ b/cmake/cmake @@ -0,0 +1 @@ +cmake \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 000000000..7daf0ac98 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,42 @@ +#============================================================================= +# Copyright (c) 2020, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +cmake_minimum_required(VERSION 3.18...3.18) + +set(rmm_version 0.17.0) + +project(rmm-python VERSION ${rmm_version} LANGUAGES CXX CUDA) + +find_package(Cython REQUIRED) +find_package(Python3 REQUIRED COMPONENTS Development) +find_package(CUDAToolkit REQUIRED) + +# include(cmake/CPM.cmake) +# TODO (kk): CPMFindPackage spdlog +# TODO (kk): CPMFindPackage Thrust + +# Try to find an installed RMM, if not found add the parent directory +# TODO (kk): Do some basic validation to ensure the parent is as expected +find_package(RMM ${rmm_version}) +if(NOT RMM_FOUND) + set(BUILD_TESTS OFF) + set(BUILD_BENCHMARKS OFF) + add_subdirectory(../ rmm-cpp) +endif(NOT RMM_FOUND) + +add_subdirectory(rmm/_cuda) +add_subdirectory(rmm/_lib) +add_subdirectory(rmm/tests) diff --git a/python/cmake b/python/cmake new file mode 120000 index 000000000..1a8cebff2 --- /dev/null +++ b/python/cmake @@ -0,0 +1 @@ +../cmake \ No newline at end of file diff --git a/python/pyproject.toml b/python/pyproject.toml index f10a40c81..7d97146fd 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,11 +1,25 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. [build-system] requires = [ "wheel", "setuptools", - "Cython>=0.29,<0.30", + "scikit-build", + "cmake", + "ninja", ] [tool.black] diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt new file mode 100644 index 000000000..862f4f539 --- /dev/null +++ b/python/rmm/_cuda/CMakeLists.txt @@ -0,0 +1,43 @@ +#============================================================================= +# Copyright (c) 2020, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +# Preprocessor step to specify correct pxd file with valid symbols for specific version of CUDA. +set(preprocess_files "gpu.pxd;") +set(supported_cuda_versions "10.1;10.2;11.0") +foreach(file_p ${preprocess_files}) + get_filename_component(pxi_file ${file_p} NAME_WLE) + set(pxi_file "${pxi_file}.pxi") + set(cuda_major_minor "${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}") + if(cuda_major_minor IN_LIST supported_cuda_versions) + file(COPY "${cuda_major_minor}/${pxi_file}" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") + file(RENAME "${pxi_file}" "gpu.pxd") + else() + MESSAGE(FATAL_ERROR "CUDA ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR} is not supported.") + endif(cuda_major_minor IN_LIST supported_cuda_versions) +endforeach(file_p ${preprocess_files}) + +# Set the list of Cython files to build +list(APPEND cython_sources "gpu.pyx") + +# Build all of the Cython targets +foreach(cython_file ${cython_sources}) + get_filename_component(cython_module_name ${cython_file} NAME_WLE) + add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) + add_library(${cython_module_name} MODULE ${cython_module_name}) + target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) + target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + install(TARGETS ${cython_module_name} LIBRARY DESTINATION ${cython_module_name}) +endforeach(cython_file ${cython_sources}) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt new file mode 100644 index 000000000..c864fb77d --- /dev/null +++ b/python/rmm/_lib/CMakeLists.txt @@ -0,0 +1,30 @@ +#============================================================================= +# Copyright (c) 2020, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +# Set the list of Cython files to build +list(APPEND cython_sources "device_buffer.pyx") +list(APPEND cython_sources "lib.pyx") +list(APPEND cython_sources "memory_resource.pyx") + +# Build all of the Cython targets +foreach(cython_file ${cython_sources}) + get_filename_component(cython_module_name ${cython_file} NAME_WLE) + add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) + add_library(${cython_module_name} MODULE ${cython_module_name}) + target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) + target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + install(TARGETS ${cython_module_name} LIBRARY DESTINATION ${cython_module_name}) +endforeach(cython_file ${cython_sources}) diff --git a/python/rmm/tests/CMakeLists.txt b/python/rmm/tests/CMakeLists.txt new file mode 100644 index 000000000..1ba954ebd --- /dev/null +++ b/python/rmm/tests/CMakeLists.txt @@ -0,0 +1,28 @@ +#============================================================================= +# Copyright (c) 2020, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +# Set the list of Cython files to build +list(APPEND cython_sources "test_device_buffer.pyx") + +# Build all of the Cython targets +foreach(cython_file ${cython_sources}) + get_filename_component(cython_module_name ${cython_file} NAME_WLE) + add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) + add_library(${cython_module_name} MODULE ${cython_module_name}) + target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) + target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + install(TARGETS ${cython_module_name} LIBRARY DESTINATION ${cython_module_name}) +endforeach(cython_file ${cython_sources}) diff --git a/python/setup.py b/python/setup.py index 50888ab3c..bac70d95e 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,192 +1,12 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. -import glob -import os -import re -import shutil -import sysconfig - -# Must import in this order: -# setuptools -> Cython.Distutils.build_ext -> setuptools.command.build_ext -# Otherwise, setuptools.command.build_ext ends up inheriting from -# Cython.Distutils.old_build_ext which we do not want -import setuptools - -try: - from Cython.Distutils.build_ext import new_build_ext as _build_ext -except ImportError: - from setuptools.command.build_ext import build_ext as _build_ext - -from distutils.sysconfig import get_python_lib - -import setuptools.command.build_ext -from setuptools import find_packages, setup -from setuptools.extension import Extension +from setuptools import find_packages +from skbuild import setup import versioneer -install_requires = ["numba", "cython", "cuda-python"] - - -def get_cuda_version_from_header(cuda_include_dir): - - cuda_version = None - - with open( - os.path.join(cuda_include_dir, "cuda.h"), "r", encoding="utf-8" - ) as f: - for line in f.readlines(): - if re.search(r"#define CUDA_VERSION ", line) is not None: - cuda_version = line - break - - if cuda_version is None: - raise TypeError("CUDA_VERSION not found in cuda.h") - cuda_version = int(cuda_version.split()[2]) - return "%d.%d" % (cuda_version // 1000, (cuda_version % 1000) // 10) - - -cython_tests = glob.glob("rmm/_lib/tests/*.pyx") - -CUDA_HOME = os.environ.get("CUDA_HOME", False) -if not CUDA_HOME: - path_to_cuda_gdb = shutil.which("cuda-gdb") - if path_to_cuda_gdb is None: - raise OSError( - "Could not locate CUDA. " - "Please set the environment variable " - "CUDA_HOME to the path to the CUDA installation " - "and try again." - ) - CUDA_HOME = os.path.dirname(os.path.dirname(path_to_cuda_gdb)) - -if not os.path.isdir(CUDA_HOME): - raise OSError(f"Invalid CUDA_HOME: directory does not exist: {CUDA_HOME}") - -cuda_include_dir = os.path.join(CUDA_HOME, "include") -cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") -CUDA_VERSION = get_cuda_version_from_header(cuda_include_dir) - -INSTALL_PREFIX = os.environ.get("INSTALL_PREFIX", False) -if os.path.isdir(INSTALL_PREFIX): - rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") -else: - # use uninstalled headers in source tree - rmm_include_dir = "../include" - -include_dirs = [ - rmm_include_dir, - os.path.dirname(sysconfig.get_path("include")), - cuda_include_dir, -] - -library_dirs = [ - get_python_lib(), - os.path.join(os.sys.prefix, "lib"), - cuda_lib_dir, -] - -extensions = [ - # lib: - Extension( - "*", - sources=["rmm/_lib/*.pyx"], - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[ - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib"), - ], - libraries=["cuda", "cudart"], - language="c++", - extra_compile_args=["-std=c++17"], - ), - # cuda: - Extension( - "*", - sources=["rmm/_cuda/*.pyx"], - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[ - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib"), - ], - libraries=["cuda", "cudart"], - language="c++", - extra_compile_args=["-std=c++17"], - ), - # tests: - Extension( - "*", - sources=cython_tests, - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[ - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib"), - ], - libraries=["cuda", "cudart"], - language="c++", - extra_compile_args=["-std=c++17"], - ), -] - - -def remove_flags(compiler, *flags): - for flag in flags: - try: - compiler.compiler_so = list( - filter((flag).__ne__, compiler.compiler_so) - ) - except Exception: - pass - - -class build_ext_no_debug(_build_ext): - def build_extensions(self): - # Full optimization - self.compiler.compiler_so.append("-O3") - # No debug symbols, full optimization, no '-Wstrict-prototypes' warning - remove_flags( - self.compiler, "-g", "-G", "-O1", "-O2", "-Wstrict-prototypes" - ) - super().build_extensions() - - def finalize_options(self): - if self.distribution.ext_modules: - # Delay import this to allow for Cython-less installs - from Cython.Build.Dependencies import cythonize - - nthreads = getattr(self, "parallel", None) # -j option in Py3.5+ - nthreads = int(nthreads) if nthreads else None - self.distribution.ext_modules = cythonize( - self.distribution.ext_modules, - nthreads=nthreads, - force=self.force, - gdb_debug=False, - compiler_directives=dict( - profile=False, - language_level=3, - embedsignature=True, - binding=True, - ), - ) - # 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("-DRMM_DISABLE_CUDA_MALLOC_ASYNC") - 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 - +# TODO: Need to find a way to enable builds without debug or async like we had +# before with a custom cmdclass. setup( name="rmm", version=versioneer.get_version(), @@ -204,15 +24,13 @@ def build_extensions(self): "Programming Language :: Python :: 3.8", ], # Include the separately-compiled shared library - setup_requires=["Cython>=0.29,<0.30"], extras_require={"test": ["pytest", "pytest-xdist"]}, - ext_modules=extensions, packages=find_packages(include=["rmm", "rmm.*"]), package_data=dict.fromkeys( find_packages(include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"]), ["*.hpp", "*.pxd"], ), - cmdclass=cmdclass, - install_requires=install_requires, + cmdclass=versioneer.get_cmdclass(), + install_requires=["numba", "cython", "cuda-python"], zip_safe=False, ) From 63bdfc706dfc83de3092c6558406cb69b17ed2d4 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Mon, 30 Nov 2020 17:16:21 -0500 Subject: [PATCH 02/51] Fix install paths in cmake --- python/rmm/_cuda/CMakeLists.txt | 31 ++++++++++++++++--------------- python/rmm/_lib/CMakeLists.txt | 24 ++++++++++++------------ python/rmm/tests/CMakeLists.txt | 23 +++++++++++------------ 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 862f4f539..e4886d8d6 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -1,20 +1,18 @@ -#============================================================================= +# ============================================================================= # Copyright (c) 2020, NVIDIA CORPORATION. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#============================================================================= +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= -# Preprocessor step to specify correct pxd file with valid symbols for specific version of CUDA. +# Preprocessor step to specify correct pxd file with valid symbols for specific version of CUDA. set(preprocess_files "gpu.pxd;") set(supported_cuda_versions "10.1;10.2;11.0") foreach(file_p ${preprocess_files}) @@ -25,7 +23,9 @@ foreach(file_p ${preprocess_files}) file(COPY "${cuda_major_minor}/${pxi_file}" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") file(RENAME "${pxi_file}" "gpu.pxd") else() - MESSAGE(FATAL_ERROR "CUDA ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR} is not supported.") + MESSAGE( + FATAL_ERROR "CUDA ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR} is not supported." + ) endif(cuda_major_minor IN_LIST supported_cuda_versions) endforeach(file_p ${preprocess_files}) @@ -37,7 +37,8 @@ foreach(cython_file ${cython_sources}) get_filename_component(cython_module_name ${cython_file} NAME_WLE) add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) add_library(${cython_module_name} MODULE ${cython_module_name}) - target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) + set_target_properties(${cython_module_name} PROPERTIES PREFIX "") + target_link_libraries(${cython_module_name} rmm::rmm Python3::Module CUDA::cuda_driver) target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module_name} LIBRARY DESTINATION ${cython_module_name}) + install(TARGETS ${cython_module_name} LIBRARY DESTINATION rmm/_cuda) endforeach(cython_file ${cython_sources}) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index c864fb77d..12c214377 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -1,30 +1,30 @@ -#============================================================================= +# ============================================================================= # Copyright (c) 2020, NVIDIA CORPORATION. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#============================================================================= +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= # Set the list of Cython files to build list(APPEND cython_sources "device_buffer.pyx") list(APPEND cython_sources "lib.pyx") list(APPEND cython_sources "memory_resource.pyx") +list(APPEND cython_sources "cuda_stream_view.pyx") # Build all of the Cython targets foreach(cython_file ${cython_sources}) get_filename_component(cython_module_name ${cython_file} NAME_WLE) add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) add_library(${cython_module_name} MODULE ${cython_module_name}) + set_target_properties(${cython_module_name} PROPERTIES PREFIX "") target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module_name} LIBRARY DESTINATION ${cython_module_name}) + install(TARGETS ${cython_module_name} LIBRARY DESTINATION rmm/_lib) endforeach(cython_file ${cython_sources}) diff --git a/python/rmm/tests/CMakeLists.txt b/python/rmm/tests/CMakeLists.txt index 1ba954ebd..d83fa2f05 100644 --- a/python/rmm/tests/CMakeLists.txt +++ b/python/rmm/tests/CMakeLists.txt @@ -1,18 +1,16 @@ -#============================================================================= +# ============================================================================= # Copyright (c) 2020, NVIDIA CORPORATION. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#============================================================================= +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= # Set the list of Cython files to build list(APPEND cython_sources "test_device_buffer.pyx") @@ -22,7 +20,8 @@ foreach(cython_file ${cython_sources}) get_filename_component(cython_module_name ${cython_file} NAME_WLE) add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) add_library(${cython_module_name} MODULE ${cython_module_name}) + set_target_properties(${cython_module_name} PROPERTIES PREFIX "") target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module_name} LIBRARY DESTINATION ${cython_module_name}) + install(TARGETS ${cython_module_name} LIBRARY DESTINATION rmm/tests) endforeach(cython_file ${cython_sources}) From 66d070b405a5fb457943fe896f02a3041e44b16b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Feb 2022 15:26:24 -0800 Subject: [PATCH 03/51] Minimal changes to get rmm to compile. --- ci/release/update-version.sh | 1 - python/CMakeLists.txt | 13 ++++++++----- python/pyproject.toml | 1 + python/rmm/_cuda/CMakeLists.txt | 21 ++------------------- python/rmm/_lib/CMakeLists.txt | 2 +- python/rmm/tests/CMakeLists.txt | 27 --------------------------- 6 files changed, 12 insertions(+), 53 deletions(-) delete mode 100644 python/rmm/tests/CMakeLists.txt diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 9d40b2712..6b7342961 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -30,7 +30,6 @@ function sed_runner() { } sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt - sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 7daf0ac98..aa8a35151 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,20 +14,24 @@ # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.18...3.18) +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -set(rmm_version 0.17.0) +# TODO: Pull this directly from the file written by rapids_cmake_write_version_file. +set(rmm_version 22.04.00) +# TODO: What name do we want to use here? project(rmm-python VERSION ${rmm_version} LANGUAGES CXX CUDA) -find_package(Cython REQUIRED) +find_package(PythonExtensions REQUIRED) find_package(Python3 REQUIRED COMPONENTS Development) +find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) # include(cmake/CPM.cmake) # TODO (kk): CPMFindPackage spdlog # TODO (kk): CPMFindPackage Thrust +# TODO: Is this the expected behavior? To use existing installs if found, otherwise the headers from the source directory? # Try to find an installed RMM, if not found add the parent directory # TODO (kk): Do some basic validation to ensure the parent is as expected find_package(RMM ${rmm_version}) @@ -39,4 +43,3 @@ endif(NOT RMM_FOUND) add_subdirectory(rmm/_cuda) add_subdirectory(rmm/_lib) -add_subdirectory(rmm/tests) diff --git a/python/pyproject.toml b/python/pyproject.toml index 7d97146fd..b5e0b800c 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -17,6 +17,7 @@ requires = [ "wheel", "setuptools", + "cython>=0.29,<0.30", "scikit-build", "cmake", "ninja", diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index e4886d8d6..1764e4fe6 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at @@ -12,25 +12,8 @@ # the License. # ============================================================================= -# Preprocessor step to specify correct pxd file with valid symbols for specific version of CUDA. -set(preprocess_files "gpu.pxd;") -set(supported_cuda_versions "10.1;10.2;11.0") -foreach(file_p ${preprocess_files}) - get_filename_component(pxi_file ${file_p} NAME_WLE) - set(pxi_file "${pxi_file}.pxi") - set(cuda_major_minor "${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}") - if(cuda_major_minor IN_LIST supported_cuda_versions) - file(COPY "${cuda_major_minor}/${pxi_file}" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}") - file(RENAME "${pxi_file}" "gpu.pxd") - else() - MESSAGE( - FATAL_ERROR "CUDA ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR} is not supported." - ) - endif(cuda_major_minor IN_LIST supported_cuda_versions) -endforeach(file_p ${preprocess_files}) - # Set the list of Cython files to build -list(APPEND cython_sources "gpu.pyx") +list(APPEND cython_sources "stream.pyx") # Build all of the Cython targets foreach(cython_file ${cython_sources}) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 12c214377..ccb4c4a9e 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -16,7 +16,7 @@ list(APPEND cython_sources "device_buffer.pyx") list(APPEND cython_sources "lib.pyx") list(APPEND cython_sources "memory_resource.pyx") -list(APPEND cython_sources "cuda_stream_view.pyx") +list(APPEND cython_sources "cuda_stream.pyx") # Build all of the Cython targets foreach(cython_file ${cython_sources}) diff --git a/python/rmm/tests/CMakeLists.txt b/python/rmm/tests/CMakeLists.txt deleted file mode 100644 index d83fa2f05..000000000 --- a/python/rmm/tests/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# ============================================================================= -# Copyright (c) 2020, NVIDIA CORPORATION. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# ============================================================================= - -# Set the list of Cython files to build -list(APPEND cython_sources "test_device_buffer.pyx") - -# Build all of the Cython targets -foreach(cython_file ${cython_sources}) - get_filename_component(cython_module_name ${cython_file} NAME_WLE) - add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) - add_library(${cython_module_name} MODULE ${cython_module_name}) - set_target_properties(${cython_module_name} PROPERTIES PREFIX "") - target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) - target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module_name} LIBRARY DESTINATION rmm/tests) -endforeach(cython_file ${cython_sources}) From fb32ec7a5bab8021ca81e868cd877f0591825d2b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Feb 2022 17:48:15 -0800 Subject: [PATCH 04/51] Some degree of further simplification. --- python/CMakeLists.txt | 4 ---- python/rmm/_cuda/CMakeLists.txt | 26 ++++++++++++++++---------- python/rmm/_lib/CMakeLists.txt | 32 +++++++++++++++++++------------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index aa8a35151..c41ee4467 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -27,10 +27,6 @@ find_package(Python3 REQUIRED COMPONENTS Development) find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) -# include(cmake/CPM.cmake) -# TODO (kk): CPMFindPackage spdlog -# TODO (kk): CPMFindPackage Thrust - # TODO: Is this the expected behavior? To use existing installs if found, otherwise the headers from the source directory? # Try to find an installed RMM, if not found add the parent directory # TODO (kk): Do some basic validation to ensure the parent is as expected diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 1764e4fe6..7362c153e 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -13,15 +13,21 @@ # ============================================================================= # Set the list of Cython files to build -list(APPEND cython_sources "stream.pyx") +set(cython_sources + stream) +# TODO: Extract this logic into a function that can be reused. # Build all of the Cython targets -foreach(cython_file ${cython_sources}) - get_filename_component(cython_module_name ${cython_file} NAME_WLE) - add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) - add_library(${cython_module_name} MODULE ${cython_module_name}) - set_target_properties(${cython_module_name} PROPERTIES PREFIX "") - target_link_libraries(${cython_module_name} rmm::rmm Python3::Module CUDA::cuda_driver) - target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module_name} LIBRARY DESTINATION rmm/_cuda) -endforeach(cython_file ${cython_sources}) +foreach(cython_module ${cython_sources}) + add_cython_target("${cython_module}" CXX PY3) + add_library(${cython_module} MODULE ${cython_module}) + # TODO: This doesn't seem to be necessary for some reason. Are the Python headers somehow being included without it? In fact, trying to add this fails. + #python_extension_module(${cython_module}) + + # To avoid libraries being prefixed with "lib". + set_target_properties(${cython_module} PROPERTIES PREFIX "") + + target_link_libraries(${cython_module} rmm::rmm Python3::Module) + target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + install(TARGETS ${cython_module} DESTINATION rmm/_cuda) +endforeach(cython_module ${cython_sources}) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index ccb4c4a9e..4e38db904 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -13,18 +13,24 @@ # ============================================================================= # Set the list of Cython files to build -list(APPEND cython_sources "device_buffer.pyx") -list(APPEND cython_sources "lib.pyx") -list(APPEND cython_sources "memory_resource.pyx") -list(APPEND cython_sources "cuda_stream.pyx") +set(cython_sources + device_buffer + lib + memory_resource + cuda_stream) # Build all of the Cython targets -foreach(cython_file ${cython_sources}) - get_filename_component(cython_module_name ${cython_file} NAME_WLE) - add_cython_target("${cython_module_name}" "${cython_file}" CXX PY3) - add_library(${cython_module_name} MODULE ${cython_module_name}) - set_target_properties(${cython_module_name} PROPERTIES PREFIX "") - target_link_libraries(${cython_module_name} rmm::rmm Python3::Module) - target_include_directories(${cython_module_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module_name} LIBRARY DESTINATION rmm/_lib) -endforeach(cython_file ${cython_sources}) +foreach(cython_module ${cython_sources}) + add_cython_target("${cython_module}" CXX PY3) + add_library(${cython_module} MODULE ${cython_module}) + # TODO: This doesn't seem to be necessary for some reason. Are the Python + # headers somehow being included without it? + #python_extension_module(${cython_module}) + + # To avoid libraries being prefixed with "lib". + set_target_properties(${cython_module} PROPERTIES PREFIX "") + + target_link_libraries(${cython_module} rmm::rmm Python3::Module) + target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + install(TARGETS ${cython_module} DESTINATION rmm/_lib) +endforeach(cython_module ${cython_sources}) From 3eb20facd170a8af6ce40bb9e38393c035e8f1cd Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Feb 2022 17:52:42 -0800 Subject: [PATCH 05/51] Remove unnecessary cmake symlinks. --- cmake/cmake | 1 - python/cmake | 1 - 2 files changed, 2 deletions(-) delete mode 120000 cmake/cmake delete mode 120000 python/cmake diff --git a/cmake/cmake b/cmake/cmake deleted file mode 120000 index b6868d450..000000000 --- a/cmake/cmake +++ /dev/null @@ -1 +0,0 @@ -cmake \ No newline at end of file diff --git a/python/cmake b/python/cmake deleted file mode 120000 index 1a8cebff2..000000000 --- a/python/cmake +++ /dev/null @@ -1 +0,0 @@ -../cmake \ No newline at end of file From ee69827de5dbaff2570589a6d16848e327efa8d2 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Feb 2022 18:06:02 -0800 Subject: [PATCH 06/51] Move cython module adding logic to a function. --- python/CMakeLists.txt | 1 + python/cmake/CMakeLists.txt | 1 + python/cmake/rmm-python-helpers.cmake | 16 ++++++++++++++++ python/rmm/_cuda/CMakeLists.txt | 17 ++--------------- python/rmm/_lib/CMakeLists.txt | 17 ++--------------- 5 files changed, 22 insertions(+), 30 deletions(-) create mode 100644 python/cmake/CMakeLists.txt create mode 100644 python/cmake/rmm-python-helpers.cmake diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c41ee4467..5a6d8a3b1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -37,5 +37,6 @@ if(NOT RMM_FOUND) add_subdirectory(../ rmm-cpp) endif(NOT RMM_FOUND) +add_subdirectory(cmake) add_subdirectory(rmm/_cuda) add_subdirectory(rmm/_lib) diff --git a/python/cmake/CMakeLists.txt b/python/cmake/CMakeLists.txt new file mode 100644 index 000000000..e339fcb65 --- /dev/null +++ b/python/cmake/CMakeLists.txt @@ -0,0 +1 @@ +include(rmm-python-helpers.cmake) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake new file mode 100644 index 000000000..4ec15a4ec --- /dev/null +++ b/python/cmake/rmm-python-helpers.cmake @@ -0,0 +1,16 @@ +function(add_cython_modules cython_modules) + foreach(cython_module ${cython_modules}) + add_cython_target(${cython_module} CXX PY3) + add_library(${cython_module} MODULE ${cython_module}) + # TODO: This doesn't seem to be necessary for some reason. Are the Python + # headers somehow being included without it? + #python_extension_module(${cython_module}) + + # To avoid libraries being prefixed with "lib". + set_target_properties(${cython_module} PROPERTIES PREFIX "") + + target_link_libraries(${cython_module} rmm::rmm Python3::Module) + target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + install(TARGETS ${cython_module} DESTINATION rmm/_lib) + endforeach(cython_module ${cython_sources}) +endfunction() diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 7362c153e..9f157b4c2 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -13,21 +13,8 @@ # ============================================================================= # Set the list of Cython files to build -set(cython_sources +set(cython_modules stream) -# TODO: Extract this logic into a function that can be reused. # Build all of the Cython targets -foreach(cython_module ${cython_sources}) - add_cython_target("${cython_module}" CXX PY3) - add_library(${cython_module} MODULE ${cython_module}) - # TODO: This doesn't seem to be necessary for some reason. Are the Python headers somehow being included without it? In fact, trying to add this fails. - #python_extension_module(${cython_module}) - - # To avoid libraries being prefixed with "lib". - set_target_properties(${cython_module} PROPERTIES PREFIX "") - - target_link_libraries(${cython_module} rmm::rmm Python3::Module) - target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module} DESTINATION rmm/_cuda) -endforeach(cython_module ${cython_sources}) +add_cython_modules(${cython_modules}) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 4e38db904..c46afc0c7 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -13,24 +13,11 @@ # ============================================================================= # Set the list of Cython files to build -set(cython_sources +set(cython_modules device_buffer lib memory_resource cuda_stream) # Build all of the Cython targets -foreach(cython_module ${cython_sources}) - add_cython_target("${cython_module}" CXX PY3) - add_library(${cython_module} MODULE ${cython_module}) - # TODO: This doesn't seem to be necessary for some reason. Are the Python - # headers somehow being included without it? - #python_extension_module(${cython_module}) - - # To avoid libraries being prefixed with "lib". - set_target_properties(${cython_module} PROPERTIES PREFIX "") - - target_link_libraries(${cython_module} rmm::rmm Python3::Module) - target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module} DESTINATION rmm/_lib) -endforeach(cython_module ${cython_sources}) +add_cython_modules(${cython_modules}) From 41d600f9b8868ab01efd6b48349eea14ae970b4f Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Feb 2022 18:29:17 -0800 Subject: [PATCH 07/51] Apply linters. --- cmake/config.json | 2 +- python/CMakeLists.txt | 31 ++++++++++++++------------- python/cmake/rmm-python-helpers.cmake | 25 +++++++++++++++++---- python/rmm/_cuda/CMakeLists.txt | 3 +-- python/rmm/_lib/CMakeLists.txt | 8 ++----- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/cmake/config.json b/cmake/config.json index fa3f769cc..6fb9d3fd7 100644 --- a/cmake/config.json +++ b/cmake/config.json @@ -28,7 +28,7 @@ "max_pargs_hwrap": 999 }, "lint": { - "disabled_codes": ["C0301"], + "disabled_codes": ["C0301", "C0112"], "function_pattern": "[0-9A-z_]+", "macro_pattern": "[0-9A-z_]+", "global_var_pattern": "[A-z][0-9A-z_]+", diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5a6d8a3b1..ad5941400 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,18 +1,16 @@ -#============================================================================= +# ============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#============================================================================= +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) @@ -20,16 +18,19 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) set(rmm_version 22.04.00) # TODO: What name do we want to use here? -project(rmm-python VERSION ${rmm_version} LANGUAGES CXX CUDA) +project( + rmm-python + VERSION ${rmm_version} + LANGUAGES CXX CUDA) find_package(PythonExtensions REQUIRED) find_package(Python3 REQUIRED COMPONENTS Development) find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) -# TODO: Is this the expected behavior? To use existing installs if found, otherwise the headers from the source directory? -# Try to find an installed RMM, if not found add the parent directory -# TODO (kk): Do some basic validation to ensure the parent is as expected +# TODO: Is this the expected behavior? To use existing installs if found, otherwise the headers from +# the source directory? Try to find an installed RMM, if not found add the parent directory TODO +# (kk): Do some basic validation to ensure the parent is as expected find_package(RMM ${rmm_version}) if(NOT RMM_FOUND) set(BUILD_TESTS OFF) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index 4ec15a4ec..c43240559 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -1,14 +1,31 @@ +#[=======================================================================[.rst: +add_cython_modules +------------------ + +Generate C(++) from Cython and create Python modules. + +.. code-block:: cmake + + add_cython_modules() + +Creates a Cython target for a module, then adds a corresponding Python +extension module. + +``ModuleName`` + The list of modules to build. + +#]=======================================================================] function(add_cython_modules cython_modules) foreach(cython_module ${cython_modules}) add_cython_target(${cython_module} CXX PY3) add_library(${cython_module} MODULE ${cython_module}) - # TODO: This doesn't seem to be necessary for some reason. Are the Python - # headers somehow being included without it? + # TODO: This doesn't seem to be necessary for some reason. Are the Python headers somehow being + # included without it? #python_extension_module(${cython_module}) - + # To avoid libraries being prefixed with "lib". set_target_properties(${cython_module} PROPERTIES PREFIX "") - + target_link_libraries(${cython_module} rmm::rmm Python3::Module) target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") install(TARGETS ${cython_module} DESTINATION rmm/_lib) diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 9f157b4c2..b77b5d801 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -13,8 +13,7 @@ # ============================================================================= # Set the list of Cython files to build -set(cython_modules - stream) +set(cython_modules stream) # Build all of the Cython targets add_cython_modules(${cython_modules}) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index c46afc0c7..71d61fc8d 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at @@ -13,11 +13,7 @@ # ============================================================================= # Set the list of Cython files to build -set(cython_modules - device_buffer - lib - memory_resource - cuda_stream) +set(cython_modules device_buffer lib memory_resource cuda_stream) # Build all of the Cython targets add_cython_modules(${cython_modules}) From f5f9bb2b6a5c52415fa0cc13d6856cc482efec6c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Feb 2022 19:09:18 -0800 Subject: [PATCH 08/51] Add TODOs documenting various issues discovered. --- python/CMakeLists.txt | 12 ++++++++++-- python/cmake/rmm-python-helpers.cmake | 11 +++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index ad5941400..9f2c4bce6 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -21,10 +21,18 @@ set(rmm_version 22.04.00) project( rmm-python VERSION ${rmm_version} - LANGUAGES CXX CUDA) + # TODO: For some reason building Python extension modules via the + # python_extension_module requires the C language here to be enabled. I + # suspect that it assumes that Cython is C even when it's actually building + # C++. Setting a directive in the file does not resolve the problem. + LANGUAGES C CXX CUDA) find_package(PythonExtensions REQUIRED) -find_package(Python3 REQUIRED COMPONENTS Development) +# TODO: This isn't necessary if we use `python_extension_module`, but it is for manually linking to the Python3 headers. +#find_package(Python3 REQUIRED COMPONENTS Development) +# TODO: When would we need to add these? +#find_package(PythonInterp REQUIRED) +#find_package(PythonLibs REQUIRED) find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index c43240559..07eae176f 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -19,14 +19,17 @@ function(add_cython_modules cython_modules) foreach(cython_module ${cython_modules}) add_cython_target(${cython_module} CXX PY3) add_library(${cython_module} MODULE ${cython_module}) - # TODO: This doesn't seem to be necessary for some reason. Are the Python headers somehow being - # included without it? - #python_extension_module(${cython_module}) + # TODO: This fails unless the C language is enabled in the project.Also, + # this is slower to compile than just linking manually to Python3 below. + python_extension_module(${cython_module}) # To avoid libraries being prefixed with "lib". set_target_properties(${cython_module} PROPERTIES PREFIX "") - target_link_libraries(${cython_module} rmm::rmm Python3::Module) + # TODO: This is the "manual" version of the python_extension_module command + # above, but it seems to compile faster. + #target_link_libraries(${cython_module} rmm::rmm Python3::Module) + target_link_libraries(${cython_module} rmm::rmm) target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") install(TARGETS ${cython_module} DESTINATION rmm/_lib) endforeach(cython_module ${cython_sources}) From 6cc43bcc5c5e8218a0795c064fc852ffa95fe39d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Feb 2022 10:59:29 -0800 Subject: [PATCH 09/51] Fix install destination. --- python/cmake/rmm-python-helpers.cmake | 8 ++++++-- python/rmm/_cuda/CMakeLists.txt | 2 +- python/rmm/_lib/CMakeLists.txt | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index 07eae176f..9444b29e1 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -15,7 +15,8 @@ extension module. The list of modules to build. #]=======================================================================] -function(add_cython_modules cython_modules) +function(add_cython_modules cython_modules install_dst) + message("The install destination is ${install_dst} when the cython module is ${cython_modules}") foreach(cython_module ${cython_modules}) add_cython_target(${cython_module} CXX PY3) add_library(${cython_module} MODULE ${cython_module}) @@ -31,6 +32,9 @@ function(add_cython_modules cython_modules) #target_link_libraries(${cython_module} rmm::rmm Python3::Module) target_link_libraries(${cython_module} rmm::rmm) target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - install(TARGETS ${cython_module} DESTINATION rmm/_lib) + # TODO: Currently requiring the user to pass the install destination + # because I'm not sure what CMake variable is most appropriate to work for + # both in- and out-of-source builds. + install(TARGETS ${cython_module} DESTINATION ${install_dst}) endforeach(cython_module ${cython_sources}) endfunction() diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index b77b5d801..0ec13a568 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -16,4 +16,4 @@ set(cython_modules stream) # Build all of the Cython targets -add_cython_modules(${cython_modules}) +add_cython_modules("${cython_modules}" rmm/_cuda) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 71d61fc8d..78336cf96 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -16,4 +16,4 @@ set(cython_modules device_buffer lib memory_resource cuda_stream) # Build all of the Cython targets -add_cython_modules(${cython_modules}) +add_cython_modules("${cython_modules}" rmm/_lib) From ecf36219f9c7940afbc0e390592b469c817eb37c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Feb 2022 11:15:50 -0800 Subject: [PATCH 10/51] Add missing copyrights. --- python/cmake/CMakeLists.txt | 14 ++++++++++++++ python/cmake/rmm-python-helpers.cmake | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/python/cmake/CMakeLists.txt b/python/cmake/CMakeLists.txt index e339fcb65..dc1608784 100644 --- a/python/cmake/CMakeLists.txt +++ b/python/cmake/CMakeLists.txt @@ -1 +1,15 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + include(rmm-python-helpers.cmake) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index 9444b29e1..9f96a15af 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -1,3 +1,17 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + #[=======================================================================[.rst: add_cython_modules ------------------ From e5b1e43ad9bd88f7f3f310500da39812e5663519 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 13:24:47 -0800 Subject: [PATCH 11/51] Some basic cleanup. --- python/CMakeLists.txt | 10 +--------- python/cmake/rmm-python-helpers.cmake | 6 ------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9f2c4bce6..03c2d8526 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -17,7 +17,6 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) # TODO: Pull this directly from the file written by rapids_cmake_write_version_file. set(rmm_version 22.04.00) -# TODO: What name do we want to use here? project( rmm-python VERSION ${rmm_version} @@ -28,17 +27,10 @@ project( LANGUAGES C CXX CUDA) find_package(PythonExtensions REQUIRED) -# TODO: This isn't necessary if we use `python_extension_module`, but it is for manually linking to the Python3 headers. -#find_package(Python3 REQUIRED COMPONENTS Development) -# TODO: When would we need to add these? -#find_package(PythonInterp REQUIRED) -#find_package(PythonLibs REQUIRED) find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) -# TODO: Is this the expected behavior? To use existing installs if found, otherwise the headers from -# the source directory? Try to find an installed RMM, if not found add the parent directory TODO -# (kk): Do some basic validation to ensure the parent is as expected +# TODO: Instead of running find_package first, default to using add_subdirectory unless a configuration option is set to use a pre-built RMM. find_package(RMM ${rmm_version}) if(NOT RMM_FOUND) set(BUILD_TESTS OFF) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index 9f96a15af..59293aec4 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -30,20 +30,14 @@ extension module. #]=======================================================================] function(add_cython_modules cython_modules install_dst) - message("The install destination is ${install_dst} when the cython module is ${cython_modules}") foreach(cython_module ${cython_modules}) add_cython_target(${cython_module} CXX PY3) add_library(${cython_module} MODULE ${cython_module}) - # TODO: This fails unless the C language is enabled in the project.Also, - # this is slower to compile than just linking manually to Python3 below. python_extension_module(${cython_module}) # To avoid libraries being prefixed with "lib". set_target_properties(${cython_module} PROPERTIES PREFIX "") - # TODO: This is the "manual" version of the python_extension_module command - # above, but it seems to compile faster. - #target_link_libraries(${cython_module} rmm::rmm Python3::Module) target_link_libraries(${cython_module} rmm::rmm) target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") # TODO: Currently requiring the user to pass the install destination From b5cd9cf2fc6589bfe6f14ccbd3abf7b5a3675e1f Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 16:52:31 -0800 Subject: [PATCH 12/51] Use cmake_path to compute install destination. --- python/cmake/rmm-python-helpers.cmake | 6 ++---- python/rmm/_cuda/CMakeLists.txt | 2 +- python/rmm/_lib/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index 59293aec4..bb1aef015 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -29,7 +29,7 @@ extension module. The list of modules to build. #]=======================================================================] -function(add_cython_modules cython_modules install_dst) +function(add_cython_modules cython_modules) foreach(cython_module ${cython_modules}) add_cython_target(${cython_module} CXX PY3) add_library(${cython_module} MODULE ${cython_module}) @@ -40,9 +40,7 @@ function(add_cython_modules cython_modules install_dst) target_link_libraries(${cython_module} rmm::rmm) target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - # TODO: Currently requiring the user to pass the install destination - # because I'm not sure what CMake variable is most appropriate to work for - # both in- and out-of-source builds. + cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} OUTPUT_VARIABLE install_dst) install(TARGETS ${cython_module} DESTINATION ${install_dst}) endforeach(cython_module ${cython_sources}) endfunction() diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 0ec13a568..16489dde5 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -16,4 +16,4 @@ set(cython_modules stream) # Build all of the Cython targets -add_cython_modules("${cython_modules}" rmm/_cuda) +add_cython_modules("${cython_modules}") diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 78336cf96..954af9331 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -16,4 +16,4 @@ set(cython_modules device_buffer lib memory_resource cuda_stream) # Build all of the Cython targets -add_cython_modules("${cython_modules}" rmm/_lib) +add_cython_modules("${cython_modules}") From c9e0a17c7c55377bbbd71b820fb0df855fd4ab19 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 17:05:19 -0800 Subject: [PATCH 13/51] Add an option to look for existing rmm installations rather than pulling from the source directory. --- python/CMakeLists.txt | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 03c2d8526..d8f89fd63 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -20,18 +20,28 @@ set(rmm_version 22.04.00) project( rmm-python VERSION ${rmm_version} - # TODO: For some reason building Python extension modules via the - # python_extension_module requires the C language here to be enabled. I - # suspect that it assumes that Cython is C even when it's actually building - # C++. Setting a directive in the file does not resolve the problem. + # TODO: Building Python extension modules via the python_extension_module + # requires the C language to be enabled here. The test project that is built + # in scikit-build to verify various linking options for the python library is + # hardcoded to build with C, so until that is fixed we need to keep this. LANGUAGES C CXX CUDA) +option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting to local files" OFF) + find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) -# TODO: Instead of running find_package first, default to using add_subdirectory unless a configuration option is set to use a pre-built RMM. -find_package(RMM ${rmm_version}) +# If the user requested it we attempt to find RMM. +# TODO: Should we allow the user to specify a path instead of just searching? +# This version assumes that the installation has been appropriately configured +# for CMake discovery. +if(FIND_RMM_CPP) + find_package(RMM ${rmm_version}) +else() + set(RMM_FOUND OFF) +endif(FIND_RMM_CPP) + if(NOT RMM_FOUND) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) From 383e68a613b7aa73400cf7b34e35a37b1792d1f4 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 17:26:08 -0800 Subject: [PATCH 14/51] Run formatters. --- python/CMakeLists.txt | 22 +++++++++++----------- python/cmake/rmm-python-helpers.cmake | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d8f89fd63..70f39d47e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -20,26 +20,26 @@ set(rmm_version 22.04.00) project( rmm-python VERSION ${rmm_version} - # TODO: Building Python extension modules via the python_extension_module - # requires the C language to be enabled here. The test project that is built - # in scikit-build to verify various linking options for the python library is - # hardcoded to build with C, so until that is fixed we need to keep this. + # TODO: Building Python extension modules via the python_extension_module requires the C language + # to be enabled here. The test project that is built in scikit-build to verify various linking + # options for the python library is hardcoded to build with C, so until that is fixed we need to + # keep this. LANGUAGES C CXX CUDA) -option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting to local files" OFF) +option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting to local files" + OFF) find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) find_package(CUDAToolkit REQUIRED) -# If the user requested it we attempt to find RMM. -# TODO: Should we allow the user to specify a path instead of just searching? -# This version assumes that the installation has been appropriately configured -# for CMake discovery. +# If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path +# instead of just searching? This version assumes that the installation has been appropriately +# configured for CMake discovery. if(FIND_RMM_CPP) - find_package(RMM ${rmm_version}) + find_package(RMM ${rmm_version}) else() - set(RMM_FOUND OFF) + set(RMM_FOUND OFF) endif(FIND_RMM_CPP) if(NOT RMM_FOUND) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index bb1aef015..d4e3fa54f 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -40,7 +40,8 @@ function(add_cython_modules cython_modules) target_link_libraries(${cython_module} rmm::rmm) target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} OUTPUT_VARIABLE install_dst) + cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} + OUTPUT_VARIABLE install_dst) install(TARGETS ${cython_module} DESTINATION ${install_dst}) endforeach(cython_module ${cython_sources}) endfunction() From a576c2aedd8f3aa5e2df82e31453543392fc0a14 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 18:03:30 -0800 Subject: [PATCH 15/51] Remove unnecessary includes and add some comments. --- python/cmake/rmm-python-helpers.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index d4e3fa54f..b815c30b1 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -37,9 +37,10 @@ function(add_cython_modules cython_modules) # To avoid libraries being prefixed with "lib". set_target_properties(${cython_module} PROPERTIES PREFIX "") - target_link_libraries(${cython_module} rmm::rmm) - target_include_directories(${cython_module} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + + # Compute the install directory relative to the source and rely on installs + # being relative to the CMAKE_PREFIX_PATH for e.g. editable installs. cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} OUTPUT_VARIABLE install_dst) install(TARGETS ${cython_module} DESTINATION ${install_dst}) From 9a6ccfba0d4da28d1325da25184f15df6159fff7 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 18:11:34 -0800 Subject: [PATCH 16/51] Remove unnecessary CUDAToolkit. --- python/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 70f39d47e..eab194498 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -31,7 +31,6 @@ option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) -find_package(CUDAToolkit REQUIRED) # If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path # instead of just searching? This version assumes that the installation has been appropriately From 3481d3675e535e5d97f698524a486fa8719ae119 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 18:39:56 -0800 Subject: [PATCH 17/51] Fix formatting. --- python/cmake/rmm-python-helpers.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm-python-helpers.cmake index b815c30b1..91f0a5a17 100644 --- a/python/cmake/rmm-python-helpers.cmake +++ b/python/cmake/rmm-python-helpers.cmake @@ -39,8 +39,8 @@ function(add_cython_modules cython_modules) set_target_properties(${cython_module} PROPERTIES PREFIX "") target_link_libraries(${cython_module} rmm::rmm) - # Compute the install directory relative to the source and rely on installs - # being relative to the CMAKE_PREFIX_PATH for e.g. editable installs. + # Compute the install directory relative to the source and rely on installs being relative to + # the CMAKE_PREFIX_PATH for e.g. editable installs. cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} OUTPUT_VARIABLE install_dst) install(TARGETS ${cython_module} DESTINATION ${install_dst}) From defcbf0275632ca06d963a0f853f81dd2fcec8ff Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 16 Feb 2022 14:06:48 -0800 Subject: [PATCH 18/51] Prevent scikit-build from marking all symbols as local, which clobbers the visibility attribute ensuring that per device resources are consistent across all objects in a shared library. --- python/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index eab194498..45551a719 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -32,6 +32,34 @@ option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) +# TODO: Should we guard this based on a scikit-build version? +# Override this function to avoid scikit-build clobbering symbol visibility. +function(_set_python_extension_symbol_visibility _target) + if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) + set(_modinit_prefix "PyInit_") + else() + set(_modinit_prefix "init") + endif() + message("_modinit_prefix:${_modinit_prefix}") + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${_target} PROPERTIES LINK_FLAGS + "/EXPORT:${_modinit_prefix}${_target}" + ) + elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(_script_path + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map + ) + file(WRITE ${_script_path} + # Note: The change is to this script, which does not indiscriminately + # mark all non PyInit symbols as local. + "{global: ${_modinit_prefix}${_target}; };" + ) + set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS + " -Wl,--version-script=\"${_script_path}\"" + ) + endif() +endfunction() + # If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path # instead of just searching? This version assumes that the installation has been appropriately # configured for CMake discovery. From b0764576a0f446f964120d8d0e716e455c7535f6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 16 Feb 2022 14:10:33 -0800 Subject: [PATCH 19/51] Silence CMake warnings about an unused variable. --- python/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 45551a719..029e4b40e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -60,6 +60,9 @@ function(_set_python_extension_symbol_visibility _target) endif() endfunction() +# Ignore unused variable warning. +set(ignored_variable "${SKBUILD}") + # If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path # instead of just searching? This version assumes that the installation has been appropriately # configured for CMake discovery. From 82366e5d45bcc54736efd70cd92d4dea6042cc3e Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 16 Feb 2022 14:20:56 -0800 Subject: [PATCH 20/51] Run cmake-format. --- python/CMakeLists.txt | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 029e4b40e..94c5bf93d 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -32,8 +32,8 @@ option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) -# TODO: Should we guard this based on a scikit-build version? -# Override this function to avoid scikit-build clobbering symbol visibility. +# TODO: Should we guard this based on a scikit-build version? Override this function to avoid +# scikit-build clobbering symbol visibility. function(_set_python_extension_symbol_visibility _target) if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) set(_modinit_prefix "PyInit_") @@ -42,21 +42,18 @@ function(_set_python_extension_symbol_visibility _target) endif() message("_modinit_prefix:${_modinit_prefix}") if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${_target} PROPERTIES LINK_FLAGS - "/EXPORT:${_modinit_prefix}${_target}" - ) + set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(_script_path - ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map - ) - file(WRITE ${_script_path} - # Note: The change is to this script, which does not indiscriminately - # mark all non PyInit symbols as local. - "{global: ${_modinit_prefix}${_target}; };" - ) - set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS - " -Wl,--version-script=\"${_script_path}\"" - ) + set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) + file( + WRITE ${_script_path} + # Note: The change is to this script, which does not indiscriminately mark all non PyInit + # symbols as local. + "{global: ${_modinit_prefix}${_target}; };") + set_property( + TARGET ${_target} + APPEND_STRING + PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") endif() endfunction() From 57cc78e86e97b0b10e8b42ccf7f1b740b7870b5d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 16 Feb 2022 17:40:42 -0800 Subject: [PATCH 21/51] Address PR comments. --- python/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 94c5bf93d..3b3a8b0c5 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -23,10 +23,13 @@ project( # TODO: Building Python extension modules via the python_extension_module requires the C language # to be enabled here. The test project that is built in scikit-build to verify various linking # options for the python library is hardcoded to build with C, so until that is fixed we need to - # keep this. + # keep this. TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to + # CMake 3.22 will also pull in the corresponding required languages even if this project does not + # actually require those languages. As a result, we need to include CUDA here. We can remove this + # once we upgrade the minimum required CMake version to 3.22. LANGUAGES C CXX CUDA) -option(FIND_RMM_CPP "Search for existing RMM CPP installations before defaulting to local files" +option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) find_package(PythonExtensions REQUIRED) From 6993f2d3cabfcdea67b30d9f9a4a49509a1aa2a4 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 08:58:22 -0800 Subject: [PATCH 22/51] Stop on first test failure. --- ci/gpu/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 8a7a94e22..27fcc1716 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -92,7 +92,7 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then gpuci_logger "Running rmm pytests..." cd $WORKSPACE/python - py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term + py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x fi else export LD_LIBRARY_PATH="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build:$LD_LIBRARY_PATH" From 4f752b05764a089925a8159a02ee2b8dccf41e54 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 09:29:47 -0800 Subject: [PATCH 23/51] Actually stop on first test failure. --- ci/gpu/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 27fcc1716..8909614cc 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -92,7 +92,7 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then gpuci_logger "Running rmm pytests..." cd $WORKSPACE/python - py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x + py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term fi else export LD_LIBRARY_PATH="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build:$LD_LIBRARY_PATH" @@ -130,7 +130,7 @@ else "$WORKSPACE/build.sh" -v rmm gpuci_logger "pytest rmm" - py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term + py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x exitcode=$? if (( ${exitcode} != 0 )); then SUITEERROR=${exitcode} From 6d98e6983ab092f88cd2aa17a369f089d323e9b0 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 11:56:04 -0800 Subject: [PATCH 24/51] Add scikit-build to all conda environment and recipes as well as the dev requirements file. --- conda/environments/rmm_dev_cuda11.5.yml | 1 + conda/environments/rmm_dev_cuda11.6.yml | 1 + conda/recipes/rmm/meta.yaml | 3 ++- python/dev_requirements.txt | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 549aca8d5..c09595999 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -16,6 +16,7 @@ dependencies: - cffi>=1.10.0 - pytest - cudatoolkit=11.5 +- scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index d8e2320a4..9b1d258d6 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -16,6 +16,7 @@ dependencies: - cffi>=1.10.0 - pytest - cudatoolkit=11.6 +- scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index ce1ecec07..c2f1968d2 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set py_version=environ.get('CONDA_PY', 35) %} @@ -28,6 +28,7 @@ requirements: - librmm {{ version }} - setuptools - cython >=0.29,<0.30 + - scikit-build>=0.13.1 - spdlog>=1.8.5,<2.0.0a0 - cudatoolkit {{ cuda_version }}.* - cuda-python >=11.5,<12.0 diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt index 2113ee242..0b494bf32 100644 --- a/python/dev_requirements.txt +++ b/python/dev_requirements.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. clang==8.0.1 flake8==3.8.3 @@ -12,3 +12,4 @@ pytest-xdist cython>=0.29,<0.30 wheel setuptools +scikit-build>=0.13.1 From f54978c4b9a0a0a6e62de4e592d08f097f71ee83 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 12:41:10 -0800 Subject: [PATCH 25/51] Disable cudaMallocAsync using CMake directly now that we have access from setup.py builds using scikit-build. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index e04442344..5e32cd823 100755 --- a/build.sh +++ b/build.sh @@ -179,7 +179,7 @@ if (( NUMARGS == 0 )) || hasArg rmm; then export INSTALL_PREFIX echo "building rmm..." if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then - python setup.py build_ext_no_async --inplace + python setup.py build_ext --inplace -- -DRMM_DISABLE_CUDA_MALLOC_ASYNC else python setup.py build_ext --inplace fi From 9c39e049eae87528286e3b0adc8e923d8f9787de Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 14:27:34 -0800 Subject: [PATCH 26/51] Pass CMake variable correctly. --- build.sh | 6 +----- python/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 5e32cd823..804bbca94 100755 --- a/build.sh +++ b/build.sh @@ -178,11 +178,7 @@ if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" export INSTALL_PREFIX echo "building rmm..." - if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then - python setup.py build_ext --inplace -- -DRMM_DISABLE_CUDA_MALLOC_ASYNC - else - python setup.py build_ext --inplace - fi + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=ON if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3b3a8b0c5..146cbe859 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -72,6 +72,10 @@ else() set(RMM_FOUND OFF) endif(FIND_RMM_CPP) +if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) + compile_definitions("RMM_DISABLE_CUDA_MALLOC_ASYNC") +endif() + if(NOT RMM_FOUND) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) From 696430eb458ac01429d08cb6491185eaf49916b1 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 14:27:47 -0800 Subject: [PATCH 27/51] Remove unnecessary endifs. --- python/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 146cbe859..cf3e68536 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -70,7 +70,7 @@ if(FIND_RMM_CPP) find_package(RMM ${rmm_version}) else() set(RMM_FOUND OFF) -endif(FIND_RMM_CPP) +endif() if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) compile_definitions("RMM_DISABLE_CUDA_MALLOC_ASYNC") @@ -80,7 +80,7 @@ if(NOT RMM_FOUND) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) add_subdirectory(../ rmm-cpp) -endif(NOT RMM_FOUND) +endif() add_subdirectory(cmake) add_subdirectory(rmm/_cuda) From 6951f75e92819e787c5459f5e7faab51804fc504 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 14:32:37 -0800 Subject: [PATCH 28/51] Move scikit-build override to separate helper file and add license. --- python/CMakeLists.txt | 25 -------- python/cmake/set_python_visibility.cmake | 76 ++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 python/cmake/set_python_visibility.cmake diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cf3e68536..a307cdd82 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -35,31 +35,6 @@ option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) -# TODO: Should we guard this based on a scikit-build version? Override this function to avoid -# scikit-build clobbering symbol visibility. -function(_set_python_extension_symbol_visibility _target) - if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) - set(_modinit_prefix "PyInit_") - else() - set(_modinit_prefix "init") - endif() - message("_modinit_prefix:${_modinit_prefix}") - if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") - elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) - file( - WRITE ${_script_path} - # Note: The change is to this script, which does not indiscriminately mark all non PyInit - # symbols as local. - "{global: ${_modinit_prefix}${_target}; };") - set_property( - TARGET ${_target} - APPEND_STRING - PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") - endif() -endfunction() - # Ignore unused variable warning. set(ignored_variable "${SKBUILD}") diff --git a/python/cmake/set_python_visibility.cmake b/python/cmake/set_python_visibility.cmake new file mode 100644 index 000000000..7fa7b41f2 --- /dev/null +++ b/python/cmake/set_python_visibility.cmake @@ -0,0 +1,76 @@ +# This code is adapted directly from the scikit-build project under the following license. + +# The MIT License (MIT) +# +# Copyright (c) 2014 Mike Sarahan +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# +# This project borrows a great deal from the setup tools of the PyNE project. Here is its license: +# +# Copyright 2011-2014, the PyNE Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are +# permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are those of the +# authors and should not be interpreted as representing official policies, either expressed +# or implied, of the stakeholders of the PyNE project or the employers of PyNE developers. + +# TODO: Should we guard this based on a scikit-build version? Override this function to avoid +# scikit-build clobbering symbol visibility. +function(_set_python_extension_symbol_visibility _target) + if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) + set(_modinit_prefix "PyInit_") + else() + set(_modinit_prefix "init") + endif() + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") + elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) + file( + WRITE ${_script_path} + # Note: The change is to this script, which does not indiscriminately mark all non PyInit + # symbols as local. + "{global: ${_modinit_prefix}${_target}; };") + set_property( + TARGET ${_target} + APPEND_STRING + PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") + endif() +endfunction() From 81d7a7b5b0a1d97d86070c3e0ec352c8217c1b9a Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 14:33:32 -0800 Subject: [PATCH 29/51] Run cmake-format. --- python/cmake/set_python_visibility.cmake | 83 +++++++++++------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/python/cmake/set_python_visibility.cmake b/python/cmake/set_python_visibility.cmake index 7fa7b41f2..55036a1c7 100644 --- a/python/cmake/set_python_visibility.cmake +++ b/python/cmake/set_python_visibility.cmake @@ -1,55 +1,50 @@ # This code is adapted directly from the scikit-build project under the following license. # The MIT License (MIT) -# +# # Copyright (c) 2014 Mike Sarahan -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +# associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, +# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# +# +# The above copyright notice and this permission notice shall be included in all copies or +# substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT +# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# # This project borrows a great deal from the setup tools of the PyNE project. Here is its license: -# +# # Copyright 2011-2014, the PyNE Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other materials -# provided with the distribution. -# +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# +# 1. Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# # THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are those of the -# authors and should not be interpreted as representing official policies, either expressed -# or implied, of the stakeholders of the PyNE project or the employers of PyNE developers. +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are those of the authors and +# should not be interpreted as representing official policies, either expressed or implied, of the +# stakeholders of the PyNE project or the employers of PyNE developers. # TODO: Should we guard this based on a scikit-build version? Override this function to avoid # scikit-build clobbering symbol visibility. From e33e6811d308869527d9392b15bb8abd1bcc3864 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 15:57:40 -0800 Subject: [PATCH 30/51] Revert "Run cmake-format." This reverts commit 81d7a7b5b0a1d97d86070c3e0ec352c8217c1b9a. --- python/cmake/set_python_visibility.cmake | 83 +++++++++++++----------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/python/cmake/set_python_visibility.cmake b/python/cmake/set_python_visibility.cmake index 55036a1c7..7fa7b41f2 100644 --- a/python/cmake/set_python_visibility.cmake +++ b/python/cmake/set_python_visibility.cmake @@ -1,50 +1,55 @@ # This code is adapted directly from the scikit-build project under the following license. # The MIT License (MIT) -# +# # Copyright (c) 2014 Mike Sarahan -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -# associated documentation files (the "Software"), to deal in the Software without restriction, -# including without limitation the rights to use, copy, modify, merge, publish, distribute, -# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all copies or -# substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT -# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT -# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# # This project borrows a great deal from the setup tools of the PyNE project. Here is its license: -# +# # Copyright 2011-2014, the PyNE Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# -# 1. Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# +# +# Redistribution and use in source and binary forms, with or without modification, are +# permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# # THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are those of the authors and -# should not be interpreted as representing official policies, either expressed or implied, of the -# stakeholders of the PyNE project or the employers of PyNE developers. +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are those of the +# authors and should not be interpreted as representing official policies, either expressed +# or implied, of the stakeholders of the PyNE project or the employers of PyNE developers. # TODO: Should we guard this based on a scikit-build version? Override this function to avoid # scikit-build clobbering symbol visibility. From 62ed5f005aaec60f8246bdb0199e529d1eb1ddc1 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 15:57:46 -0800 Subject: [PATCH 31/51] Revert "Move scikit-build override to separate helper file and add license." This reverts commit 6951f75e92819e787c5459f5e7faab51804fc504. --- python/CMakeLists.txt | 25 ++++++++ python/cmake/set_python_visibility.cmake | 76 ------------------------ 2 files changed, 25 insertions(+), 76 deletions(-) delete mode 100644 python/cmake/set_python_visibility.cmake diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a307cdd82..cf3e68536 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -35,6 +35,31 @@ option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) +# TODO: Should we guard this based on a scikit-build version? Override this function to avoid +# scikit-build clobbering symbol visibility. +function(_set_python_extension_symbol_visibility _target) + if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) + set(_modinit_prefix "PyInit_") + else() + set(_modinit_prefix "init") + endif() + message("_modinit_prefix:${_modinit_prefix}") + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") + elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) + file( + WRITE ${_script_path} + # Note: The change is to this script, which does not indiscriminately mark all non PyInit + # symbols as local. + "{global: ${_modinit_prefix}${_target}; };") + set_property( + TARGET ${_target} + APPEND_STRING + PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") + endif() +endfunction() + # Ignore unused variable warning. set(ignored_variable "${SKBUILD}") diff --git a/python/cmake/set_python_visibility.cmake b/python/cmake/set_python_visibility.cmake deleted file mode 100644 index 7fa7b41f2..000000000 --- a/python/cmake/set_python_visibility.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# This code is adapted directly from the scikit-build project under the following license. - -# The MIT License (MIT) -# -# Copyright (c) 2014 Mike Sarahan -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# -# This project borrows a great deal from the setup tools of the PyNE project. Here is its license: -# -# Copyright 2011-2014, the PyNE Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are those of the -# authors and should not be interpreted as representing official policies, either expressed -# or implied, of the stakeholders of the PyNE project or the employers of PyNE developers. - -# TODO: Should we guard this based on a scikit-build version? Override this function to avoid -# scikit-build clobbering symbol visibility. -function(_set_python_extension_symbol_visibility _target) - if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) - set(_modinit_prefix "PyInit_") - else() - set(_modinit_prefix "init") - endif() - if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") - elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) - file( - WRITE ${_script_path} - # Note: The change is to this script, which does not indiscriminately mark all non PyInit - # symbols as local. - "{global: ${_modinit_prefix}${_target}; };") - set_property( - TARGET ${_target} - APPEND_STRING - PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") - endif() -endfunction() From 70e3d9ef6e56629321f86fd20fc2045ab9291ec9 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Feb 2022 16:42:19 -0800 Subject: [PATCH 32/51] Update CMake requirement in pyproject.toml. --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index b5e0b800c..de9fcd03e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "setuptools", "cython>=0.29,<0.30", "scikit-build", - "cmake", + "cmake>=3.20.1", "ninja", ] From 7b9679da394146f34cdf2894027aa2065bd1e007 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 11:18:15 -0800 Subject: [PATCH 33/51] Add cmake to meta.yaml and make scikit-build version explicit in pyproject.toml. --- conda/recipes/rmm/meta.yaml | 3 ++- python/pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index c2f1968d2..4baa09085 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -27,7 +27,8 @@ requirements: - python - librmm {{ version }} - setuptools - - cython >=0.29,<0.30 + - cython>=0.29,<0.30 + - cmake>=3.20.1 - scikit-build>=0.13.1 - spdlog>=1.8.5,<2.0.0a0 - cudatoolkit {{ cuda_version }}.* diff --git a/python/pyproject.toml b/python/pyproject.toml index de9fcd03e..5fe11a11e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -18,7 +18,7 @@ requires = [ "wheel", "setuptools", "cython>=0.29,<0.30", - "scikit-build", + "scikit-build>=0.13.1", "cmake>=3.20.1", "ninja", ] From fe444bb923206a40dc932c50fc2b68a6d5548604 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 13:10:45 -0800 Subject: [PATCH 34/51] Disable async support. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 804bbca94..6a8a1046f 100755 --- a/build.sh +++ b/build.sh @@ -178,7 +178,7 @@ if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" export INSTALL_PREFIX echo "building rmm..." - python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=ON + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." From ead4f395d5e93287656228e5b41a9395c3bb0b04 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 13:37:51 -0800 Subject: [PATCH 35/51] Use add_compile_definitions correctly. --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cf3e68536..761ff1503 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -73,7 +73,7 @@ else() endif() if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) - compile_definitions("RMM_DISABLE_CUDA_MALLOC_ASYNC") + add_compile_definitions("RMM_DISABLE_CUDA_MALLOC_ASYNC") endif() if(NOT RMM_FOUND) From 260951ca7c844293c8fbfeb2edacaf9f147ac5dc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 14:18:12 -0800 Subject: [PATCH 36/51] Request verbose output from ninja and make sure to tell the install step to build without async support as well just in case. --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 6a8a1046f..6e9e4074e 100755 --- a/build.sh +++ b/build.sh @@ -178,11 +178,12 @@ if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" export INSTALL_PREFIX echo "building rmm..." - python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -- -v if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." - python setup.py install --single-version-externally-managed --record=record.txt + # TODO: I shouldn't have to pass the flags twice, but just in case I do... + python setup.py install --single-version-externally-managed --record=record.txt -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -- -v fi fi From 9c044d1ecbcb048ca9f6335326113be88232dc9a Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 15:24:55 -0800 Subject: [PATCH 37/51] Selectively disable async APIs and remove unnecessary verbosity. --- build.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 6e9e4074e..128423cff 100755 --- a/build.sh +++ b/build.sh @@ -178,12 +178,16 @@ if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" export INSTALL_PREFIX echo "building rmm..." - python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -- -v + + if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF + else + python setup.py build_ext --inplace + fi if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." - # TODO: I shouldn't have to pass the flags twice, but just in case I do... - python setup.py install --single-version-externally-managed --record=record.txt -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -- -v + python setup.py install --single-version-externally-managed --record=record.txt fi fi From 75995bf2eb1c879106cdeccb5e5012706458adb6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 16:38:37 -0800 Subject: [PATCH 38/51] Clear _skbuild dir to avoid pulling builds from other executors. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 128423cff..de039759e 100755 --- a/build.sh +++ b/build.sh @@ -37,7 +37,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasy default action (no args) is to build and install 'librmm' and 'rmm' targets " LIBRMM_BUILD_DIR=${LIBRMM_BUILD_DIR:=${REPODIR}/build} -RMM_BUILD_DIR=${REPODIR}/python/build +RMM_BUILD_DIR="${REPODIR}/python/build ${REPODIR}/python/_skbuild" BUILD_DIRS="${LIBRMM_BUILD_DIR} ${RMM_BUILD_DIR}" # Set defaults for vars modified by flags to this script From 84fe4abe4aa15820c5f093a6a34f372748f7f81b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 18 Feb 2022 17:45:51 -0800 Subject: [PATCH 39/51] Stop failing on the first test and print some information about where the rmm module is being imported from. --- ci/gpu/build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 8909614cc..0b64f666d 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -130,8 +130,13 @@ else "$WORKSPACE/build.sh" -v rmm gpuci_logger "pytest rmm" - py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x + py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term exitcode=$? + + python -c "import rmm; print(rmm.__file__)" + ls `python -c "import rmm; import os; print(os.path.dirname(rmm.__file__))"` + ls `python -c "import rmm; import os; print(os.path.dirname(rmm.__file__))"`/_lib + if (( ${exitcode} != 0 )); then SUITEERROR=${exitcode} echo "FAILED: 1 or more tests in /rmm/python" From f0ffdec2816fa8a04794bba2c2dfb88602ce91eb Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 22 Feb 2022 12:42:23 -0800 Subject: [PATCH 40/51] Go back to failing on first error to avoid segfault. --- ci/gpu/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 0b64f666d..8fe245581 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -130,7 +130,7 @@ else "$WORKSPACE/build.sh" -v rmm gpuci_logger "pytest rmm" - py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term + py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x exitcode=$? python -c "import rmm; print(rmm.__file__)" From 33f979f73a4a17be39a95c172574ca97cbc35d7c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 22 Feb 2022 13:13:36 -0800 Subject: [PATCH 41/51] Print info before failure. --- ci/gpu/build.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 8fe245581..771b48623 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -129,14 +129,16 @@ else gpuci_logger "Building rmm" "$WORKSPACE/build.sh" -v rmm - gpuci_logger "pytest rmm" - py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x - exitcode=$? + gpuci_logger "printing info" python -c "import rmm; print(rmm.__file__)" ls `python -c "import rmm; import os; print(os.path.dirname(rmm.__file__))"` ls `python -c "import rmm; import os; print(os.path.dirname(rmm.__file__))"`/_lib + gpuci_logger "pytest rmm" + py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x + exitcode=$? + if (( ${exitcode} != 0 )); then SUITEERROR=${exitcode} echo "FAILED: 1 or more tests in /rmm/python" From b374e92e01465ecffb6f626972baa212a2652221 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Mar 2022 10:50:55 -0800 Subject: [PATCH 42/51] Ensure that every package has a different package_data list to avoid referencing the same list when updating. --- python/setup.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/python/setup.py b/python/setup.py index bac70d95e..0fa53b469 100644 --- a/python/setup.py +++ b/python/setup.py @@ -26,10 +26,15 @@ # Include the separately-compiled shared library extras_require={"test": ["pytest", "pytest-xdist"]}, packages=find_packages(include=["rmm", "rmm.*"]), - package_data=dict.fromkeys( - find_packages(include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"]), - ["*.hpp", "*.pxd"], - ), + package_data={ + # Note: A dict comprehension with an explicit copy is necessary (rather + # than something simpler like a dict.fromkeys) because otherwise every + # package will refer to the same list and skbuild modifies it in place. + key: ["*.hpp", "*.pxd"] + for key in find_packages( + include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"] + ) + }, cmdclass=versioneer.get_cmdclass(), install_requires=["numba", "cython", "cuda-python"], zip_safe=False, From 504325f766928188eaa3f9e49b144d998db4e351 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Mar 2022 11:21:13 -0800 Subject: [PATCH 43/51] Remove debugging cruft. --- ci/gpu/build.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 771b48623..8a7a94e22 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -129,16 +129,9 @@ else gpuci_logger "Building rmm" "$WORKSPACE/build.sh" -v rmm - gpuci_logger "printing info" - - python -c "import rmm; print(rmm.__file__)" - ls `python -c "import rmm; import os; print(os.path.dirname(rmm.__file__))"` - ls `python -c "import rmm; import os; print(os.path.dirname(rmm.__file__))"`/_lib - gpuci_logger "pytest rmm" - py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term -x + py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term exitcode=$? - if (( ${exitcode} != 0 )); then SUITEERROR=${exitcode} echo "FAILED: 1 or more tests in /rmm/python" From fa27df85060ff7cc9545b28e92abcf94f61098c0 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Mar 2022 11:22:04 -0800 Subject: [PATCH 44/51] Clean up TODOs. --- python/CMakeLists.txt | 3 ++- python/setup.py | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 761ff1503..d008c626c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -23,7 +23,8 @@ project( # TODO: Building Python extension modules via the python_extension_module requires the C language # to be enabled here. The test project that is built in scikit-build to verify various linking # options for the python library is hardcoded to build with C, so until that is fixed we need to - # keep this. TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to + # keep this. + # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to # CMake 3.22 will also pull in the corresponding required languages even if this project does not # actually require those languages. As a result, we need to include CUDA here. We can remove this # once we upgrade the minimum required CMake version to 3.22. diff --git a/python/setup.py b/python/setup.py index 0fa53b469..feaa29fe5 100644 --- a/python/setup.py +++ b/python/setup.py @@ -5,8 +5,6 @@ import versioneer -# TODO: Need to find a way to enable builds without debug or async like we had -# before with a custom cmdclass. setup( name="rmm", version=versioneer.get_version(), From 0488b8e3f3814e685fffb8d6aa3762f9ec275134 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Mar 2022 11:25:12 -0800 Subject: [PATCH 45/51] Make cmake-lint happy. --- python/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d008c626c..a5a0eeac3 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -23,10 +23,11 @@ project( # TODO: Building Python extension modules via the python_extension_module requires the C language # to be enabled here. The test project that is built in scikit-build to verify various linking # options for the python library is hardcoded to build with C, so until that is fixed we need to - # keep this. + # keep C. + # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to # CMake 3.22 will also pull in the corresponding required languages even if this project does not - # actually require those languages. As a result, we need to include CUDA here. We can remove this + # actually require those languages. As a result, we need to include CUDA here. We can remove CUDA # once we upgrade the minimum required CMake version to 3.22. LANGUAGES C CXX CUDA) From 4867f9708ca00b883ee0d99e3d70a835a7b948a3 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Mar 2022 11:27:40 -0800 Subject: [PATCH 46/51] Make cmake-format happy. --- python/CMakeLists.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a5a0eeac3..8a60bb583 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -20,16 +20,17 @@ set(rmm_version 22.04.00) project( rmm-python VERSION ${rmm_version} - # TODO: Building Python extension modules via the python_extension_module requires the C language - # to be enabled here. The test project that is built in scikit-build to verify various linking - # options for the python library is hardcoded to build with C, so until that is fixed we need to - # keep C. - - # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to - # CMake 3.22 will also pull in the corresponding required languages even if this project does not - # actually require those languages. As a result, we need to include CUDA here. We can remove CUDA - # once we upgrade the minimum required CMake version to 3.22. - LANGUAGES C CXX CUDA) + LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + # language to be enabled here. The test project that is built in scikit-build to verify + # various linking options for the python library is hardcoded to build with C, so until + # that is fixed we need to keep C. + C + CXX + # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to + # CMake 3.22 will also pull in the corresponding required languages even if this project + # does not actually require those languages. As a result, we need to include CUDA here. + # We can remove CUDA once we upgrade the minimum required CMake version to 3.22. + CUDA) option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) From 3bba733eb9614bdff3b88c958b3d3258bd574d58 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Mar 2022 09:33:43 -0800 Subject: [PATCH 47/51] Address PR comments. --- build.sh | 8 ++-- ci/release/update-version.sh | 1 + python/CMakeLists.txt | 25 ---------- python/cmake/CMakeLists.txt | 3 +- ...helpers.cmake => rmm_python_helpers.cmake} | 0 python/cmake/skbuild_patches.cmake | 48 +++++++++++++++++++ 6 files changed, 55 insertions(+), 30 deletions(-) rename python/cmake/{rmm-python-helpers.cmake => rmm_python_helpers.cmake} (100%) create mode 100644 python/cmake/skbuild_patches.cmake diff --git a/build.sh b/build.sh index de039759e..1d3be606c 100755 --- a/build.sh +++ b/build.sh @@ -38,7 +38,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasy " LIBRMM_BUILD_DIR=${LIBRMM_BUILD_DIR:=${REPODIR}/build} RMM_BUILD_DIR="${REPODIR}/python/build ${REPODIR}/python/_skbuild" -BUILD_DIRS="${LIBRMM_BUILD_DIR} ${RMM_BUILD_DIR}" +BUILD_DIR="${LIBRMM_BUILD_DIR} ${RMM_BUILD_DIR}" # Set defaults for vars modified by flags to this script VERBOSE_FLAG="" @@ -157,7 +157,7 @@ if hasArg clean; then if [ -d "${bd}" ]; then find "${bd}" -mindepth 1 -delete rmdir "${bd}" || true - fi + fi done fi @@ -180,9 +180,9 @@ if (( NUMARGS == 0 )) || hasArg rmm; then echo "building rmm..." if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then - python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF else - python setup.py build_ext --inplace + python setup.py build_ext --inplace fi if [[ ${INSTALL_TARGET} != "" ]]; then diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 6b7342961..fcc52922f 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -30,6 +30,7 @@ function sed_runner() { } sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt +sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 8a60bb583..a6442fdc7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -38,31 +38,6 @@ option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) -# TODO: Should we guard this based on a scikit-build version? Override this function to avoid -# scikit-build clobbering symbol visibility. -function(_set_python_extension_symbol_visibility _target) - if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) - set(_modinit_prefix "PyInit_") - else() - set(_modinit_prefix "init") - endif() - message("_modinit_prefix:${_modinit_prefix}") - if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") - elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) - file( - WRITE ${_script_path} - # Note: The change is to this script, which does not indiscriminately mark all non PyInit - # symbols as local. - "{global: ${_modinit_prefix}${_target}; };") - set_property( - TARGET ${_target} - APPEND_STRING - PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") - endif() -endfunction() - # Ignore unused variable warning. set(ignored_variable "${SKBUILD}") diff --git a/python/cmake/CMakeLists.txt b/python/cmake/CMakeLists.txt index dc1608784..9469891ae 100644 --- a/python/cmake/CMakeLists.txt +++ b/python/cmake/CMakeLists.txt @@ -12,4 +12,5 @@ # the License. # ============================================================================= -include(rmm-python-helpers.cmake) +include(rmm_python_helpers.cmake) +include(skbuild_patches.cmake) diff --git a/python/cmake/rmm-python-helpers.cmake b/python/cmake/rmm_python_helpers.cmake similarity index 100% rename from python/cmake/rmm-python-helpers.cmake rename to python/cmake/rmm_python_helpers.cmake diff --git a/python/cmake/skbuild_patches.cmake b/python/cmake/skbuild_patches.cmake new file mode 100644 index 000000000..6302e9e2f --- /dev/null +++ b/python/cmake/skbuild_patches.cmake @@ -0,0 +1,48 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +#[=======================================================================[.rst: +_set_python_extension_symbol_visibility +--------------------------------------- + +The original version of this function in scikit-build runs a linker script to +modify the visibility of symbols. This version is a patch to avoid overwriting +the visibility of symbols because RMM specifically overrides some symbol +visibility in order to share certain functional-local static variables. + +#]=======================================================================] +# TODO: Should we guard this based on a scikit-build version? Override this function to avoid +# scikit-build clobbering symbol visibility. +function(_set_python_extension_symbol_visibility _target) + if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) + set(_modinit_prefix "PyInit_") + else() + set(_modinit_prefix "init") + endif() + message("_modinit_prefix:${_modinit_prefix}") + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") + elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) + file( + WRITE ${_script_path} + # Note: The change is to this script, which does not indiscriminately mark all non PyInit + # symbols as local. + "{global: ${_modinit_prefix}${_target}; };") + set_property( + TARGET ${_target} + APPEND_STRING + PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") + endif() +endfunction() From c6b57bc110e8067f400784e865d732c9a9a5c555 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Mar 2022 10:50:53 -0800 Subject: [PATCH 48/51] Address PR review. --- build.sh | 2 +- python/dev_requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 1d3be606c..dee757fa0 100755 --- a/build.sh +++ b/build.sh @@ -157,7 +157,7 @@ if hasArg clean; then if [ -d "${bd}" ]; then find "${bd}" -mindepth 1 -delete rmdir "${bd}" || true - fi + fi done fi diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt index 0b494bf32..09ad10049 100644 --- a/python/dev_requirements.txt +++ b/python/dev_requirements.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. clang==8.0.1 flake8==3.8.3 From c210bfb3ea850ee13baab1ffab266601955e7f91 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Mar 2022 15:51:31 -0800 Subject: [PATCH 49/51] Add contributing documentation. --- CONTRIBUTING.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5e730cbb0..b47d10c72 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,12 @@ into three categories: 8. Once reviewed and approved, a RAPIDS developer will merge your pull request. Note that for C++ code, two reviewers are required. +To set up a development environment, follow the steps in the [README](https://github.com/rapidsai/cudf/blob/main/README.md) for cloning the repository and creating the conda environment. +Once the environment is created, you can build and install RMM using +```bash +$ python setup.py develop +``` +This command will build the RMM Python library inside the clone and automatically make it importable when running Python anywhere on your machine. Remember, if you are unsure about anything, don't hesitate to comment on issues and ask for clarifications! @@ -52,7 +58,7 @@ implementation of the issue, ask them in the issue instead of the PR. ### Building and Testing on a gpuCI image locally - Before submitting a pull request, you can do a local build and test on your machine that mimics our gpuCI environment using the `ci/local/build.sh` script. +Before submitting a pull request, you can do a local build and test on your machine that mimics our gpuCI environment using the `ci/local/build.sh` script. For detailed information on usage of this script, see [here](ci/local/README.md). ## Attribution From cd796bd617e58cae391db9e67237fca871f7a57c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Mar 2022 15:53:26 -0800 Subject: [PATCH 50/51] Add the prefix path. --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index dee757fa0..4c4198563 100755 --- a/build.sh +++ b/build.sh @@ -180,14 +180,14 @@ if (( NUMARGS == 0 )) || hasArg rmm; then echo "building rmm..." if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then - python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} else - python setup.py build_ext --inplace + python setup.py build_ext --inplace -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} fi if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." - python setup.py install --single-version-externally-managed --record=record.txt + python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} fi fi From f0ac0df8ce1e5f656d7e7172aee7ce20daa9af17 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 11 Mar 2022 11:43:53 -0800 Subject: [PATCH 51/51] Apply suggestions from code review Co-authored-by: Keith Kraus --- CONTRIBUTING.md | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b47d10c72..bd654bef3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,7 @@ into three categories: 8. Once reviewed and approved, a RAPIDS developer will merge your pull request. Note that for C++ code, two reviewers are required. -To set up a development environment, follow the steps in the [README](https://github.com/rapidsai/cudf/blob/main/README.md) for cloning the repository and creating the conda environment. +To set up a development environment, follow the steps in the [README](https://github.com/rapidsai/rmm/blob/main/README.md) for cloning the repository and creating the conda environment. Once the environment is created, you can build and install RMM using ```bash $ python setup.py develop diff --git a/build.sh b/build.sh index 4c4198563..1a83652ad 100755 --- a/build.sh +++ b/build.sh @@ -182,7 +182,7 @@ if (( NUMARGS == 0 )) || hasArg rmm; then if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} else - python setup.py build_ext --inplace -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} + python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} fi if [[ ${INSTALL_TARGET} != "" ]]; then