Skip to content

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

wip on streamlining slurm integration #1165

wants to merge 11 commits into from

Conversation

JBlaschke
Copy link
Collaborator

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 the chn (Customer High-Speed Network) adaptor on the HSN:

export REACTANT_COORDINATOR_BIND_ADDRESS=\$(ip -f inet addr show hsn0 | grep chn | awk '/inet / {print \$2}' | cut -d/ -f1):75535

Comment on lines +291 to +292
port = ENV["REACTANT_COORDINATOR_BIND_ADDRESS"] |>
Base.Fix2(split, ":") |> last |> Base.Fix1(parse, Int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
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"])))

Copy link
Collaborator Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
broker_addr = Hostlists.Hostlist(node_list) |> first
broker_addr = first(Hostlists.Hostlist(node_list))

module Hostlists
module SlurmHostlists

import Libdl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
import Libdl
using Libdl: Libdl

Comment on lines +6 to +11
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
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

Copy link
Collaborator Author

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

Comment on lines +13 to +31
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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
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

Copy link
Collaborator Author

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

Comment on lines +102 to +109
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
export string, push!, length
export string, push!, length


export string, push!, length

Base.show(io::IO, x::Hostlist) = print(io, string(x))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
global const Hostlists.Hostlist = SlurmHostlists.Hostlist
const global Hostlists.Hostlist = SlurmHostlists.Hostlist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants