Skip to content

Commit

Permalink
Rename distributed_resources to worker_resources
Browse files Browse the repository at this point in the history
Also improve implementation.
  • Loading branch information
oschulz committed Apr 15, 2024
1 parent 47271a7 commit ed7f6f2
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/workers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


const _always_everywhere_code::Expr = quote
import Distributed, ThreadPinning, LinearAlgebra, LegendDataManagement
import LegendDataManagement
end

"""
Expand Down Expand Up @@ -89,22 +89,25 @@ end


"""
LegendDataManagement.distributed_resources
LegendDataManagement.worker_resources
Get the distributed Julia process resources currently available.
"""
function distributed_resources()
resources = Distributed.remotecall_fetch.(
() -> (
workerid = Distributed.myid(),
hostname = Base.gethostname(),
nthreads = Base.Threads.nthreads(),
blas_nthreads = LinearAlgebra.BLAS.get_num_threads(),
cpuids = ThreadPinning.getcpuids()
),
Distributed.workers()
function worker_resources()
resources_ft = Distributed.remotecall.(LegendDataManagement._current_process_resources, Distributed.workers())
resources = fetch.(resources_ft)
sorted_resources = sort(resources, by = x -> x.workerid)
StructArray(sorted_resources)

Check warning on line 100 in src/workers.jl

View check run for this annotation

Codecov / codecov/patch

src/workers.jl#L96-L100

Added lines #L96 - L100 were not covered by tests
end

function _current_process_resources()
return (

Check warning on line 104 in src/workers.jl

View check run for this annotation

Codecov / codecov/patch

src/workers.jl#L103-L104

Added lines #L103 - L104 were not covered by tests
workerid = Distributed.myid(),
hostname = Base.gethostname(),
nthreads = Base.Threads.nthreads(),
blas_nthreads = LinearAlgebra.BLAS.get_num_threads(),
cpuids = ThreadPinning.getcpuids()
)
StructArray(resources)
end


Expand Down Expand Up @@ -144,7 +147,7 @@ legend_addprocs()
remotecall_fetch(get_global_value, last(workers()))
```
See also [`LegendDataManagement.distributed_resources()`](@ref) and
See also [`LegendDataManagement.worker_resources()`](@ref) and
[`LegendDataManagement.shutdown_workers_atexit()`](@ref).
"""
function legend_addprocs end
Expand Down

0 comments on commit ed7f6f2

Please sign in to comment.