uncomplicate.clojurecuda.internal.utils
Utility functions used as helpers in other ClojureCUDA namespaces. The user of the ClojureCUDA library would probably not need to use any of the functions defined here.
error
(error err-code details)
(error err-code)
Converts an CUDA error code to an ExceptionInfo (http://clojuredocs.org/clojure.core/ex-info) with richer, user-friendly information.
Accepts a long err-code
that should be one of the codes defined in CUDA standard, and an optional details
argument that could be anything that you think is informative.
Also see the discussion about
Examples:
(error 0) => an ExceptionInfo instance
(error -5 {:comment "Why here?""}) => an ExceptionInfo instance
maybe
macro
(maybe form)
Evaluates form in try/catch block; if a CUDA-related exception is caught, substitutes the result with the ExceptionInfo object.
with-check
macro
(with-check status form)
(with-check status details form)
Evaluates form
if status
is not zero (:success
), otherwise throws an appropriate ExceptionInfo
with decoded informative details. It helps fith CUDA methods that return error codes directly, while returning computation results through side-effects in arguments.
Example:
(with-check (some-jcuda-call-that-returns-error-code) result)