Skip to content

Commit

Permalink
Merge branch 'branch-25.04' into use_rapids-generate-version_again
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham authored Feb 20, 2025
2 parents 6a99b49 + 77da587 commit 99e0b86
Show file tree
Hide file tree
Showing 24 changed files with 1,563 additions and 332 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# kvikio 25.02.00 (13 Feb 2025)

## 🚨 Breaking Changes

- Continue to make KvikIO a shared library by moving code from hpp to cpp ([#581](https://github.com/rapidsai/kvikio/pull/581)) [@kingcrimsontianyu](https://github.com/kingcrimsontianyu)

## 🐛 Bug Fixes

- Set `POSITION_INDEPENDENT_CODE` on libcurl ([#625](https://github.com/rapidsai/kvikio/pull/625)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA)
- allow deselecting nvcomp wheels ([#589](https://github.com/rapidsai/kvikio/pull/589)) [@jameslamb](https://github.com/jameslamb)
- Fix the misplaced libcurl in CMake ([#587](https://github.com/rapidsai/kvikio/pull/587)) [@kingcrimsontianyu](https://github.com/kingcrimsontianyu)

## 🚀 New Features

- Remove upper bounds on cuda-python to allow 12.6.2 and 11.8.5 ([#564](https://github.com/rapidsai/kvikio/pull/564)) [@bdice](https://github.com/bdice)

## 🛠️ Improvements

- Use `rapids-pip-retry` in CI jobs that might need retries ([#619](https://github.com/rapidsai/kvikio/pull/619)) [@gforsyth](https://github.com/gforsyth)
- Use std::string ([#617](https://github.com/rapidsai/kvikio/pull/617)) [@madsbk](https://github.com/madsbk)
- Revert CUDA 12.8 shared workflow branch changes ([#609](https://github.com/rapidsai/kvikio/pull/609)) [@vyasr](https://github.com/vyasr)
- Build and test with CUDA 12.8.0 ([#600](https://github.com/rapidsai/kvikio/pull/600)) [@bdice](https://github.com/bdice)
- Separate more interface and definition. Add comments on std::future. Mark noexcept to compat mode-related functions ([#588](https://github.com/rapidsai/kvikio/pull/588)) [@kingcrimsontianyu](https://github.com/kingcrimsontianyu)
- Use GCC 13 in CUDA 12 conda builds. ([#586](https://github.com/rapidsai/kvikio/pull/586)) [@bdice](https://github.com/bdice)
- Zarr: pin to version 2.* ([#583](https://github.com/rapidsai/kvikio/pull/583)) [@madsbk](https://github.com/madsbk)
- Continue to make KvikIO a shared library by moving code from hpp to cpp ([#581](https://github.com/rapidsai/kvikio/pull/581)) [@kingcrimsontianyu](https://github.com/kingcrimsontianyu)
- Check if nightlies have succeeded recently enough ([#579](https://github.com/rapidsai/kvikio/pull/579)) [@vyasr](https://github.com/vyasr)
- Update cuda-python lower bounds to 12.6.2 / 11.8.5 ([#573](https://github.com/rapidsai/kvikio/pull/573)) [@bdice](https://github.com/bdice)
- Improve compatibility mode consistency ([#567](https://github.com/rapidsai/kvikio/pull/567)) [@kingcrimsontianyu](https://github.com/kingcrimsontianyu)
- Require approval to run CI on draft PRs ([#563](https://github.com/rapidsai/kvikio/pull/563)) [@bdice](https://github.com/bdice)
- Add breaking change workflow trigger ([#536](https://github.com/rapidsai/kvikio/pull/536)) [@AyodeAwe](https://github.com/AyodeAwe)
- Add Initial Java Support for GDS to KvikIO ([#396](https://github.com/rapidsai/kvikio/pull/396)) [@aslobodaNV](https://github.com/aslobodaNV)

# kvikio 24.12.00 (11 Dec 2024)

## 🚨 Breaking Changes
Expand Down
16 changes: 7 additions & 9 deletions ci/test_java.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.
# Copyright (c) 2024-2025, NVIDIA CORPORATION.

set -euo pipefail

. /opt/conda/etc/profile.d/conda.sh

rapids-logger "Downloading artifacts from previous jobs"
CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp)

rapids-logger "Generate java testing dependencies"
rapids-dependency-file-generator \
--output conda \
--file-key test_java \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" \
--prepend-channel "${CPP_CHANNEL}" \
| tee env.yaml

rapids-mamba-retry env create --yes -f env.yaml -n test

Expand All @@ -18,15 +23,8 @@ set +u
conda activate test
set -u

rapids-logger "Downloading artifacts from previous jobs"
CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp)

rapids-print-env

rapids-mamba-retry install \
--channel "${CPP_CHANNEL}" \
libkvikio

rapids-logger "Check GPU usage"
nvidia-smi

Expand Down
2 changes: 2 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ set(SOURCES
"src/batch.cpp"
"src/bounce_buffer.cpp"
"src/buffer.cpp"
"src/compat_mode.cpp"
"src/cufile/config.cpp"
"src/cufile/driver.cpp"
"src/defaults.cpp"
"src/error.cpp"
"src/file_handle.cpp"
"src/file_utils.cpp"
"src/nvtx.cpp"
"src/posix_io.cpp"
"src/shim/cuda.cpp"
"src/shim/cufile.cpp"
Expand Down
2 changes: 1 addition & 1 deletion cpp/doxygen/main_page.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ When KvikIO is running in compatibility mode, it doesn't load `libcufile.so`. In

The environment variable `KVIKIO_COMPAT_MODE` has three options (case-insensitive):
- `ON` (aliases: `TRUE`, `YES`, `1`): Enable the compatibility mode.
- `OFF` (aliases: `FALSE`, `NO`, `0`): Disable the compatibility mode, and enforce cuFile I/O. GDS will be activated if the system requirements for cuFile are met and cuFile is properly configured. However, if the system is not suited for cuFile, I/O operations under the `OFF` option may error out, crash or hang.
- `OFF` (aliases: `FALSE`, `NO`, `0`): Disable the compatibility mode, and enforce cuFile I/O. GDS will be activated if the system requirements for cuFile are met and cuFile is properly configured. However, if the system is not suited for cuFile, I/O operations under the `OFF` option may error out.
- `AUTO`: Try cuFile I/O first, and fall back to POSIX I/O if the system requirements for cuFile are not met.

Under `AUTO`, KvikIO falls back to the compatibility mode:
Expand Down
150 changes: 150 additions & 0 deletions cpp/include/kvikio/compat_mode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* 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 <cstdint>
#include <string>

#include <kvikio/file_utils.hpp>

namespace kvikio {
/**
* @brief I/O compatibility mode.
*/
enum class CompatMode : uint8_t {
OFF, ///< Enforce cuFile I/O. GDS will be activated if the system requirements for cuFile are met
///< and cuFile is properly configured. However, if the system is not suited for cuFile, I/O
///< operations under the OFF option may error out.
ON, ///< Enforce POSIX I/O.
AUTO, ///< Try cuFile I/O first, and fall back to POSIX I/O if the system requirements for cuFile
///< are not met.
};

namespace detail {
/**
* @brief Parse a string into a CompatMode enum.
*
* @param compat_mode_str Compatibility mode in string format (case-insensitive). Valid values
* are:
* - `ON` (alias: `TRUE`, `YES`, `1`)
* - `OFF` (alias: `FALSE`, `NO`, `0`)
* - `AUTO`
* @return A CompatMode enum.
*/
CompatMode parse_compat_mode_str(std::string_view compat_mode_str);

} // namespace detail

// Forward declaration.
class FileHandle;

/**
* @brief Store and manage the compatibility mode data associated with a FileHandle.
*/
class CompatModeManager {
private:
CompatMode _compat_mode_requested{CompatMode::AUTO};
bool _is_compat_mode_preferred{true};
bool _is_compat_mode_preferred_for_async{true};

public:
/**
* @brief Construct an empty compatibility mode manager.
*/
CompatModeManager() noexcept = default;

/**
* @brief Construct a compatibility mode manager associated with a FileHandle.
*
* According to the file path, requested compatibility mode, and the system configuration, the
* compatibility manager:
* - Infers the final compatibility modes for synchronous and asynchronous I/O paths,
* respectively.
* - Initializes the file wrappers and cuFile handle associated with a FileHandle.
*
* @param file_path Refer to
* FileHandle::FileHandle(std::string const&, std::string const&, mode_t, CompatMode).
* @param flags Same as above.
* @param mode Same as above.
* @param compat_mode_requested Same as above.
* @param file_handle Pointer to the FileHandle object that owns this compatibility mode manager.
*/
CompatModeManager(std::string const& file_path,
std::string const& flags,
mode_t mode,
CompatMode compat_mode_requested,
FileHandle* file_handle);

~CompatModeManager() noexcept = default;
CompatModeManager(const CompatModeManager&) = default;
CompatModeManager& operator=(const CompatModeManager&) = default;
CompatModeManager(CompatModeManager&&) noexcept = default;
CompatModeManager& operator=(CompatModeManager&&) noexcept = default;

/**
* @brief Functionally identical to defaults::infer_compat_mode_if_auto(CompatMode).
*
* @param compat_mode Compatibility mode.
* @return If the given compatibility mode is CompatMode::AUTO, infer the final compatibility
* mode.
*/
CompatMode infer_compat_mode_if_auto(CompatMode compat_mode) noexcept;

/**
* @brief Functionally identical to defaults::is_compat_mode_preferred(CompatMode).
*
* @param compat_mode Compatibility mode.
* @return Boolean answer.
*/
bool is_compat_mode_preferred(CompatMode compat_mode) noexcept;

/**
* @brief Check if the compatibility mode for synchronous I/O of the associated FileHandle is
* expected to be CompatMode::ON.
*
* @return Boolean answer.
*/
bool is_compat_mode_preferred() const noexcept;

/**
* @brief Check if the compatibility mode for asynchronous I/O of the associated FileHandle is
* expected to be CompatMode::ON.
*
* @return Boolean answer.
*/
bool is_compat_mode_preferred_for_async() const noexcept;

/**
* @brief Retrieve the original compatibility mode requested.
*
* @return The original compatibility mode requested.
*/
CompatMode compat_mode_requested() const noexcept;

/**
* @brief Determine if asynchronous I/O can be performed or not (throw exceptions)
* according to the existing compatibility mode data in the manager.
*
* Asynchronous I/O cannot be performed, for instance, when compat_mode_requested() is
* CompatMode::OFF, is_compat_mode_preferred() is CompatMode::OFF, but
* is_compat_mode_preferred_for_async() is CompatMode::ON (due to missing cuFile stream API or
* cuFile configuration file).
*/
void validate_compat_mode_for_async() const;
};

} // namespace kvikio
33 changes: 3 additions & 30 deletions cpp/include/kvikio/defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
* limitations under the License.
*/

// Enable documentation of the enum.
/**
* @file
*/

#pragma once

#include <cstddef>
Expand All @@ -29,35 +24,13 @@

#include <BS_thread_pool.hpp>

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

namespace kvikio {
/**
* @brief I/O compatibility mode.
* @brief KvikIO namespace.
*/
enum class CompatMode : uint8_t {
OFF, ///< Enforce cuFile I/O. GDS will be activated if the system requirements for cuFile are met
///< and cuFile is properly configured. However, if the system is not suited for cuFile, I/O
///< operations under the OFF option may error out, crash or hang.
ON, ///< Enforce POSIX I/O.
AUTO, ///< Try cuFile I/O first, and fall back to POSIX I/O if the system requirements for cuFile
///< are not met.
};

namespace detail {
/**
* @brief Parse a string into a CompatMode enum.
*
* @param compat_mode_str Compatibility mode in string format(case-insensitive). Valid values
* include:
* - `ON` (alias: `TRUE`, `YES`, `1`)
* - `OFF` (alias: `FALSE`, `NO`, `0`)
* - `AUTO`
* @return A CompatMode enum.
*/
CompatMode parse_compat_mode_str(std::string_view compat_mode_str);

} // namespace detail
namespace kvikio {

template <typename T>
T getenv_or(std::string_view env_var_name, T default_val)
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/kvikio/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <cstring>
#include <exception>
#include <string>
#include <system_error>

#include <kvikio/shim/cuda.hpp>
Expand Down Expand Up @@ -71,7 +72,7 @@ void cuda_driver_try_2(CUresult error, int line_number, char const* filename)
{
if (error == CUDA_ERROR_STUB_LIBRARY) {
throw Exception{std::string{"CUDA error at: "} + std::string(filename) + ":" +
KVIKIO_STRINGIFY(line_number) +
std::to_string(line_number) +
": CUDA_ERROR_STUB_LIBRARY("
"The CUDA driver loaded is a stub library)"};
}
Expand All @@ -82,9 +83,8 @@ void cuda_driver_try_2(CUresult error, int line_number, char const* filename)
CUresult err_str_status = cudaAPI::instance().GetErrorString(error, &err_str);
if (err_name_status == CUDA_ERROR_INVALID_VALUE) { err_name = "unknown"; }
if (err_str_status == CUDA_ERROR_INVALID_VALUE) { err_str = "unknown"; }
throw Exception{std::string{"CUDA error at: "} + filename + ":" +
KVIKIO_STRINGIFY(line_number) + ": " + std::string(err_name) + "(" +
std::string(err_str) + ")"};
throw Exception{std::string{"CUDA error at: "} + filename + ":" + std::to_string(line_number) +
": " + std::string(err_name) + "(" + std::string(err_str) + ")"};
}
}

Expand All @@ -97,7 +97,7 @@ void cufile_try_2(CUfileError_t error, int line_number, char const* filename)
CUDA_DRIVER_TRY(cuda_error);
}
throw Exception{std::string{"cuFile error at: "} + filename + ":" +
KVIKIO_STRINGIFY(line_number) + ": " +
std::to_string(line_number) + ": " +
cufileop_status_error((CUfileOpError)std::abs(error.err))};
}
}
Expand All @@ -111,7 +111,7 @@ void cufile_check_bytes_done_2(ssize_t nbytes_done, int line_number, char const*
? std::string(cufileop_status_error((CUfileOpError)err))
: std::string(std::strerror(err));
throw Exception{std::string{"cuFile error at: "} + filename + ":" +
KVIKIO_STRINGIFY(line_number) + ": " + msg};
std::to_string(line_number) + ": " + msg};
}
}

Expand Down
Loading

0 comments on commit 99e0b86

Please sign in to comment.