Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Jul 23, 2024
1 parent 521a88b commit d795b8f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cpp/include/kvikio/file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,17 @@ class FileHandle {
_compat_mode{compat_mode}
{
if (!_compat_mode) {
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
}
return; // No need to open the file with the O_DIRECT flag 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;
}

// Create a cuFile handle if not in compatibility mode
if (!_compat_mode) {
CUfileDescr_t desc{}; // It is important to set to zero!
desc.type = CU_FILE_HANDLE_TYPE_OPAQUE_FD;
Expand Down

0 comments on commit d795b8f

Please sign in to comment.