From c1fb3ffbd6e013787f1175a9825b95e7c1b3a7de Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Sun, 24 Mar 2024 19:36:08 -0400 Subject: [PATCH] Update error.jl and management.jl --- src/error.jl | 14 ++++++-------- src/management.jl | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/error.jl b/src/error.jl index f6423d1..bc5c4c1 100644 --- a/src/error.jl +++ b/src/error.jl @@ -9,8 +9,7 @@ Base.showerror(io::IO, err::CUDSSError) = name(err::CUDSSError) = string(err.code) -## COV_EXCL_START -function description(err) +function description(err::CUDSSError) if err.code == CUDSS_STATUS_SUCCESS return "the operation completed successfully" elseif err.code == CUDSS_STATUS_NOT_INITIALIZED @@ -43,14 +42,13 @@ end end end -function check(f, errs...) - res = retry_reclaim(in((CUDSS_STATUS_ALLOC_FAILED, errs...))) do - return f() - end +@inline function check(f) + retry_if(res) = res in (CUDSS_STATUS_NOT_INITIALIZED, + CUDSS_STATUS_ALLOC_FAILED, + CUDSS_STATUS_INTERNAL_ERROR) + res = retry_reclaim(f, retry_if) if res != CUDSS_STATUS_SUCCESS throw_api_error(res) end - - return end diff --git a/src/management.jl b/src/management.jl index 671d794..375a5ac 100644 --- a/src/management.jl +++ b/src/management.jl @@ -2,9 +2,7 @@ function cudssCreate() handle = Ref{cudssHandle_t}() - check(CUDSS_STATUS_NOT_INITIALIZED) do - unsafe_cudssCreate(handle) - end + cudssCreate(handle) handle[] end