Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ PythonCall = "0.9"
Random = "1.10"
Random123 = "1.7"
ReactantCore = "0.1.3"
Reactant_jll = "0.0.27"
Reactant_jll = "0.0.29"
Scratch = "1.2"
Statistics = "1.10"
YaoBlocks = "0.13"
Expand Down
1 change: 1 addition & 0 deletions deps/ReactantExtra/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ cc_library(
"-Wl,-exported_symbol,_RegisterCustomCallTarget",
"-Wl,-exported_symbol,_ConvertLLVMToMLIR",
"-Wl,-exported_symbol,_EnzymeGPUCustomCall",
"-Wl,-exported_symbol,_ReactantThrowError",
]}),
deps = [
"@enzyme//:EnzymeMLIR",
Expand Down
21 changes: 21 additions & 0 deletions src/XLA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ const default_device_idx = Ref{Int}(0)
using Reactant_jll
using Libdl
using Scratch, Downloads

struct ReactantInternalError <: Base.Exception
msg::String
end

function Base.showerror(io::IO, ece::ReactantInternalError)
return print(io, ece.msg, '\n')
end

function reactant_err(msg::Cstring)::Cvoid
throw(ReactantInternalError(Base.unsafe_string(msg)))
end

function __init__()
initLogs = Libdl.dlsym(Reactant_jll.libReactantExtra_handle, "InitializeLogs")
ccall(initLogs, Cvoid, ())
Expand Down Expand Up @@ -136,6 +149,14 @@ function __init__()
cglobal((:EnzymeGPUCustomCall, MLIR.API.mlir_c))::Ptr{Cvoid},
"CUDA"::Cstring,
)::Cvoid

# This wasn't properly exported on macos, we'll remove the try once macOS JLL
# has the fix.
try
errptr = cglobal((:ReactantThrowError, MLIR.API.mlir_c), Ptr{Ptr{Cvoid}})
unsafe_store!(errptr, @cfunction(reactant_err, Cvoid, (Cstring,)))
finally
end
return nothing
end

Expand Down
Loading