-
Notifications
You must be signed in to change notification settings - Fork 20
wip on streamlining slurm integration #1165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
port = ENV["REACTANT_COORDINATOR_BIND_ADDRESS"] |> | ||
Base.Fix2(split, ":") |> last |> Base.Fix1(parse, Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
port = ENV["REACTANT_COORDINATOR_BIND_ADDRESS"] |> | |
Base.Fix2(split, ":") |> last |> Base.Fix1(parse, Int) | |
port = | |
Base.Fix1(parse, Int)(last(Base.Fix2(split, ":")(ENV["REACTANT_COORDINATOR_BIND_ADDRESS"]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
someone doesn't like the pipe syntax....
end | ||
node_list = ENV[_SLURM_NODELIST] | ||
@debug "Setup coordinator: node_list=$(node_list)" | ||
broker_addr = Hostlists.Hostlist(node_list) |> first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
broker_addr = Hostlists.Hostlist(node_list) |> first | |
broker_addr = first(Hostlists.Hostlist(node_list)) |
module Hostlists | ||
module SlurmHostlists | ||
|
||
import Libdl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
import Libdl | |
using Libdl: Libdl |
const libslurm = Libdl.find_library(["libslurm"]) | ||
if !("" == libslurm) | ||
# We need to dlopen libslurm with RTLD_GLOBAL to make sure that all | ||
# dependencies are loaded correctly. | ||
Libdl.dlopen(libslurm, Libdl.RTLD_GLOBAL) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
const libslurm = Libdl.find_library(["libslurm"]) | |
if !("" == libslurm) | |
# We need to dlopen libslurm with RTLD_GLOBAL to make sure that all | |
# dependencies are loaded correctly. | |
Libdl.dlopen(libslurm, Libdl.RTLD_GLOBAL) | |
end | |
const libslurm = Libdl.find_library(["libslurm"]) | |
if !("" == libslurm) | |
# We need to dlopen libslurm with RTLD_GLOBAL to make sure that all | |
# dependencies are loaded correctly. | |
Libdl.dlopen(libslurm, Libdl.RTLD_GLOBAL) | |
end | |
const hostlist_t = Ptr{Nothing} | |
function slurm_hostlist_create(hostlist) | |
@ccall libslurm.slurm_hostlist_create(hostlist::Cstring)::hostlist_t | |
end | |
function slurm_hostlist_count(hl::hostlist_t) | |
@ccall libslurm.slurm_hostlist_count(hl::hostlist_t)::Cint | |
end | |
function slurm_hostlist_destroy(hl::hostlist_t) | |
@ccall libslurm.slurm_hostlist_destroy(hl::hostlist_t)::Cvoid | |
end | |
function slurm_hostlist_find(hl::hostlist_t, hostname) | |
@ccall libslurm.slurm_hostlist_find(hl::hostlist_t, hostname::Cstring)::Cint | |
end | |
function slurm_hostlist_push(hl::hostlist_t, hosts) | |
@ccall libslurm.slurm_hostlist_push(hl::hostlist_t, hosts::Cstring)::Cint | |
end | |
function slurm_hostlist_push_host(hl::hostlist_t, host) | |
@ccall libslurm.slurm_hostlist_push_host(hl::hostlist_t, host::Cstring)::Cint | |
end | |
function slurm_hostlist_ranged_string(hl::hostlist_t, n::Csize_t, buf) | |
@ccall libslurm.slurm_hostlist_ranged_string( | |
hl::hostlist_t, n::Csize_t, buf::Ptr{UInt8} | |
)::Cssize_t | |
end | |
function slurm_hostlist_shift(hl::hostlist_t) | |
@ccall libslurm.slurm_hostlist_shift(hl::hostlist_t)::Cstring | |
end | |
function slurm_hostlist_uniq(hl::hostlist_t) | |
@ccall libslurm.slurm_hostlist_uniq(hl::hostlist_t)::Cvoid | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this, but probably fine
const hostlist_t = Ptr{Nothing} | ||
|
||
slurm_hostlist_create(hostlist) = @ccall libslurm.slurm_hostlist_create(hostlist::Cstring)::hostlist_t | ||
slurm_hostlist_count(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_count(hl::hostlist_t)::Cint | ||
slurm_hostlist_destroy(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_destroy(hl::hostlist_t)::Cvoid | ||
slurm_hostlist_find(hl::hostlist_t, hostname) = @ccall libslurm.slurm_hostlist_find(hl::hostlist_t, hostname::Cstring)::Cint | ||
slurm_hostlist_push(hl::hostlist_t, hosts) = @ccall libslurm.slurm_hostlist_push(hl::hostlist_t,hosts::Cstring)::Cint | ||
slurm_hostlist_push_host(hl::hostlist_t, host) = @ccall libslurm.slurm_hostlist_push_host(hl::hostlist_t, host::Cstring)::Cint | ||
slurm_hostlist_ranged_string(hl::hostlist_t, n::Csize_t, buf) = @ccall libslurm.slurm_hostlist_ranged_string(hl::hostlist_t, n::Csize_t, buf::Ptr{UInt8})::Cssize_t | ||
slurm_hostlist_shift(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_shift(hl::hostlist_t)::Cstring | ||
slurm_hostlist_uniq(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_uniq(hl::hostlist_t)::Cvoid | ||
|
||
mutable struct Hostlist | ||
hlist::hostlist_t | ||
|
||
function Hostlist(node_list::String) | ||
slurm_hl = slurm_hostlist_create(node_list) | ||
if slurm_hl == C_NULL | ||
error("Could not allocate memory for hostlist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
const hostlist_t = Ptr{Nothing} | |
slurm_hostlist_create(hostlist) = @ccall libslurm.slurm_hostlist_create(hostlist::Cstring)::hostlist_t | |
slurm_hostlist_count(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_count(hl::hostlist_t)::Cint | |
slurm_hostlist_destroy(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_destroy(hl::hostlist_t)::Cvoid | |
slurm_hostlist_find(hl::hostlist_t, hostname) = @ccall libslurm.slurm_hostlist_find(hl::hostlist_t, hostname::Cstring)::Cint | |
slurm_hostlist_push(hl::hostlist_t, hosts) = @ccall libslurm.slurm_hostlist_push(hl::hostlist_t,hosts::Cstring)::Cint | |
slurm_hostlist_push_host(hl::hostlist_t, host) = @ccall libslurm.slurm_hostlist_push_host(hl::hostlist_t, host::Cstring)::Cint | |
slurm_hostlist_ranged_string(hl::hostlist_t, n::Csize_t, buf) = @ccall libslurm.slurm_hostlist_ranged_string(hl::hostlist_t, n::Csize_t, buf::Ptr{UInt8})::Cssize_t | |
slurm_hostlist_shift(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_shift(hl::hostlist_t)::Cstring | |
slurm_hostlist_uniq(hl::hostlist_t) = @ccall libslurm.slurm_hostlist_uniq(hl::hostlist_t)::Cvoid | |
mutable struct Hostlist | |
hlist::hostlist_t | |
function Hostlist(node_list::String) | |
slurm_hl = slurm_hostlist_create(node_list) | |
if slurm_hl == C_NULL | |
error("Could not allocate memory for hostlist.") | |
mutable struct Hostlist | |
hlist::hostlist_t | |
function Hostlist(node_list::String) | |
slurm_hl = slurm_hostlist_create(node_list) | |
if slurm_hl == C_NULL | |
error("Could not allocate memory for hostlist.") | |
end | |
hl = new(slurm_hl) | |
finalizer(delete, hl) | |
return hl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, not sure but probably fine
Base.convert(::Type{String}, hl::Hostlist) = join(hl.hlist, ",") | ||
Base.string(hl::Hostlist) = Base.convert(String, hl) | ||
function Base.push!(x::Hostlist, y::String) | ||
push!(x.hlist, y) | ||
x.hlist = x.hlist |> x->filter(!isempty, x) |> unique! | ||
x | ||
end | ||
Base.length(x::Hostlist) = length(x.hlist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Base.convert(::Type{String}, hl::Hostlist) = join(hl.hlist, ",") | |
Base.string(hl::Hostlist) = Base.convert(String, hl) | |
function Base.push!(x::Hostlist, y::String) | |
push!(x.hlist, y) | |
x.hlist = x.hlist |> x->filter(!isempty, x) |> unique! | |
x | |
end | |
Base.length(x::Hostlist) = length(x.hlist) | |
Base.convert(::Type{String}, hl::Hostlist) = join(hl.hlist, ",") | |
Base.string(hl::Hostlist) = Base.convert(String, hl) | |
function Base.push!(x::Hostlist, y::String) | |
push!(x.hlist, y) | |
x.hlist = (x -> unique!(filter(!isempty, x)))(x.hlist) | |
return x | |
end | |
Base.length(x::Hostlist) = length(x.hlist) |
end | ||
Base.length(x::Hostlist) = length(x.hlist) | ||
|
||
export string, push!, length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
export string, push!, length | |
export string, push!, length |
|
||
export string, push!, length | ||
|
||
Base.show(io::IO, x::Hostlist) = print(io, string(x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Base.show(io::IO, x::Hostlist) = print(io, string(x)) | |
Base.show(io::IO, x::Hostlist) = print(io, string(x)) |
function __init__() | ||
if "" == SlurmHostlists.libslurm | ||
@debug "libslurm.so not found, using SimpleHostlists" | ||
global const Hostlists.Hostlist = SimpleHostlists.Hostlist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
global const Hostlists.Hostlist = SimpleHostlists.Hostlist | |
const global Hostlists.Hostlist = SimpleHostlists.Hostlist |
global const Hostlists.Hostlist = SimpleHostlists.Hostlist | ||
else | ||
@debug "libslurm.so found, using SlurmHostlists" | ||
global const Hostlists.Hostlist = SlurmHostlists.Hostlist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
global const Hostlists.Hostlist = SlurmHostlists.Hostlist | |
const global Hostlists.Hostlist = SlurmHostlists.Hostlist |
Long term we'll want to use https://github.com/JuliaParallel/NetworkInterfaceControllers.jl -- however to make progress right now, I just copied the slurm integration into
src/extern
.The way this ends up being used (at the moment -- again we'll make it better) is to set
REACTANT_COORDINATOR_BIND_ADDRESS
. Eg. on Perlmutter we want to use thechn
(Customer High-Speed Network) adaptor on the HSN: