This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
3 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
julia 1.0 | ||
julia 1.1 | ||
CUDAdrv 1.0 | ||
LLVM 0.9.14 | ||
CUDAapi 0.4.0 | ||
|
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,50 @@ | ||
## | ||
# Implements contextual dispatch through Cassette.jl | ||
# Goals: | ||
# - Rewrite common CPU functions to appropriate GPU intrinsics | ||
# | ||
# TODO: | ||
# - error (erf, ...) | ||
# - pow | ||
# - min, max | ||
# - mod, rem | ||
# - gamma | ||
# - bessel | ||
# - distributions | ||
# - unsorted | ||
|
||
using Cassette | ||
|
||
function transform(ctx, ref) | ||
ci = ref.code_info | ||
ci.inlineable = true | ||
return ci | ||
end | ||
const InlinePass = Cassette.@pass transform | ||
|
||
Cassette.@context CUDACtx | ||
const cudactx = Cassette.disablehooks(CUDACtx(pass = InlinePass)) | ||
|
||
function Cassette.overdub(ctx::CUDACtx, ::typeof(isdevice)) | ||
return true | ||
end | ||
|
||
# libdevice.jl | ||
for f in (:cos, :cospi, :sin, :sinpi, :tan, | ||
:acos, :asin, :atan, | ||
:cosh, :sinh, :tanh, | ||
:acosh, :asinh, :atanh, | ||
:log, :log10, :log1p, :log2, | ||
:exp, :exp2, :exp10, :expm1, :ldexp, | ||
:isfinite, :isinf, :isnan, | ||
:signbit, :abs, | ||
:sqrt, :cbrt, | ||
:ceil, :floor,) | ||
@eval function Cassette.overdub(ctx::CUDACtx, ::typeof(Base.$f), x::Union{Float32, Float64}) | ||
@Base._inline_meta | ||
return CUDAnative.$f(x) | ||
end | ||
end | ||
|
||
contextualize(f::F) where F = (args...) -> Cassette.overdub(cudactx, f, args...) | ||
|
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