Skip to content

Commit

Permalink
Merge pull request #140 from omlins/EnzymeExt
Browse files Browse the repository at this point in the history
Polishing of Enzyme extension
  • Loading branch information
omlins authored Jan 16, 2024
2 parents d49dd44 + 95a3e88 commit a9b025f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ParallelKernel/EnzymeExt/AD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ using ..Exceptions
const ERRMSG_EXTENSION_LOAD_ERROR = "AD: the Enzyme extension was not loaded. Make sure to import Enzyme before ParallelStencil."

init_AD(args...) = return # NOTE: a call will be triggered from @init_parallel_kernel, but it will do nothing if the extension is not loaded. Methods are to be defined in the AD extension modules.
autodiff_deferred!(args...) = @ExtensionLoadError(ERRMSG_EXTENSION_LOAD_ERROR)
autodiff_deferred_thunk!(args...) = @ExtensionLoadError(ERRMSG_EXTENSION_LOAD_ERROR)
autodiff_deferred!(args...) = @NotLoadedError(ERRMSG_EXTENSION_NOT_LOADED)
autodiff_deferred_thunk!(args...) = @NotLoadedError(ERRMSG_EXTENSION_NOT_LOADED)

export autodiff_deferred!, autodiff_deferred_thunk!

Expand Down
10 changes: 5 additions & 5 deletions src/ParallelKernel/Exceptions.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module Exceptions
export @ModuleInternalError, @MethodPluginError, @IncoherentCallError, @NotInitializedError, @ExtensionLoadError, @IncoherentArgumentError, @KeywordArgumentError, @ArgumentEvaluationError, @ArgumentError
export ModuleInternalError, MethodPluginError, IncoherentCallError, NotInitializedError, ExtensionLoadError, IncoherentArgumentError, KeywordArgumentError, ArgumentEvaluationError
export @ModuleInternalError, @MethodPluginError, @IncoherentCallError, @NotInitializedError, @NotLoadedError, @IncoherentArgumentError, @KeywordArgumentError, @ArgumentEvaluationError, @ArgumentError
export ModuleInternalError, MethodPluginError, IncoherentCallError, NotInitializedError, NotLoadedError, IncoherentArgumentError, KeywordArgumentError, ArgumentEvaluationError

macro ModuleInternalError(msg) esc(:(throw(ModuleInternalError($msg)))) end
macro MethodPluginError(msg) esc(:(throw(MethodPluginError($msg)))) end
macro IncoherentCallError(msg) esc(:(throw(IncoherentCallError($msg)))) end
macro NotInitializedError(msg) esc(:(throw(NotInitializedError($msg)))) end
macro ExtensionLoadError(msg) esc(:(throw(ExtensionLoadError($msg)))) end
macro NotLoadedError(msg) esc(:(throw(NotLoadedError($msg)))) end
macro IncoherentArgumentError(msg) esc(:(throw(IncoherentArgumentError($msg)))) end
macro KeywordArgumentError(msg) esc(:(throw(KeywordArgumentError($msg)))) end
macro ArgumentEvaluationError(msg) esc(:(throw(ArgumentEvaluationError($msg)))) end
Expand All @@ -32,10 +32,10 @@ struct NotInitializedError <: Exception
end
Base.showerror(io::IO, e::NotInitializedError) = print(io, "NotInitializedError: ", e.msg)

struct ExtensionLoadError <: Exception
struct NotLoadedError <: Exception
msg::String
end
Base.showerror(io::IO, e::ExtensionLoadError) = print(io, "ExtensionLoadError: ", e.msg)
Base.showerror(io::IO, e::NotLoadedError) = print(io, "NotLoadedError: ", e.msg)

struct IncoherentArgumentError <: Exception
msg::String
Expand Down
2 changes: 1 addition & 1 deletion src/ParallelKernel/ParallelKernel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To see a description of a macro or module type `?<macroname>` (including the `@`
"""
module ParallelKernel

## Include off exception module
## Include of exception module
include("Exceptions.jl");
using .Exceptions

Expand Down

0 comments on commit a9b025f

Please sign in to comment.