Skip to content

[WIP] Use FunctionWrappers for custom reduction operators #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
1 change: 1 addition & 0 deletions src/MPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module MPI
using Libdl, Serialization
using Requires
using DocStringExtensions
using FunctionWrappers: FunctionWrapper

export mpiexec, UBuffer, VBuffer

Expand Down
2 changes: 1 addition & 1 deletion src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down