Skip to content

Commit 6ef9d6b

Browse files
authored
Wrap MPI_Get_processor_name function (#630)
1 parent 1172aa2 commit 6ef9d6b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

docs/src/reference/environment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MPI.ThreadLevel
1818
```@docs
1919
MPI.Abort
2020
MPI.Init
21+
MPI.Get_processor_name
2122
MPI.Query_thread
2223
MPI.Is_thread_main
2324
MPI.Initialized

src/environment.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,19 @@ function has_cuda()
307307
return parse(Bool, flag)
308308
end
309309
end
310+
311+
"""
312+
Get_processor_name()
313+
314+
Return the name of the processor, as a `String`.
315+
316+
# External links
317+
$(_doc_external("MPI_Get_processor_name"))
318+
"""
319+
function Get_processor_name()
320+
proc_name = Array{UInt8}(undef, Consts.MPI_MAX_PROCESSOR_NAME)
321+
name_len = Ref{Cint}(0)
322+
@mpicall ccall((:MPI_Get_processor_name, libmpi), Cint, (Ptr{UInt8}, Ptr{Cint}), proc_name, name_len)
323+
@assert name_len[] <= Consts.MPI_MAX_PROCESSOR_NAME
324+
GC.@preserve proc_name unsafe_string(pointer(proc_name))
325+
end

test/test_test.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include("common.jl")
22

33
MPI.Init()
44

5+
@test MPI.Get_processor_name() == gethostname()
6+
57
comm = MPI.COMM_WORLD
68
size = MPI.Comm_size(comm)
79
rank = MPI.Comm_rank(comm)

0 commit comments

Comments
 (0)