-
-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy patherrorhandler.jl
77 lines (64 loc) · 2.41 KB
/
errorhandler.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""
MPI.ErrorHandler
An MPI error handler object. Currently only two are supported:
- `ERRORS_ARE_FATAL` (default): program will immediately abort
- `ERRORS_RETURN`: program will throw an `MPIError`.
"""
@mpi_handle ErrorHandler MPI_Errhandler
const ERRORS_ARE_FATAL = _ErrorHandler(MPI_ERRORS_ARE_FATAL)
const ERRORS_RETURN = _ErrorHandler(MPI_ERRORS_RETURN)
function free(errh::ErrorHandler)
if !Finalized()
# int MPI_Errhandler_free(MPI_Errhandler *errhandler)
@mpichk ccall((:MPI_Errhandler_free, libmpi), Cint, (Ptr{MPI_Errhandler},), errh)
end
return nothing
end
function set_default_errhandler_return()
set_errhandler!(COMM_SELF, ERRORS_RETURN)
set_errhandler!(COMM_WORLD, ERRORS_RETURN)
end
"""
MPI.get_errhandler(comm::MPI.Comm)
MPI.get_errhandler(win::MPI.Win)
MPI.get_errhandler(file::MPI.File.FileHandle)
Get the current [`ErrorHandler`](@ref) for the relevant MPI object.
# See also
- [`set_errhandler!`](@ref)
"""
function get_errhandler(comm::Comm)
errh = ErrorHandler(ERRORS_ARE_FATAL.val)
@mpichk ccall((:MPI_Comm_get_errhandler, libmpi), Cint, (MPI_Comm, Ptr{MPI_Errhandler}), comm, errh)
finalizer(free, errh)
return errh
end
function get_errhandler(win::Win)
errh = v(ERRORS_ARE_FATAL.val)
@mpichk ccall((:MPI_Win_get_errhandler, libmpi), Cint, (MPI_Win, Ptr{MPI_Errhandler}), win, errh)
return errh
end
function get_errhandler(file::File.FileHandle)
errh = ErrorHandler(ERRORS_ARE_FATAL.val)
@mpichk ccall((:MPI_File_get_errhandler, libmpi), Cint, (MPI_File, Ptr{MPI_Errhandler}), file, errh)
return errh
end
"""
MPI.set_errhandler!(comm::MPI.Comm, errh::Errhandler)
MPI.set_errhandler!(win::MPI.Win, errh::Errhandler)
MPI.set_errhandler!(file::MPI.File.FileHandle, errh::Errhandler)
Set the [`ErrorHandler`](@ref) for the relevant MPI object.
# See also
- [`get_errhandler`](@ref)
"""
function set_errhandler!(comm::Comm, errh::ErrorHandler)
@mpichk ccall((:MPI_Comm_set_errhandler, libmpi), Cint, (MPI_Comm, MPI_Errhandler), comm, errh)
return nothing
end
function set_errhandler!(win::Win, errh::ErrorHandler)
@mpichk ccall((:MPI_Win_set_errhandler, libmpi), Cint, (MPI_Win, MPI_Errhandler), win, errh)
return nothing
end
function set_errhandler!(file::File.FileHandle, errh::ErrorHandler)
@mpichk ccall((:MPI_File_set_errhandler, libmpi), Cint, (MPI_File, MPI_Errhandler), file, errh)
return nothing
end