Skip to content

Commit

Permalink
Merge branch 'branch-25.04' into cmake-pin
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice authored Feb 21, 2025
2 parents e6a3860 + fcd84e3 commit 618cb30
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 50 deletions.
15 changes: 8 additions & 7 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ cpp/ @rapidsai/kvikio-cpp-codeowners
python/ @rapidsai/kvikio-python-codeowners

#cmake code owners
**/CMakeLists.txt @rapidsai/kvikio-cmake-codeowners
CMakeLists.txt @rapidsai/kvikio-cmake-codeowners
**/cmake/ @rapidsai/kvikio-cmake-codeowners
*.cmake @rapidsai/kvikio-cmake-codeowners
build.sh @rapidsai/kvikio-cmake-codeowners
python/setup.py @rapidsai/kvikio-cmake-codeowners @rapidsai/kvikio-python-codeowners

#CI code owners
/.github/ @rapidsai/ci-codeowners
/ci/ @rapidsai/ci-codeowners
/.pre-commit-config.yaml @rapidsai/ci-codeowners

#packaging code owners
/.devcontainer/ @rapidsai/packaging-codeowners
/conda/ @rapidsai/packaging-codeowners
/dependencies.yaml @rapidsai/packaging-codeowners
/build.sh @rapidsai/packaging-codeowners
pyproject.toml @rapidsai/packaging-codeowners
/.pre-commit-config.yaml @rapidsai/packaging-codeowners
/.devcontainer/ @rapidsai/packaging-codeowners
/conda/ @rapidsai/packaging-codeowners
dependencies.yaml @rapidsai/packaging-codeowners
/build.sh @rapidsai/packaging-codeowners
pyproject.toml @rapidsai/packaging-codeowners
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
# Copyright (c) 2019-2025, NVIDIA CORPORATION.

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -90,19 +90,22 @@ repos:
^CHANGELOG.md$
)
- repo: https://github.com/rapidsai/pre-commit-hooks
rev: v0.4.0
rev: v0.6.0
hooks:
- id: verify-copyright
files: |
(?x)
[.](cmake|cpp|cu|cuh|h|hpp|sh|pxd|py|pyx)$|
^[.]pre-commit-config[.]yaml$|
CMakeLists[.]txt$|
meta[.]yaml$
exclude: |
(?x)^(
cpp/cmake/Modules/FindCUDAToolkit[.]cmake$
)
- id: verify-alpha-spec
- id: verify-codeowners
args: [--fix, --project-prefix=kvikio]
- repo: https://github.com/rapidsai/dependency-file-generator
rev: v1.17.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- numpy>=1.23,<3.0a0
- numpydoc
- nvcc_linux-aarch64=11.8
- nvcomp==4.1.0.6
- nvcomp==4.2.0.11
- packaging
- pre-commit
- pytest
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies:
- numpy>=1.23,<3.0a0
- numpydoc
- nvcc_linux-64=11.8
- nvcomp==4.1.0.6
- nvcomp==4.2.0.11
- packaging
- pre-commit
- pytest
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-128_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- numcodecs !=0.12.0
- numpy>=1.23,<3.0a0
- numpydoc
- nvcomp==4.1.0.6
- nvcomp==4.2.0.11
- packaging
- pre-commit
- pytest
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-128_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- numcodecs !=0.12.0
- numpy>=1.23,<3.0a0
- numpydoc
- nvcomp==4.1.0.6
- nvcomp==4.2.0.11
- packaging
- pre-commit
- pytest
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/kvikio/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ libcurl_version:
- "==8.5.0"

nvcomp_version:
- "=4.1.0.6"
- "=4.2.0.11"
7 changes: 3 additions & 4 deletions cpp/include/kvikio/defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
#include <stdexcept>
#include <string>

#include <BS_thread_pool.hpp>

#include <kvikio/compat_mode.hpp>
#include <kvikio/shim/cufile.hpp>
#include <kvikio/threadpool_wrapper.hpp>

/**
* @brief KvikIO namespace.
Expand Down Expand Up @@ -60,7 +59,7 @@ CompatMode getenv_or(std::string_view env_var_name, CompatMode default_val);
*/
class defaults {
private:
BS::thread_pool _thread_pool{get_num_threads_from_env()};
BS_thread_pool _thread_pool{get_num_threads_from_env()};
CompatMode _compat_mode;
std::size_t _task_size;
std::size_t _gds_threshold;
Expand Down Expand Up @@ -156,7 +155,7 @@ class defaults {
*
* @return The the default thread pool instance.
*/
[[nodiscard]] static BS::thread_pool& thread_pool();
[[nodiscard]] static BS_thread_pool& thread_pool();

/**
* @brief Get the number of threads in the default thread pool.
Expand Down
4 changes: 3 additions & 1 deletion cpp/include/kvikio/file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class FileHandle {
friend class CompatModeManager;

public:
static constexpr mode_t m644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
// 644 is a common setting of Unix file permissions: read and write for owner, read-only for group
// and others.
static constexpr mode_t m644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
FileHandle() noexcept = default;

/**
Expand Down
16 changes: 8 additions & 8 deletions cpp/include/kvikio/nvtx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ using nvtx_registered_string_type = nvtx3::registered_string_in<libkvikio_domain
} \
}
#define KVIKIO_NVTX_SCOPED_RANGE_IMPL_2(message, payload) \
KVIKIO_NVTX_SCOPED_RANGE_IMPL_3(message, payload, kvikio::nvtx_manager::default_color())
KVIKIO_NVTX_SCOPED_RANGE_IMPL_3(message, payload, kvikio::NvtxManager::default_color())
#define KVIKIO_NVTX_SCOPED_RANGE_SELECTOR(_1, _2, _3, NAME, ...) NAME
#define KVIKIO_NVTX_SCOPED_RANGE_IMPL(...) \
KVIKIO_NVTX_SCOPED_RANGE_SELECTOR( \
Expand All @@ -85,9 +85,9 @@ using nvtx_color_type = int;
/**
* @brief Utility singleton class for NVTX annotation.
*/
class nvtx_manager {
class NvtxManager {
public:
static nvtx_manager& instance() noexcept;
static NvtxManager& instance() noexcept;

/**
* @brief Return the default color.
Expand All @@ -114,13 +114,13 @@ class nvtx_manager {
*/
static void rename_current_thread(std::string_view new_name) noexcept;

nvtx_manager(nvtx_manager const&) = delete;
nvtx_manager& operator=(nvtx_manager const&) = delete;
nvtx_manager(nvtx_manager&&) = delete;
nvtx_manager& operator=(nvtx_manager&&) = delete;
NvtxManager(NvtxManager const&) = delete;
NvtxManager& operator=(NvtxManager const&) = delete;
NvtxManager(NvtxManager&&) = delete;
NvtxManager& operator=(NvtxManager&&) = delete;

private:
nvtx_manager() = default;
NvtxManager() = default;
};

/**
Expand Down
13 changes: 3 additions & 10 deletions cpp/include/kvikio/parallel_operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline const std::pair<const nvtx_color_type&, std::uint64_t> get_next_color_and
{
static std::atomic_uint64_t call_counter{1ull};
auto call_idx = call_counter.fetch_add(1ull, std::memory_order_relaxed);
auto& nvtx_color = nvtx_manager::get_color_by_index(call_idx);
auto& nvtx_color = NvtxManager::get_color_by_index(call_idx);
return {nvtx_color, call_idx};
}

Expand All @@ -57,17 +57,10 @@ std::future<std::size_t> submit_task(F op,
std::size_t file_offset,
std::size_t devPtr_offset,
std::uint64_t nvtx_payload = 0ull,
nvtx_color_type nvtx_color = nvtx_manager::default_color())
nvtx_color_type nvtx_color = NvtxManager::default_color())
{
return defaults::thread_pool().submit_task([=] {
KVIKIO_NVTX_SCOPED_RANGE("task", nvtx_payload, nvtx_color);

// Rename the worker thread in the thread pool to improve clarity from nsys-ui.
// Note: This NVTX feature is currently not supported by nsys-ui.
thread_local std::once_flag call_once_per_thread;
std::call_once(call_once_per_thread,
[] { nvtx_manager::rename_current_thread("thread pool"); });

return op(buf, size, file_offset, devPtr_offset);
});
}
Expand All @@ -94,7 +87,7 @@ std::future<std::size_t> parallel_io(F op,
std::size_t task_size,
std::size_t devPtr_offset,
std::uint64_t call_idx = 0,
nvtx_color_type nvtx_color = nvtx_manager::default_color())
nvtx_color_type nvtx_color = NvtxManager::default_color())
{
if (task_size == 0) { throw std::invalid_argument("`task_size` cannot be zero"); }

Expand Down
57 changes: 57 additions & 0 deletions cpp/include/kvikio/threadpool_wrapper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
*/

#pragma once

#include <functional>

#include <BS_thread_pool.hpp>

#include <kvikio/nvtx.hpp>

namespace kvikio {

template <typename pool_type>
class thread_pool_wrapper : public pool_type {
public:
/**
* @brief Construct a new thread pool wrapper, and invoke a pre-defined initialization function in
* each worker thread.
*
* @param nthreads The number of threads to use.
*/
thread_pool_wrapper(unsigned int nthreads) : pool_type{nthreads, worker_thread_init_func} {}

/**
* @brief Reset the number of threads in the thread pool, and invoke a pre-defined initialization
* function in each worker thread.
*
* @param nthreads The number of threads to use.
*/
void reset(unsigned int nthreads) { pool_type::reset(nthreads, worker_thread_init_func); }

private:
inline static std::function<void()> worker_thread_init_func{[] {
KVIKIO_NVTX_SCOPED_RANGE("worker thread init", 0, NvtxManager::default_color());
// Rename the worker thread in the thread pool to improve clarity from nsys-ui.
// Note: This NVTX feature is currently not supported by nsys-ui.
NvtxManager::rename_current_thread("thread pool");
}};
};

using BS_thread_pool = thread_pool_wrapper<BS::thread_pool>;

} // namespace kvikio
3 changes: 2 additions & 1 deletion cpp/src/bounce_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ AllocRetain::Alloc AllocRetain::get()
// If no available allocation, allocate and register a new one
void* alloc{};
// Allocate page-locked host memory
CUDA_DRIVER_TRY(cudaAPI::instance().MemHostAlloc(&alloc, _size, CU_MEMHOSTREGISTER_PORTABLE));
// Under unified addressing, host memory allocated this way is automatically portable and mapped.
CUDA_DRIVER_TRY(cudaAPI::instance().MemHostAlloc(&alloc, _size, CU_MEMHOSTALLOC_PORTABLE));
return Alloc(this, alloc, _size);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/defaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ bool defaults::is_compat_mode_preferred(CompatMode compat_mode) noexcept

bool defaults::is_compat_mode_preferred() { return is_compat_mode_preferred(compat_mode()); }

BS::thread_pool& defaults::thread_pool() { return instance()->_thread_pool; }
BS_thread_pool& defaults::thread_pool() { return instance()->_thread_pool; }

unsigned int defaults::thread_pool_nthreads() { return thread_pool().get_thread_count(); }

Expand Down
10 changes: 5 additions & 5 deletions cpp/src/nvtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

namespace kvikio {

nvtx_manager& nvtx_manager::instance() noexcept
NvtxManager& NvtxManager::instance() noexcept
{
static nvtx_manager _instance;
static NvtxManager _instance;
return _instance;
}

const nvtx_color_type& nvtx_manager::default_color() noexcept
const nvtx_color_type& NvtxManager::default_color() noexcept
{
#ifdef KVIKIO_CUDA_FOUND
static nvtx_color_type default_color{nvtx3::argb{0, 255, 255, 255}};
Expand All @@ -43,7 +43,7 @@ const nvtx_color_type& nvtx_manager::default_color() noexcept
#endif
}

const nvtx_color_type& nvtx_manager::get_color_by_index(std::uint64_t idx) noexcept
const nvtx_color_type& NvtxManager::get_color_by_index(std::uint64_t idx) noexcept
{
#ifdef KVIKIO_CUDA_FOUND
constexpr std::size_t num_color{16};
Expand Down Expand Up @@ -72,7 +72,7 @@ const nvtx_color_type& nvtx_manager::get_color_by_index(std::uint64_t idx) noexc
#endif
}

void nvtx_manager::rename_current_thread(std::string_view new_name) noexcept
void NvtxManager::rename_current_thread(std::string_view new_name) noexcept
{
#ifdef KVIKIO_CUDA_FOUND
auto tid = syscall(SYS_gettid);
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/test_basic_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include <kvikio/defaults.hpp>
#include <kvikio/file_handle.hpp>
#include "kvikio/defaults.hpp"
#include "utils.hpp"

using namespace kvikio::test;
Expand Down
8 changes: 4 additions & 4 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,20 @@ dependencies:
common:
- output_types: conda
packages:
- nvcomp==4.1.0.6
- nvcomp==4.2.0.11
specific:
- output_types: [requirements, pyproject]
matrices:
- matrix:
cuda: "12.*"
use_cuda_wheels: "true"
packages:
- nvidia-nvcomp-cu12==4.1.0.6
- nvidia-nvcomp-cu12==4.2.0.11
- matrix:
cuda: "11.*"
use_cuda_wheels: "true"
packages:
- nvidia-nvcomp-cu11==4.1.0.6
- nvidia-nvcomp-cu11==4.2.0.11
# if use_cuda_wheels=false is provided, do not add dependencies on any CUDA wheels
# (e.g. for DLFW and pip devcontainers)
- matrix:
Expand All @@ -321,7 +321,7 @@ dependencies:
# (just as a source of documentation, as this populates pyproject.toml in source control)
- matrix:
packages:
- nvidia-nvcomp==4.1.0.6
- nvidia-nvcomp==4.2.0.11
depends_on_libkvikio:
common:
- output_types: conda
Expand Down
12 changes: 12 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ Install the **nightly release** from the ``rapidsai-nightly`` channel like:

If the nightly install doesn't work, set ``channel_priority: flexible`` in your ``.condarc``.


PyPI
----

KvikIO is also available on PyPI. Install the latest release like:

.. code-block::
pip install kvikio-cu11 # for CUDA 11
pip install kvikio-cu12 # for CUDA 12
Build from source
-----------------

Expand Down
Loading

0 comments on commit 618cb30

Please sign in to comment.