Skip to content

Commit

Permalink
deal with vendor=cray but no gtl (#785)
Browse files Browse the repository at this point in the history
* deal with vendor=cray but no gtl

* bump preferences version

* fix style
  • Loading branch information
JBlaschke authored Nov 3, 2023
1 parent a71467b commit 2f51fc4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/MPIPreferences/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MPIPreferences"
uuid = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
authors = []
version = "0.1.9"
version = "0.1.10"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand Down
7 changes: 5 additions & 2 deletions lib/MPIPreferences/src/MPIPreferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,14 @@ function use_system_binary(;
preloads = []
preloads_env_switch = nothing
cclibs = []
if vendor === nothing
if isnothing(vendor)
elseif vendor == "cray"
cray_pe = CrayParser.analyze_cray_cc()
library_names = [cray_pe.libmpi]
preloads = [cray_pe.libgtl]
# if there is no preload, then set preloads to "nothing" instead of
# "[nothing]" -- the later of which would cause an error when trying to
# dump as toml
preloads = isnothing(cray_pe.libgtl) ? nothing : [cray_pe.libgtl]
preloads_env_switch = cray_pe.gtl_env_switch
cclibs = cray_pe.cclibs
else
Expand Down
35 changes: 28 additions & 7 deletions lib/MPIPreferences/src/parse_cray_cc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,59 @@ reduce(f::Function)::Function = Base.Fix1(Base.reduce, f)

struct CrayPE
libmpi::String
libgtl::String
libgtl::Union{String, Nothing}
cclibs::Vector{String}
gtl_env_switch::String

CrayPE(mpi_dl::T, gtl_dl::T, cclibs::Vector{T}) where T <:AbstractString = new(

CrayPE(
mpi_dl::T,
gtl_dl::T,
cclibs::Vector{T}
) where T <:AbstractString = new(
"lib" * mpi_dl * ".so", # Assuming Linux -- CrayPE is only avaialbe for linux anyway
"lib" * gtl_dl * ".so",
cclibs,
"MPICH_GPU_SUPPORT_ENABLED"
)
CrayPE(
mpi_dl::T,
gtl_dl::Nothing,
cclibs::Vector{T}
) where T <:AbstractString = new(
"lib" * mpi_dl * ".so", # Assuming Linux -- CrayPE is only avaialbe for linux anyway
nothing,
cclibs,
"MPICH_GPU_SUPPORT_ENABLED"
)
end

const libmpi_prefix = "mpi_"
const libgtl_prefix = "mpi_gtl_"

function only_or_nothing(iter)
if length(iter) == 0
return nothing
end
only(iter)
end

function cray_mpi(libs)
x = libs |>
filter(x-> startswith(x, libmpi_prefix)) |>
filter(x-> startswith(x, libmpi_prefix)) |>
filter(x->!startswith(x, libgtl_prefix))
return only(x)
end

function cray_gtl(libs)
x = libs |>
filter(x->startswith(x, libmpi_prefix)) |>
filter(x->startswith(x, libmpi_prefix)) |>
filter(x->startswith(x, libgtl_prefix))
return only(x)
return only_or_nothing(x)
end

function other_libs(libs)
x = libs |>
filter(x->!startswith(x, libmpi_prefix)) |>
filter(x->!startswith(x, libmpi_prefix)) |>
filter(x->!startswith(x, libgtl_prefix))
return x
end
Expand Down

0 comments on commit 2f51fc4

Please sign in to comment.