@@ -35,11 +35,6 @@ function Bcast!(buffer::AbstractArray{T}, root::Integer, comm::Comm) where T
35
35
Bcast! (buffer, length (buffer), root, comm)
36
36
end
37
37
38
- function Bcast! (buffer:: SubArray{T} , root:: Integer , comm:: Comm ) where T
39
- @assert Base. iscontiguous (buffer)
40
- Bcast! (buffer, length (buffer), root, comm)
41
- end
42
-
43
38
#=
44
39
function Bcast{T}(obj::T, root::Integer, comm::Comm)
45
40
buf = [T]
@@ -112,25 +107,20 @@ To specify the output buffer, see [`Reduce!`](@ref).
112
107
113
108
To perform the reduction in place, see [`Reduce_in_place!`](@ref).
114
109
"""
115
- function Reduce (sendbuf:: MPIBuffertype{T} , count:: Integer ,
110
+ function Reduce (sendbuf, count:: Integer ,
116
111
op, root:: Integer , comm:: Comm ) where T
117
112
isroot = Comm_rank (comm) == root
118
- recvbuf = Array {T} (undef , isroot ? count : 0 )
113
+ recvbuf = similar (sendbuf , isroot ? count : 0 )
119
114
Reduce! (sendbuf, recvbuf, count, op, root, comm)
120
115
end
121
116
122
117
function Reduce (sendbuf:: AbstractArray{T,N} , op,
123
- root:: Integer , comm:: Comm ) where {T,N}
118
+ root:: Integer , comm:: Comm ) where {T,N}
124
119
isroot = Comm_rank (comm) == root
125
120
recvbuf = similar (sendbuf, isroot ? size (sendbuf) : Tuple (zeros (Int, ndims (sendbuf))))
126
121
Reduce! (sendbuf, recvbuf, length (sendbuf), op, root, comm)
127
122
end
128
123
129
- function Reduce (sendbuf:: SubArray{T} , op, root:: Integer , comm:: Comm ) where T
130
- @assert Base. iscontiguous (sendbuf)
131
- Reduce (sendbuf, length (sendbuf), op, root, comm)
132
- end
133
-
134
124
function Reduce (object:: T , op
135
125
, root:: Integer , comm:: Comm ) where T
136
126
isroot = Comm_rank (comm) == root
@@ -238,12 +228,6 @@ output buffer in all processes of the group.
238
228
239
229
To specify the output buffer or perform the operation in pace, see [`Allreduce!`](@ref).
240
230
"""
241
- function Allreduce (sendbuf:: MPIBuffertype{T} , op, comm:: Comm ) where T
242
-
243
- recvbuf = similar (sendbuf)
244
- Allreduce! (sendbuf, recvbuf, length (recvbuf), op, comm)
245
- end
246
-
247
231
function Allreduce (sendbuf:: AbstractArray{T, N} , op, comm:: Comm ) where {T, N}
248
232
recvbuf = similar (sendbuf, size (sendbuf))
249
233
Allreduce! (sendbuf, recvbuf, length (sendbuf), op, comm)
@@ -257,14 +241,6 @@ function Allreduce(obj::T, op, comm::Comm) where T
257
241
outref[]
258
242
end
259
243
260
- # Deprecation warning for lowercase allreduce that was used until v. 0.7.2
261
- # Should be removed at some point in the future
262
- function allreduce (sendbuf:: MPIBuffertype{T} , op,
263
- comm:: Comm ) where T
264
- @warn " `allreduce` is deprecated, use `Allreduce` instead."
265
- Allreduce (sendbuf, op, comm)
266
- end
267
-
268
244
269
245
"""
270
246
Scatter!(sendbuf, recvbuf, count, root, comm)
@@ -456,10 +432,10 @@ Each process sends the first `count` elements of the buffer `sendbuf` to the
456
432
`root` process. The `root` allocates the output buffer and stores elements in
457
433
rank order.
458
434
"""
459
- function Gather (sendbuf:: MPIBuffertype{T} , count:: Integer ,
435
+ function Gather (sendbuf, count:: Integer ,
460
436
root:: Integer , comm:: Comm ) where T
461
437
isroot = Comm_rank (comm) == root
462
- recvbuf = Array {T} (undef , isroot ? Comm_size (comm) * count : 0 )
438
+ recvbuf = similar (sendbuf , isroot ? Comm_size (comm) * count : 0 )
463
439
Gather! (sendbuf, recvbuf, count, root, comm)
464
440
end
465
441
@@ -469,11 +445,6 @@ function Gather(sendbuf::AbstractArray{T}, root::Integer, comm::Comm) where T
469
445
Gather! (sendbuf, recvbuf, length (sendbuf), root, comm)
470
446
end
471
447
472
- function Gather (sendbuf:: SubArray{T} , root:: Integer , comm:: Comm ) where T
473
- @assert Base. iscontiguous (sendbuf)
474
- Gather (sendbuf, length (sendbuf), root, comm)
475
- end
476
-
477
448
function Gather (object:: T , root:: Integer , comm:: Comm ) where T
478
449
isroot = Comm_rank (comm) == root
479
450
sendbuf = T[object]
@@ -549,25 +520,17 @@ function Allgather!(buf, count::Integer,
549
520
end
550
521
551
522
"""
552
- Allgather(sendbuf, count, comm)
523
+ Allgather(sendbuf[ , count=length(sendbuf)] , comm)
553
524
554
525
Each process sends the first `count` elements of `sendbuf` to the
555
526
other processes, who store the results in rank order allocating
556
527
the output buffer.
557
528
"""
558
- function Allgather (sendbuf:: MPIBuffertype{T} , count:: Integer ,
559
- comm:: Comm ) where T
560
- recvbuf = Array {T} (undef, Comm_size (comm) * count)
529
+ function Allgather (sendbuf, count:: Integer , comm:: Comm )
530
+ recvbuf = similar (sendbuf, Comm_size (comm) * count)
561
531
Allgather! (sendbuf, recvbuf, count, comm)
562
532
end
563
-
564
- function Allgather (sendbuf:: AbstractArray{T} , comm:: Comm ) where T
565
- recvbuf = similar (sendbuf, Comm_size (comm) * length (sendbuf))
566
- Allgather! (sendbuf, recvbuf, length (sendbuf), comm)
567
- end
568
-
569
- function Allgather (sendbuf:: SubArray{T} , comm:: Comm ) where T
570
- @assert Base. iscontiguous (sendbuf)
533
+ function Allgather (sendbuf:: AbstractArray , comm:: Comm )
571
534
Allgather (sendbuf, length (sendbuf), comm)
572
535
end
573
536
@@ -613,7 +576,7 @@ in rank order.
613
576
function Gatherv (sendbuf, counts:: Vector{Cint} ,
614
577
root:: Integer , comm:: Comm )
615
578
isroot = Comm_rank (comm) == root
616
- recvbuf = Array {T} (undef , isroot ? sum (counts) : 0 )
579
+ recvbuf = similar (sendbuf , isroot ? sum (counts) : 0 )
617
580
Gatherv! (sendbuf, recvbuf, counts, root, comm)
618
581
end
619
582
@@ -797,24 +760,61 @@ function Scan(sendbuf, count::Integer,
797
760
recvbuf
798
761
end
799
762
800
- function Scan (object:: T , op:: Union{Op,MPI_Op} , comm:: Comm ) where T
763
+
764
+ function Scan! (sendbuf, recvbuf, count:: Integer ,
765
+ op:: Union{Op,MPI_Op} , comm:: Comm )
766
+ T = eltype (sendbuf)
767
+ # int MPI_Scan(const void* sendbuf, void* recvbuf, int count,
768
+ # MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
769
+ @mpichk ccall ((:MPI_Scan , libmpi), Cint,
770
+ (MPIPtr, MPIPtr, Cint, MPI_Datatype, MPI_Op, MPI_Comm),
771
+ sendbuf, recvbuf, count, mpitype (T), op, comm)
772
+ recvbuf
773
+ end
774
+ function Scan! (sendbuf, recvbuf, count:: Integer , opfunc, comm:: Comm )
775
+ Scan! (sendbuf, recvbuf, count, Op (opfunc, eltype (sendbuf)), comm)
776
+ end
777
+ function Scan! (sendbuf:: AbstractArray , recvbuf, op, comm:: Comm )
778
+ Scan! (sendbuf, recvbuf, length (sendbuf), op, comm)
779
+ end
780
+
781
+ function Scan (sendbuf, count:: Integer , op, comm:: Comm )
782
+ Scan! (sendbuf, similar (sendbuf, count), count, op, comm)
783
+ end
784
+
785
+ function Scan (sendbuf:: AbstractArray , op, comm:: Comm )
786
+ Scan (sendbuf, length (sendbuf), op, comm)
787
+ end
788
+ function Scan (object:: T , op, comm:: Comm ) where T
801
789
sendbuf = T[object]
802
790
Scan (sendbuf,1 ,op,comm)
803
791
end
804
792
805
- function Exscan (sendbuf, count:: Integer ,
793
+ function Exscan! (sendbuf, recvbuf , count:: Integer ,
806
794
op:: Union{Op,MPI_Op} , comm:: Comm )
807
795
T = eltype (sendbuf)
808
- recvbuf = similar (sendbuf, count)
809
796
# int MPI_Exscan(const void* sendbuf, void* recvbuf, int count,
810
797
# MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
811
798
@mpichk ccall ((:MPI_Exscan , libmpi), Cint,
812
799
(MPIPtr, MPIPtr, Cint, MPI_Datatype, MPI_Op, MPI_Comm),
813
800
sendbuf, recvbuf, count, mpitype (T), op, comm)
814
801
recvbuf
815
802
end
803
+ function Exscan! (sendbuf, recvbuf, count:: Integer , opfunc, comm:: Comm )
804
+ Exscan! (sendbuf, recvbuf, count, Op (opfunc, eltype (sendbuf)), comm)
805
+ end
806
+ function Exscan! (sendbuf:: AbstractArray , recvbuf, op, comm:: Comm )
807
+ Exscan! (sendbuf, recvbuf, length (sendbuf), op, comm)
808
+ end
809
+
810
+ function Exscan (sendbuf, count:: Integer , op, comm:: Comm )
811
+ Exscan! (sendbuf, similar (sendbuf, count), count, op, comm)
812
+ end
816
813
817
- function Exscan (object:: T , op:: Union{Op,MPI_Op} , comm:: Comm ) where T
814
+ function Exscan (sendbuf:: AbstractArray , op, comm:: Comm )
815
+ Exscan (sendbuf, length (sendbuf), op, comm)
816
+ end
817
+ function Exscan (object:: T , op, comm:: Comm ) where T
818
818
sendbuf = T[object]
819
819
Exscan (sendbuf,1 ,op,comm)
820
820
end
0 commit comments