@@ -2,7 +2,7 @@ const MPIDatatype = Union{Char,
2
2
Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64,
3
3
UInt64,
4
4
Float32, Float64, Complex64, Complex128}
5
- MPIBuffertype{T} = Union{Ptr{T}, Array{T}, Ref{T}}
5
+ MPIBuffertype{T} = Union{Ptr{T}, Array{T}, SubArray{T}, Ref{T}}
6
6
7
7
fieldoffsets (:: Type{T} ) where {T} = Int[fieldoffset (T, i) for i in 1 : nfields (T)]
8
8
@@ -354,6 +354,12 @@ function Send(buf::Array{T}, dest::Integer, tag::Integer,
354
354
Send (buf, length (buf), dest, tag, comm)
355
355
end
356
356
357
+ function Send (buf:: SubArray{T} , dest:: Integer , tag:: Integer ,
358
+ comm:: Comm ) where T
359
+ @assert Base. iscontiguous (buf)
360
+ Send (buf, length (buf), dest, tag, comm)
361
+ end
362
+
357
363
function Send (obj:: T , dest:: Integer , tag:: Integer , comm:: Comm ) where T
358
364
buf = [obj]
359
365
Send (buf, dest, tag, comm)
@@ -379,6 +385,12 @@ function Isend(buf::Array{T}, dest::Integer, tag::Integer,
379
385
Isend (buf, length (buf), dest, tag, comm)
380
386
end
381
387
388
+ function Isend (buf:: SubArray{T} , dest:: Integer , tag:: Integer ,
389
+ comm:: Comm ) where T
390
+ @assert Base. iscontiguous (buf)
391
+ Isend (buf, length (buf), dest, tag, comm)
392
+ end
393
+
382
394
function Isend (obj:: T , dest:: Integer , tag:: Integer , comm:: Comm ) where T
383
395
buf = [obj]
384
396
Isend (buf, dest, tag, comm)
@@ -404,6 +416,12 @@ function Recv!(buf::Array{T}, src::Integer, tag::Integer,
404
416
Recv! (buf, length (buf), src, tag, comm)
405
417
end
406
418
419
+ function Recv! (buf:: SubArray{T} , src:: Integer , tag:: Integer ,
420
+ comm:: Comm ) where T
421
+ @assert Base. iscontiguous (buf)
422
+ Recv! (buf, length (buf), src, tag, comm)
423
+ end
424
+
407
425
function Recv (:: Type{T} , src:: Integer , tag:: Integer , comm:: Comm ) where T
408
426
buf = Ref {T} ()
409
427
stat = Recv! (buf, 1 , src, tag, comm)
@@ -433,6 +451,12 @@ function Irecv!(buf::Array{T}, src::Integer, tag::Integer,
433
451
Irecv! (buf, length (buf), src, tag, comm)
434
452
end
435
453
454
+ function Irecv! (buf:: SubArray{T} , src:: Integer , tag:: Integer ,
455
+ comm:: Comm ) where T
456
+ @assert Base. iscontiguous (buf)
457
+ Irecv! (buf, length (buf), src, tag, comm)
458
+ end
459
+
436
460
function irecv (src:: Integer , tag:: Integer , comm:: Comm )
437
461
(flag, stat) = Iprobe (src, tag, comm)
438
462
if ! flag
@@ -620,6 +644,11 @@ function Bcast!(buffer::Array{T}, root::Integer, comm::Comm) where T
620
644
Bcast! (buffer, length (buffer), root, comm)
621
645
end
622
646
647
+ function Bcast! (buffer:: SubArray{T} , root:: Integer , comm:: Comm ) where T
648
+ @assert Base. iscontiguous (buffer)
649
+ Bcast! (buffer, length (buffer), root, comm)
650
+ end
651
+
623
652
#=
624
653
function Bcast{T}(obj::T, root::Integer, comm::Comm)
625
654
buf = [T]
@@ -662,6 +691,11 @@ function Reduce(sendbuf::Array{T}, op::Union{Op,Function}, root::Integer, comm::
662
691
Reduce (sendbuf, length (sendbuf), op, root, comm)
663
692
end
664
693
694
+ function Reduce (sendbuf:: SubArray{T} , op:: Union{Op,Function} , root:: Integer , comm:: Comm ) where T
695
+ @assert Base. iscontiguous (sendbuf)
696
+ Reduce (sendbuf, length (sendbuf), op, root, comm)
697
+ end
698
+
665
699
function Reduce (object:: T , op:: Union{Op,Function} , root:: Integer , comm:: Comm ) where T
666
700
isroot = Comm_rank (comm) == root
667
701
sendbuf = T[object]
@@ -736,6 +770,11 @@ function Gather(sendbuf::Array{T}, root::Integer, comm::Comm) where T
736
770
Gather (sendbuf, length (sendbuf), root, comm)
737
771
end
738
772
773
+ function Gather (sendbuf:: SubArray{T} , root:: Integer , comm:: Comm ) where T
774
+ @assert Base. iscontiguous (sendbuf)
775
+ Gather (sendbuf, length (sendbuf), root, comm)
776
+ end
777
+
739
778
function Gather (object:: T , root:: Integer , comm:: Comm ) where T
740
779
isroot = Comm_rank (comm) == root
741
780
sendbuf = T[object]
@@ -756,6 +795,11 @@ function Allgather(sendbuf::Array{T}, comm::Comm) where T
756
795
Allgather (sendbuf, length (sendbuf), comm)
757
796
end
758
797
798
+ function Allgather (sendbuf:: SubArray{T} , comm:: Comm ) where T
799
+ @assert Base. iscontiguous (sendbuf)
800
+ Allgather (sendbuf, length (sendbuf), comm)
801
+ end
802
+
759
803
function Allgather (object:: T , comm:: Comm ) where T
760
804
sendbuf = T[object]
761
805
recvbuf = Allgather (sendbuf, comm)
0 commit comments