Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the default number of threads in KvikIO thread pool to 8 #17126

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cpp/include/cudf/io/config_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include <cudf/utilities/export.hpp>

namespace CUDF_EXPORT cudf {
namespace io::cufile_integration {
namespace io {
namespace cufile_integration {

/**
* @brief Returns true if cuFile and its compatibility mode are enabled.
Expand All @@ -35,9 +36,15 @@ bool is_gds_enabled();
*/
bool is_kvikio_enabled();

} // namespace io::cufile_integration
/**
* @brief Set kvikIO thread pool size according to the environment variable KVIKIO_NTHREADS. If
* KVIKIO_NTHREADS is not set, use 8 threads by default.
*/
void set_thread_pool_nthreads_from_env();

} // namespace cufile_integration

namespace io::nvcomp_integration {
namespace nvcomp_integration {

/**
* @brief Returns true if all nvCOMP uses are enabled.
Expand All @@ -49,5 +56,6 @@ bool is_all_enabled();
*/
bool is_stable_enabled();

} // namespace io::nvcomp_integration
} // namespace nvcomp_integration
} // namespace io
} // namespace CUDF_EXPORT cudf
12 changes: 11 additions & 1 deletion cpp/src/io/utilities/config_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#include <cudf/detail/utilities/logger.hpp>
#include <cudf/utilities/error.hpp>

#include <kvikio/defaults.hpp>

#include <cstdlib>
#include <mutex>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -53,6 +56,14 @@ bool is_gds_enabled() { return is_always_enabled() or get_env_policy() == usage_

bool is_kvikio_enabled() { return get_env_policy() == usage_policy::KVIKIO; }

void set_thread_pool_nthreads_from_env()
{
static std::once_flag flag{};
std::call_once(flag, [] {
auto nthreads = getenv_or<unsigned int>("KVIKIO_NTHREADS", 8U);
kvikio::defaults::thread_pool_nthreads_reset(nthreads);
});
}
} // namespace cufile_integration

namespace nvcomp_integration {
Expand Down Expand Up @@ -81,5 +92,4 @@ bool is_all_enabled() { return get_env_policy() == usage_policy::ALWAYS; }
bool is_stable_enabled() { return is_all_enabled() or get_env_policy() == usage_policy::STABLE; }

} // namespace nvcomp_integration

} // namespace cudf::io
1 change: 1 addition & 0 deletions cpp/src/io/utilities/data_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class file_sink : public data_sink {
if (!_output_stream.is_open()) { detail::throw_on_file_open_failure(filepath, true); }

if (cufile_integration::is_kvikio_enabled()) {
cufile_integration::set_thread_pool_nthreads_from_env();
_kvikio_file = kvikio::FileHandle(filepath, "w");
CUDF_LOG_INFO("Writing a file using kvikIO, with compatibility mode {}.",
_kvikio_file.is_compat_mode_on() ? "on" : "off");
Expand Down
1 change: 1 addition & 0 deletions cpp/src/io/utilities/datasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class file_source : public datasource {
{
detail::force_init_cuda_context();
if (cufile_integration::is_kvikio_enabled()) {
cufile_integration::set_thread_pool_nthreads_from_env();
_kvikio_file = kvikio::FileHandle(filepath);
CUDF_LOG_INFO("Reading a file using kvikIO, with compatibility mode {}.",
_kvikio_file.is_compat_mode_on() ? "on" : "off");
Expand Down
Loading