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

Don't open with O_DIRECT when in compat mode #410

Merged
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
8 changes: 7 additions & 1 deletion cpp/include/kvikio/file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,18 @@ class FileHandle {
_initialized{true},
_compat_mode{compat_mode}
{
if (!_compat_mode) {
return; // Nothing to do in compatibility mode
}

// Try to open the file with the O_DIRECT flag. Fall back to compatibility mode, if it fails.
try {
_fd_direct_on = detail::open_fd(file_path, flags, true, mode);
} catch (const std::system_error&) {
_compat_mode = true; // Fall back to compat mode if we cannot open the file with O_DIRECT
_compat_mode = true;
}

// Create a cuFile handle, if not in compatibility mode
if (!_compat_mode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this condition now that we return early in compat mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice, if _fd_direct_on = detail::open_fd(file_path, flags, true, mode); fails, we set _compat_mode = true thus _compat_mode might be true even though it was false initially

CUfileDescr_t desc{}; // It is important to set to zero!
desc.type = CU_FILE_HANDLE_TYPE_OPAQUE_FD;
Expand Down