-
Notifications
You must be signed in to change notification settings - Fork 58
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
Clean up error handling #394
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024, 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 <cstdlib> | ||
#include <filesystem> | ||
#include <string> | ||
|
||
namespace kvikio { | ||
namespace detail { | ||
|
||
[[nodiscard]] inline const std::string lookup_config_path() | ||
{ | ||
const char* env = std::getenv("CUFILE_ENV_PATH_JSON"); | ||
if (env != nullptr && std::filesystem::exists(env)) { return env; } | ||
if (std::filesystem::exists("/etc/cufile.json")) { return "/etc/cufile.json"; } | ||
return std::string(); | ||
} | ||
|
||
} // namespace detail | ||
|
||
/** | ||
* @brief Get the filepath to cuFile's config file (`cufile.json`) or the empty string | ||
* | ||
* This lookup is cached. | ||
* | ||
* @return The filepath to the cufile.json file or the empty string if it isn't found. | ||
*/ | ||
[[nodiscard]] inline const std::string config_path() | ||
{ | ||
static const std::string ret = detail::lookup_config_path(); | ||
return ret; | ||
} | ||
|
||
} // namespace kvikio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is horrible. Is this a documented restriction, or an empirically observed one?
If the former: can we please link to the docs in this comment.
If the latter: can we please open a bug that requests that this "feature" is fixed?
In either case, can we provide a warning when constructing the
config_path
singleton for the first time if a config file was not found, since this is not a discoverable failure mode.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the latter, by default the thread pool isn't enabled, which is required by the stream API.
AFAICT, the conda cufile package doesn't install a config file thus a warning would be triggered always. If we want a warning, we should make sure that the conda and pip package of cufile installs a config file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so if there is no config file, then no thread pool, and therefore no stream.
Alternatively, if there is a config file, then there is a thread pool? Or is it that there is a thread pool by default, and it can be turned off.
If the conda/pip version of cufile doesn't install a default config file (which I am guessing must live in
/etc/cufile.json
), then we need to fix something. But neither of those systems is allowed to write to/etc
, so we would need to have a way to control the "root" location of the default configuration file.But in any case, absence of a default config file should (IMO) result in all defaults being applied, so that there should be no runtime difference between
/etc/cufile.json
exists and is filled with default values and/etc/cufile.json
doesn't exist.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a config file but we do not ship it in $CONDA_PREFIX/etc. Is this desirable? https://github.com/conda-forge/libcufile-feedstock/blob/3c84e7c8ade4501345445ea56691db2767085b94/recipe/build.sh#L7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decision to drop the config file was made here: conda-forge/staged-recipes#21908 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe set
CUFILE_ENV_PATH_JSON
in the conda activation script ifCUFILE_ENV_PATH_JSON
isn't already defined and/etc/cufile.json
doesn't exist?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wence- my guess is that the threadpool is enabled by default in
cufile.json
and disabled in the default value embedded inlibcufile
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that
max_io_threads
andparallel_io
are0
when no config is found.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wence- I suggest we use this for now. Let's think of a more general solution to the
cufile.json
issue in a new PR.Maybe KvikIO should parse the config file to provide more helpful errors and warnings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
Preferably not, if we can avoid it :).