Skip to content

Commit 67ba614

Browse files
authored
Merge pull request #260 from JuliaParallel/sb/window
Update Window functions
2 parents 0140244 + 97eba79 commit 67ba614

File tree

8 files changed

+234
-163
lines changed

8 files changed

+234
-163
lines changed

deps/build.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ MPI_constants = [
4242
# reductions operations
4343
"MPI_OP_NULL",
4444
"MPI_BAND",
45-
"MPI_BOR",
45+
"MPI_BOR",
4646
"MPI_BXOR",
4747
"MPI_LAND",
4848
"MPI_LOR",
@@ -64,6 +64,7 @@ MPI_constants = [
6464
"MPI_MAX_INFO_VAL",
6565
"MPI_INFO_NULL",
6666

67+
6768
# proc
6869
"MPI_PROC_NULL",
6970

@@ -77,6 +78,9 @@ MPI_constants = [
7778
"MPI_LOCK_EXCLUSIVE",
7879
"MPI_LOCK_SHARED",
7980

81+
# window
82+
"MPI_WIN_NULL",
83+
8084
# misc constants
8185
"MPI_ANY_SOURCE",
8286
"MPI_ANY_TAG",

src/MPI.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ end
1818
include(depfile)
1919

2020
include("mpi-base.jl")
21+
include("mpi-window.jl")
2122
include("cman.jl")
2223
include("deprecated.jl")
2324

src/deprecated.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@ const FINALIZE_ATEXIT = Ref(true)
1111
@deprecate Info_free(info::Info) free(info) false
1212

1313

14+
# window functions
15+
@deprecate(Win_create(base::Array{T}, info::Info, comm::Comm, win::Win) where {T},
16+
(win = Win_create(base, comm; info...)), false)
17+
18+
@deprecate(Win_create_dynamic(info::Info, comm::Comm, win::Win),
19+
(win = Win_create_dynamic(comm; info...)), false)
20+
21+
@deprecate(Win_allocate_shared(::Type{T}, len::Int, info::Info, comm::Comm, win::Win) where T,
22+
((win, ptr) = Win_allocate_shared(T, len, comm; info...); ptr), false)
23+
24+
@deprecate Win_free(win::Win) free(win) false

src/mpi-base.jl

Lines changed: 0 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ Get_error(stat::Status) = Int(stat.val[MPI_ERROR])
139139
Get_source(stat::Status) = Int(stat.val[MPI_SOURCE])
140140
Get_tag(stat::Status) = Int(stat.val[MPI_TAG])
141141

142-
mutable struct Win
143-
val::Cint
144-
Win() = new(0)
145-
end
146-
147142
struct LockType
148143
val::Cint
149144
end
@@ -1667,133 +1662,6 @@ function Exscan(object::T, op::Op, comm::Comm) where T
16671662
Exscan(sendbuf,1,op,comm)
16681663
end
16691664

1670-
function Win_create(base::Array{T}, info::Info, comm::Comm, win::Win) where T
1671-
out_win = Ref(win.val)
1672-
ccall(MPI_WIN_CREATE, Nothing,
1673-
(Ptr{T}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1674-
base, Cptrdiff_t(length(base)*sizeof(T)), sizeof(T), info.val, comm.val, out_win, 0)
1675-
win.val = out_win[]
1676-
end
1677-
1678-
function Win_create_dynamic(info::Info, comm::Comm, win::Win)
1679-
out_win = Ref(win.val)
1680-
ccall(MPI_WIN_CREATE_DYNAMIC, Nothing,
1681-
(Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1682-
info.val, comm.val, out_win, 0)
1683-
win.val = out_win[]
1684-
end
1685-
1686-
function Win_allocate_shared(::Type{T}, len::Int, info::Info, comm::Comm, win::Win) where T
1687-
out_win = Ref(win.val)
1688-
out_baseptr = Ref{Ptr{T}}()
1689-
ccall(MPI_WIN_ALLOCATE_SHARED, Nothing,
1690-
(Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Ptr{T}}, Ref{Cint}, Ref{Cint}),
1691-
Cptrdiff_t(len*sizeof(T)), sizeof(T), info.val, comm.val, out_baseptr, out_win, 0)
1692-
win.val = out_win[]
1693-
out_baseptr[]
1694-
end
1695-
1696-
function Win_shared_query(win::Win, owner_rank::Int)
1697-
out_len = Ref{Cptrdiff_t}()
1698-
out_sizeT = Ref{Cint}()
1699-
out_baseptr = Ref{Ptr{Cvoid}}()
1700-
ccall(MPI_WIN_SHARED_QUERY, Nothing,
1701-
(Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Ptr{Cvoid}}, Ref{Cint}),
1702-
win.val, owner_rank, out_len, out_sizeT, out_baseptr, 0)
1703-
out_len[], out_sizeT[], out_baseptr[]
1704-
end
1705-
1706-
function Win_attach(win::Win, base::Array{T}) where T
1707-
ccall(MPI_WIN_ATTACH, Nothing,
1708-
(Ref{Cint}, Ptr{T}, Ref{Cptrdiff_t}, Ref{Cint}),
1709-
win.val, base, Cptrdiff_t(sizeof(base)), 0)
1710-
end
1711-
1712-
function Win_detach(win::Win, base::Array{T}) where T
1713-
ccall(MPI_WIN_DETACH, Nothing,
1714-
(Ref{Cint}, Ptr{T}, Ref{Cint}),
1715-
win.val, base, 0)
1716-
end
1717-
1718-
function Win_fence(assert::Integer, win::Win)
1719-
ccall(MPI_WIN_FENCE, Nothing, (Ref{Cint}, Ref{Cint}, Ref{Cint}), assert, win.val, 0)
1720-
end
1721-
1722-
function Win_flush(rank::Integer, win::Win)
1723-
ccall(MPI_WIN_FLUSH, Nothing, (Ref{Cint}, Ref{Cint}, Ref{Cint}), rank, win.val, 0)
1724-
end
1725-
1726-
function Win_free(win::Win)
1727-
ccall(MPI_WIN_FREE, Nothing, (Ref{Cint}, Ref{Cint}), win.val, 0)
1728-
end
1729-
1730-
function Win_sync(win::Win)
1731-
ccall(MPI_WIN_SYNC, Nothing, (Ref{Cint}, Ref{Cint}), win.val, 0)
1732-
end
1733-
1734-
function Win_sync(win::CWin)
1735-
ccall((:MPI_Win_sync, libmpi), Nothing, (CWin,), win)
1736-
end
1737-
1738-
function Win_lock(lock_type::LockType, rank::Integer, assert::Integer, win::Win)
1739-
ccall(MPI_WIN_LOCK, Nothing,
1740-
(Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1741-
lock_type.val, rank, assert, win.val, 0)
1742-
end
1743-
1744-
function Win_unlock(rank::Integer, win::Win)
1745-
ccall(MPI_WIN_UNLOCK, Nothing, (Ref{Cint}, Ref{Cint}, Ref{Cint}), rank, win.val, 0)
1746-
end
1747-
1748-
function Get(origin_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, win::Win) where T
1749-
ccall(MPI_GET, Nothing,
1750-
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1751-
origin_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), win.val, 0)
1752-
end
1753-
function Get(origin_buffer::Array{T}, target_rank::Integer, win::Win) where T
1754-
count = length(origin_buffer)
1755-
Get(origin_buffer, count, target_rank, 0, win)
1756-
end
1757-
function Get(origin_value::Ref{T}, target_rank::Integer, win::Win) where T
1758-
Get(origin_value, 1, target_rank, 0, win)
1759-
end
1760-
1761-
function Put(origin_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, win::Win) where T
1762-
ccall(MPI_PUT, Nothing,
1763-
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1764-
origin_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), win.val, 0)
1765-
end
1766-
function Put(origin_buffer::Array{T}, target_rank::Integer, win::Win) where T
1767-
count = length(origin_buffer)
1768-
Put(origin_buffer, count, target_rank, 0, win)
1769-
end
1770-
function Put(origin_value::Ref{T}, target_rank::Integer, win::Win) where T
1771-
Put(origin_value, 1, target_rank, 0, win)
1772-
end
1773-
1774-
function Fetch_and_op(sourceval::MPIBuffertype{T}, returnval::MPIBuffertype{T}, target_rank::Integer, target_disp::Integer, op::Op, win::Win) where T
1775-
ccall(MPI_FETCH_AND_OP, Nothing,
1776-
(Ptr{T}, Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1777-
sourceval, returnval, mpitype(T), target_rank, Cptrdiff_t(target_disp), op.val, win.val, 0)
1778-
end
1779-
1780-
function Fetch_and_op(sourceval::MPIBuffertype{T}, returnval::MPIBuffertype{T}, target_rank::Integer, target_disp::Integer, op::Op, win::CWin) where T
1781-
ccall((:MPI_Fetch_and_op, libmpi), Nothing,
1782-
(Ptr{T}, Ptr{T}, Cint, Cint, Cptrdiff_t, Cint, CWin),
1783-
sourceval, returnval, mpitype(T), target_rank, target_disp, op.val, win)
1784-
end
1785-
1786-
function Accumulate(origin_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, op::Op, win::Win) where T
1787-
ccall(MPI_ACCUMULATE, Nothing,
1788-
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1789-
origin_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), op.val, win.val, 0)
1790-
end
1791-
1792-
function Get_accumulate(origin_buffer::MPIBuffertype{T}, result_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, op::Op, win::Win) where T
1793-
ccall(MPI_GET_ACCUMULATE, Nothing,
1794-
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
1795-
origin_buffer, count, mpitype(T), result_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), op.val, win.val, 0)
1796-
end
17971665

17981666
function Get_address(location::MPIBuffertype{T}) where T
17991667
addr = Ref{Cptrdiff_t}(0)
@@ -1881,12 +1749,6 @@ if HAVE_MPI_COMM_C2F
18811749
function Info(cinfo::CInfo)
18821750
Info(ccall((:MPI_Info_c2f, libmpi), Cint, (CInfo,), cinfo))
18831751
end
1884-
function CWin(win::Win)
1885-
ccall((:MPI_Win_f2c, libmpi), CWin, (Cint,), win.val)
1886-
end
1887-
function Win(cwin::CWin)
1888-
Win(ccall((:MPI_Win_c2f, libmpi), Cint, (CWin,), cwin))
1889-
end
18901752
elseif sizeof(CComm) == sizeof(Cint)
18911753
# in MPICH, both C and Fortran use identical Cint comm handles
18921754
# and MPI_Comm_c2f is not provided.
@@ -1902,12 +1764,6 @@ elseif sizeof(CComm) == sizeof(Cint)
19021764
function Info(cinfo::CInfo)
19031765
Info(reinterpret(Cint, cinfo))
19041766
end
1905-
function CWin(win::Win)
1906-
reinterpret(CWin, win.val)
1907-
end
1908-
function Win(cwin::CWin)
1909-
Win(reinterpret(Cint, cwin))
1910-
end
19111767
else
19121768
@warn("No MPI_Comm_c2f found - conversion to/from MPI.CComm will not work")
19131769
end

0 commit comments

Comments
 (0)