Skip to content

Commit 2f51fc4

Browse files
authored
deal with vendor=cray but no gtl (#785)
* deal with vendor=cray but no gtl * bump preferences version * fix style
1 parent a71467b commit 2f51fc4

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

lib/MPIPreferences/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MPIPreferences"
22
uuid = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
33
authors = []
4-
version = "0.1.9"
4+
version = "0.1.10"
55

66
[deps]
77
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

lib/MPIPreferences/src/MPIPreferences.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,14 @@ function use_system_binary(;
170170
preloads = []
171171
preloads_env_switch = nothing
172172
cclibs = []
173-
if vendor === nothing
173+
if isnothing(vendor)
174174
elseif vendor == "cray"
175175
cray_pe = CrayParser.analyze_cray_cc()
176176
library_names = [cray_pe.libmpi]
177-
preloads = [cray_pe.libgtl]
177+
# if there is no preload, then set preloads to "nothing" instead of
178+
# "[nothing]" -- the later of which would cause an error when trying to
179+
# dump as toml
180+
preloads = isnothing(cray_pe.libgtl) ? nothing : [cray_pe.libgtl]
178181
preloads_env_switch = cray_pe.gtl_env_switch
179182
cclibs = cray_pe.cclibs
180183
else

lib/MPIPreferences/src/parse_cray_cc.jl

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,59 @@ reduce(f::Function)::Function = Base.Fix1(Base.reduce, f)
66

77
struct CrayPE
88
libmpi::String
9-
libgtl::String
9+
libgtl::Union{String, Nothing}
1010
cclibs::Vector{String}
1111
gtl_env_switch::String
12-
13-
CrayPE(mpi_dl::T, gtl_dl::T, cclibs::Vector{T}) where T <:AbstractString = new(
12+
13+
CrayPE(
14+
mpi_dl::T,
15+
gtl_dl::T,
16+
cclibs::Vector{T}
17+
) where T <:AbstractString = new(
1418
"lib" * mpi_dl * ".so", # Assuming Linux -- CrayPE is only avaialbe for linux anyway
1519
"lib" * gtl_dl * ".so",
1620
cclibs,
1721
"MPICH_GPU_SUPPORT_ENABLED"
1822
)
23+
CrayPE(
24+
mpi_dl::T,
25+
gtl_dl::Nothing,
26+
cclibs::Vector{T}
27+
) where T <:AbstractString = new(
28+
"lib" * mpi_dl * ".so", # Assuming Linux -- CrayPE is only avaialbe for linux anyway
29+
nothing,
30+
cclibs,
31+
"MPICH_GPU_SUPPORT_ENABLED"
32+
)
1933
end
2034

2135
const libmpi_prefix = "mpi_"
2236
const libgtl_prefix = "mpi_gtl_"
2337

38+
function only_or_nothing(iter)
39+
if length(iter) == 0
40+
return nothing
41+
end
42+
only(iter)
43+
end
44+
2445
function cray_mpi(libs)
2546
x = libs |>
26-
filter(x-> startswith(x, libmpi_prefix)) |>
47+
filter(x-> startswith(x, libmpi_prefix)) |>
2748
filter(x->!startswith(x, libgtl_prefix))
2849
return only(x)
2950
end
3051

3152
function cray_gtl(libs)
3253
x = libs |>
33-
filter(x->startswith(x, libmpi_prefix)) |>
54+
filter(x->startswith(x, libmpi_prefix)) |>
3455
filter(x->startswith(x, libgtl_prefix))
35-
return only(x)
56+
return only_or_nothing(x)
3657
end
3758

3859
function other_libs(libs)
3960
x = libs |>
40-
filter(x->!startswith(x, libmpi_prefix)) |>
61+
filter(x->!startswith(x, libmpi_prefix)) |>
4162
filter(x->!startswith(x, libgtl_prefix))
4263
return x
4364
end

0 commit comments

Comments
 (0)