forked from eth-cscs/ImplicitGlobalGrid.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eth-cscs#83 from eth-cscs/LoopVectorizationExt
Use extension for LoopVectorization dependency
- Loading branch information
Showing
9 changed files
with
103 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module ImplicitGlobalGrid_LoopVectorizationExt | ||
include(joinpath(@__DIR__, "..", "src", "LoopVectorizationExt", "memcopy_LV.jl")) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Exceptions | ||
export @ModuleInternalError, @IncoherentCallError, @NotInitializedError, @NotLoadedError, @IncoherentArgumentError, @KeywordArgumentError, @ArgumentEvaluationError, @ArgumentError | ||
export ModuleInternalError, IncoherentCallError, NotInitializedError, NotLoadedError, IncoherentArgumentError, KeywordArgumentError, ArgumentEvaluationError | ||
|
||
macro ModuleInternalError(msg) esc(:(throw(ModuleInternalError($msg)))) end | ||
macro IncoherentCallError(msg) esc(:(throw(IncoherentCallError($msg)))) end | ||
macro NotInitializedError(msg) esc(:(throw(NotInitializedError($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 | ||
macro ArgumentError(msg) esc(:(throw(ArgumentError($msg)))) end | ||
|
||
struct ModuleInternalError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::ModuleInternalError) = print(io, "ModuleInternalError: ", e.msg) | ||
|
||
struct IncoherentCallError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::IncoherentCallError) = print(io, "IncoherentCallError: ", e.msg) | ||
|
||
struct NotInitializedError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::NotInitializedError) = print(io, "NotInitializedError: ", e.msg) | ||
|
||
struct NotLoadedError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::NotLoadedError) = print(io, "NotLoadedError: ", e.msg) | ||
|
||
struct IncoherentArgumentError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::IncoherentArgumentError) = print(io, "IncoherentArgumentError: ", e.msg) | ||
|
||
struct KeywordArgumentError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::KeywordArgumentError) = print(io, "KeywordArgumentError: ", e.msg) | ||
|
||
struct ArgumentEvaluationError <: Exception | ||
msg::String | ||
end | ||
Base.showerror(io::IO, e::ArgumentEvaluationError) = print(io, "ArgumentEvaluationError: ", e.msg) | ||
|
||
end # Module Exceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ImplicitGlobalGrid | ||
import ImplicitGlobalGrid: GGNumber | ||
using LoopVectorization | ||
|
||
function ImplicitGlobalGrid.memcopy_loopvect!(dst::AbstractArray{T}, src::AbstractArray{T}) where T <: GGNumber | ||
@tturbo for i ∈ eachindex(dst, src) # NOTE: tturbo will use maximally Threads.nthreads() threads. Set the number of threads e.g. as: export JULIA_NUM_THREADS=12. NOTE: tturbo fails if src_flat and dst_flat are used due to an issue in ArrayInterface : https://github.com/JuliaArrays/ArrayInterface.jl/issues/228 | ||
@inbounds dst[i] = src[i] # NOTE: We fix here exceptionally the use of @inbounds (currently anyways done by LoopVectorization) as this copy between two flat vectors (which must have the right length) is considered safe. | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const ERRMSG_EXTENSION_NOT_LOADED = "AD: the LoopVectorization extension was not loaded. Make sure to import LoopVectorization before ImplicitGlobalGrid." | ||
|
||
memcopy_loopvect!(args...) = @NotLoadedError(ERRMSG_EXTENSION_NOT_LOADED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters