Skip to content

Commit c7a0ef9

Browse files
authored
Throw an error when using custom reductions on non-Intel platforms (#473)
The error thrown by Julia when getting to closures unsupported on non-Intel platforms is like this: ``` ERROR: LoadError: cfunction: closures are not supported on this platform in expression starting at /path/to/file.jl:line ``` and nothing else, without a full stacktrace, but `/path/to/file.jl:line` is only the top-level frame of the stack. It can take a while to understand where the error is actually coming from especially if several packages are involved, provided that you're willing to debug it, otherwise users are out of luck. This change makes the origin of the error clearer.
1 parent 1ce6399 commit c7a0ef9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/operators.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ end
6969

7070

7171
function Op(f, T=Any; iscommutative=false)
72-
if MPI_LIBRARY == MicrosoftMPI && Sys.WORD_SIZE == 32
72+
@static if MPI_LIBRARY == MicrosoftMPI && Sys.WORD_SIZE == 32
7373
error("User-defined reduction operators are not supported on 32-bit Windows.\nSee https://github.com/JuliaParallel/MPI.jl/issues/246 for more details.")
74+
elseif Sys.ARCH (:aarch64, :ppc64le, :powerpc64le) || startswith(lowercase(String(Sys.ARCH)), "arm")
75+
error("User-defined reduction operators are currently not supported on non-Intel architectures.\nSee https://github.com/JuliaParallel/MPI.jl/issues/404 for more details.")
7476
end
7577
w = OpWrapper{typeof(f),T}(f)
7678
fptr = @cfunction($w, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cint}, Ptr{MPI_Datatype}))
77-
79+
7880
op = Op(OP_NULL.val, fptr)
7981
# int MPI_Op_create(MPI_User_function* user_fn, int commute, MPI_Op* op)
8082
@mpichk ccall((:MPI_Op_create, libmpi), Cint,
@@ -84,4 +86,3 @@ function Op(f, T=Any; iscommutative=false)
8486
finalizer(free, op)
8587
return op
8688
end
87-

0 commit comments

Comments
 (0)