@@ -2,6 +2,7 @@ typealias MPIDatatype Union{Char,
2
2
Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64,
3
3
UInt64,
4
4
Float32, Float64, Complex64, Complex128}
5
+ typealias MPIBuffertype{T} Union{Ptr{T}, Array{T}, Ref{T}}
5
6
6
7
# Define a function mpitype(T) that returns the MPI datatype code for
7
8
# a given type T. The dictonary is defined in __init__ so the module
@@ -196,7 +197,7 @@ function Get_count{T}(stat::Status, ::Type{T})
196
197
Int (count[])
197
198
end
198
199
199
- function Send {T} (buf:: Union{Ptr{T},Array{T} } , count:: Integer ,
200
+ function Send {T} (buf:: MPIBuffertype{T } , count:: Integer ,
200
201
dest:: Integer , tag:: Integer , comm:: Comm )
201
202
ccall (MPI_SEND, Void,
202
203
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
@@ -219,7 +220,7 @@ function send(obj, dest::Integer, tag::Integer, comm::Comm)
219
220
Send (buf, dest, tag, comm)
220
221
end
221
222
222
- function Isend {T} (buf:: Union{Ptr{T},Array{T} } , count:: Integer ,
223
+ function Isend {T} (buf:: MPIBuffertype{T } , count:: Integer ,
223
224
dest:: Integer , tag:: Integer , comm:: Comm )
224
225
rval = Ref {Cint} ()
225
226
ccall (MPI_ISEND, Void,
@@ -244,7 +245,7 @@ function isend(obj, dest::Integer, tag::Integer, comm::Comm)
244
245
Isend (buf, dest, tag, comm)
245
246
end
246
247
247
- function Recv! {T} (buf:: Union{Ptr{T},Array{T} } , count:: Integer ,
248
+ function Recv! {T} (buf:: MPIBuffertype{T } , count:: Integer ,
248
249
src:: Integer , tag:: Integer , comm:: Comm )
249
250
stat = Status ()
250
251
ccall (MPI_RECV, Void,
@@ -273,7 +274,7 @@ function recv(src::Integer, tag::Integer, comm::Comm)
273
274
(MPI. deserialize (buf), stat)
274
275
end
275
276
276
- function Irecv! {T} (buf:: Union{Ptr{T},Array{T} } , count:: Integer ,
277
+ function Irecv! {T} (buf:: MPIBuffertype{T } , count:: Integer ,
277
278
src:: Integer , tag:: Integer , comm:: Comm )
278
279
val = Ref {Cint} ()
279
280
ccall (MPI_IRECV, Void,
@@ -463,7 +464,7 @@ function Barrier(comm::Comm)
463
464
ccall (MPI_BARRIER, Void, (Ptr{Cint},Ptr{Cint}), & comm. val, & 0 )
464
465
end
465
466
466
- function Bcast! {T} (buffer:: Union{Ptr{T},Array{T} } , count:: Integer ,
467
+ function Bcast! {T} (buffer:: MPIBuffertype{T } , count:: Integer ,
467
468
root:: Integer , comm:: Comm )
468
469
ccall (MPI_BCAST, Void,
469
470
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
@@ -501,7 +502,7 @@ function bcast(obj, root::Integer, comm::Comm)
501
502
obj
502
503
end
503
504
504
- function Reduce {T} (sendbuf:: Union{Ptr{T},Array{T} } , count:: Integer ,
505
+ function Reduce {T} (sendbuf:: MPIBuffertype{T } , count:: Integer ,
505
506
op:: Op , root:: Integer , comm:: Comm )
506
507
isroot = Comm_rank (comm) == root
507
508
recvbuf = Array (T, isroot ? count : 0 )
@@ -524,7 +525,7 @@ function Reduce{T}(object::T, op::Op, root::Integer, comm::Comm)
524
525
isroot ? recvbuf[1 ] : nothing
525
526
end
526
527
527
- function Scatter {T} (sendbuf:: Union{Ptr{T},Array{T} } ,
528
+ function Scatter {T} (sendbuf:: MPIBuffertype{T } ,
528
529
count:: Integer , root:: Integer , comm:: Comm )
529
530
recvbuf = Array (T, count)
530
531
ccall (MPI_SCATTER, Void,
@@ -533,7 +534,7 @@ function Scatter{T}(sendbuf::Union{Ptr{T},Array{T}},
533
534
recvbuf
534
535
end
535
536
536
- function Scatterv {T} (sendbuf:: Union{Ptr{T},Array{T} } ,
537
+ function Scatterv {T} (sendbuf:: MPIBuffertype{T } ,
537
538
counts:: Vector{Cint} , root:: Integer ,
538
539
comm:: Comm )
539
540
recvbuf = Array (T, counts[Comm_rank (comm) + 1 ])
@@ -545,7 +546,7 @@ function Scatterv{T}(sendbuf::Union{Ptr{T},Array{T}},
545
546
recvbuf
546
547
end
547
548
548
- function Gather {T} (sendbuf:: Union{Ptr{T},Array{T} } , count:: Integer ,
549
+ function Gather {T} (sendbuf:: MPIBuffertype{T } , count:: Integer ,
549
550
root:: Integer , comm:: Comm )
550
551
isroot = Comm_rank (comm) == root
551
552
recvbuf = Array (T, isroot ? Comm_size (comm) * count : 0 )
@@ -566,7 +567,7 @@ function Gather{T}(object::T, root::Integer, comm::Comm)
566
567
isroot ? recvbuf : nothing
567
568
end
568
569
569
- function Allgather {T} (sendbuf:: Union{Ptr{T},Array{T} } , count:: Integer ,
570
+ function Allgather {T} (sendbuf:: MPIBuffertype{T } , count:: Integer ,
570
571
comm:: Comm )
571
572
recvbuf = Array (T, Comm_size (comm) * count)
572
573
ccall (MPI_ALLGATHER, Void,
@@ -585,7 +586,7 @@ function Allgather{T}(object::T, comm::Comm)
585
586
recvbuf
586
587
end
587
588
588
- function Gatherv {T} (sendbuf:: Union{Ptr{T},Array{T} } , counts:: Vector{Cint} ,
589
+ function Gatherv {T} (sendbuf:: MPIBuffertype{T } , counts:: Vector{Cint} ,
589
590
root:: Integer , comm:: Comm )
590
591
isroot = Comm_rank (comm) == root
591
592
displs = cumsum (counts) - counts
@@ -597,7 +598,7 @@ function Gatherv{T}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
597
598
isroot ? recvbuf : nothing
598
599
end
599
600
600
- function Allgatherv {T} (sendbuf:: Union{Ptr{T},Array{T} } , counts:: Vector{Cint} ,
601
+ function Allgatherv {T} (sendbuf:: MPIBuffertype{T } , counts:: Vector{Cint} ,
601
602
comm:: Comm )
602
603
displs = cumsum (counts) - counts
603
604
sendcnt = counts[Comm_rank (comm) + 1 ]
@@ -608,7 +609,7 @@ function Allgatherv{T}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
608
609
recvbuf
609
610
end
610
611
611
- function Alltoall {T} (sendbuf:: Union{Ptr{T},Array{T} } , count:: Integer ,
612
+ function Alltoall {T} (sendbuf:: MPIBuffertype{T } , count:: Integer ,
612
613
comm:: Comm )
613
614
recvbuf = Array (T, Comm_size (comm)* count)
614
615
ccall (MPI_ALLTOALL, Void,
@@ -617,7 +618,7 @@ function Alltoall{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
617
618
recvbuf
618
619
end
619
620
620
- function Alltoallv {T} (sendbuf:: Union{Ptr{T},Array{T} } , scounts:: Vector{Cint} ,
621
+ function Alltoallv {T} (sendbuf:: MPIBuffertype{T } , scounts:: Vector{Cint} ,
621
622
rcounts:: Vector{Cint} , comm:: Comm )
622
623
recvbuf = Array (T, sum (rcounts))
623
624
sdispls = cumsum (scounts) - scounts
@@ -628,7 +629,7 @@ function Alltoallv{T}(sendbuf::Union{Ptr{T},Array{T}}, scounts::Vector{Cint},
628
629
recvbuf
629
630
end
630
631
631
- function Scan {T} (sendbuf:: Union{Ptr{T},Array{T} } , count:: Integer ,
632
+ function Scan {T} (sendbuf:: MPIBuffertype{T } , count:: Integer ,
632
633
op:: Op , comm:: Comm )
633
634
recvbuf = Array (T, count)
634
635
ccall (MPI_SCAN, Void,
@@ -642,7 +643,7 @@ function Scan{T}(object::T, op::Op, comm::Comm)
642
643
Scan (sendbuf,1 ,op,comm)
643
644
end
644
645
645
- function ExScan {T} (sendbuf:: Union{Ptr{T},Array{T} } , count:: Integer ,
646
+ function ExScan {T} (sendbuf:: MPIBuffertype{T } , count:: Integer ,
646
647
op:: Op , comm:: Comm )
647
648
recvbuf = Array (T, count)
648
649
ccall (MPI_EXSCAN, Void,
0 commit comments