Skip to content

Commit

Permalink
Fix a line number bug in error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcrimsontianyu committed Feb 3, 2025
1 parent 6641f4e commit fe29675
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit fe29675

Please sign in to comment.