Skip to content

Commit

Permalink
add support for choosing system UCX (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored Feb 26, 2021
1 parent 3c43174 commit d06ae15
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions deps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deps.jl
45 changes: 45 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Libdl

if haskey(ENV, "JULIA_SYSTEM_UCX")
@info "using system UCX"

paths = String[]
if haskey(ENV, "JULIA_UCX_LIBPATH")
push!(paths,)
libucp = ENV["JULIA_UCP_LIB"]
else
libucp = Libdl.find_library(["libucp"], [])
libucs = Libdl.find_library(["libucs"], [])
@debug "UCX paths" libucp libucs
if isempty(libucs) || isempty(libucp)
error("Did not find UCX libraries, please set the JULIA_UCX_LIBPATH environment variable.")
end
end

deps = quote
const libucp = $libucp
const libucs = $libucs
end
else
deps = quote
import UCX_jll: libucp, libucs
end
end

remove_line_numbers(x) = x
function remove_line_numbers(ex::Expr)
if ex.head == :macrocall
ex.args[2] = nothing
else
ex.args = [remove_line_numbers(arg) for arg in ex.args if !(arg isa LineNumberNode)]
end
return ex
end

# only update deps.jl if it has changed.
# allows users to call Pkg.build("FluxRM") without triggering another round of precompilation
deps_str = string(remove_line_numbers(deps))

if !isfile("deps.jl") || deps_str != read("deps.jl", String)
write("deps.jl", deps_str)
end
3 changes: 2 additions & 1 deletion src/api.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module API
using UCX_jll
include(joinpath(@__DIR__, "..", "deps", "deps.jl"))

using CEnum
include(joinpath("api", "ctypes.jl"))

Expand Down

0 comments on commit d06ae15

Please sign in to comment.