diff --git a/Project.toml b/Project.toml index 36641fa12..4a53752e9 100644 --- a/Project.toml +++ b/Project.toml @@ -6,6 +6,7 @@ version = "0.20-dev" [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" MPICH_jll = "7cb0a576-ebde-5e09-9194-50597f1243b4" MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267" @@ -18,6 +19,7 @@ Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" [compat] DocStringExtensions = "0.8, 0.9" +FunctionWrappers = "1.1.2" MPIPreferences = "0.1.3" Requires = "~0.5, 1.0" julia = "1.6" diff --git a/src/MPI.jl b/src/MPI.jl index fd0485cfa..993db060c 100644 --- a/src/MPI.jl +++ b/src/MPI.jl @@ -3,6 +3,7 @@ module MPI using Libdl, Serialization using Requires using DocStringExtensions +using FunctionWrappers: FunctionWrapper export mpiexec, UBuffer, VBuffer diff --git a/src/operators.jl b/src/operators.jl index 38a3e8ec9..894d82c4e 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -95,7 +95,7 @@ function Op(f, T=Any; iscommutative=false) 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.") end w = OpWrapper{typeof(f),T}(f) - fptr = @cfunction($w, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cint}, Ptr{MPI_Datatype})) + fptr = FunctionWrapper{Cvoid,Tuple{Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cint}, Ptr{MPI_Datatype}}}(w).ptr op = Op(OP_NULL.val, fptr) # int MPI_Op_create(MPI_User_function* user_fn, int commute, MPI_Op* op)