Skip to content

Commit

Permalink
Lapacke: add layer of error handling, not perfect as some errors are …
Browse files Browse the repository at this point in the history
…triggered in Fortran lapack layer and just halt execution
  • Loading branch information
adegomme committed Feb 24, 2025
1 parent 681df23 commit 87361b6
Show file tree
Hide file tree
Showing 2 changed files with 921 additions and 556 deletions.
26 changes: 26 additions & 0 deletions src/lapack/backends/armpl/armpl_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,32 @@ constexpr auto cast_to_int_if_complex(const T& alpha) {
}
}

class armpl_lapacke_error : virtual public std::runtime_error {
protected:
// Lapacke errors are already reported by a printf in lapacke_xerbla, so this may be redundant.
inline std::string lapacke_error_message(std::int64_t info) {
if (info == LAPACK_WORK_MEMORY_ERROR) {
return std::string("Not enough memory to allocate work array\n");
}
else if (info == LAPACK_TRANSPOSE_MEMORY_ERROR) {
return std::string("Not enough memory to transpose matrix\n");
}
else if (info < 0) {
return std::string("Wrong parameter number " + std::to_string(-info));
}
else {
return std::string("Runtime error\n");
}
}

public:
explicit armpl_lapacke_error(std::string func, std::int64_t result)
: std::runtime_error("Arm Performance Libraries backend: LAPACKE error in " + func +
": " + std::string(lapacke_error_message(result))) {}

virtual ~armpl_lapacke_error() throw() {}
};

} // namespace armpl
} // namespace lapack
} // namespace math
Expand Down
Loading

0 comments on commit 87361b6

Please sign in to comment.