Skip to content

Commit

Permalink
Wrap MPI_Get_processor_name function (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano authored Sep 17, 2022
1 parent 1172aa2 commit 6ef9d6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/reference/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MPI.ThreadLevel
```@docs
MPI.Abort
MPI.Init
MPI.Get_processor_name
MPI.Query_thread
MPI.Is_thread_main
MPI.Initialized
Expand Down
16 changes: 16 additions & 0 deletions src/environment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,19 @@ function has_cuda()
return parse(Bool, flag)
end
end

"""
Get_processor_name()
Return the name of the processor, as a `String`.
# External links
$(_doc_external("MPI_Get_processor_name"))
"""
function Get_processor_name()
proc_name = Array{UInt8}(undef, Consts.MPI_MAX_PROCESSOR_NAME)
name_len = Ref{Cint}(0)
@mpicall ccall((:MPI_Get_processor_name, libmpi), Cint, (Ptr{UInt8}, Ptr{Cint}), proc_name, name_len)
@assert name_len[] <= Consts.MPI_MAX_PROCESSOR_NAME
GC.@preserve proc_name unsafe_string(pointer(proc_name))
end
2 changes: 2 additions & 0 deletions test/test_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ include("common.jl")

MPI.Init()

@test MPI.Get_processor_name() == gethostname()

comm = MPI.COMM_WORLD
size = MPI.Comm_size(comm)
rank = MPI.Comm_rank(comm)
Expand Down

0 comments on commit 6ef9d6b

Please sign in to comment.