Skip to content

Commit fbe56a2

Browse files
committed
remove MPIDatatype restriction
1 parent fd7dcc1 commit fbe56a2

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/mpi-base.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ typealias MPIDatatype Union{Char,
44
Float32, Float64, Complex64, Complex128}
55

66
# Define a function mpitype(T) that returns the MPI datatype code
7-
# for a given type T<:MPIDatatype. This works better with precompilation
7+
# for a given type T. This works better with precompilation
88
# than a dictionary (since DataType keys need to be re-hashed at runtime),
99
# and also allows the datatype code to be inlined at compile-time.
1010

@@ -184,27 +184,27 @@ function Iprobe(src::Integer, tag::Integer, comm::Comm)
184184
true, stat
185185
end
186186

187-
function Get_count{T<:MPIDatatype}(stat::Status, ::Type{T})
187+
function Get_count{T}(stat::Status, ::Type{T})
188188
count = Ref{Cint}()
189189
ccall(MPI_GET_COUNT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
190190
stat.val, &mpitype(T), count, &0)
191191
Int(count[])
192192
end
193193

194-
function Send{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
194+
function Send{T}(buf::Union{Ptr{T},Array{T}}, count::Integer,
195195
dest::Integer, tag::Integer, comm::Comm)
196196
ccall(MPI_SEND, Void,
197197
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
198198
Ptr{Cint}),
199199
buf, &count, &mpitype(T), &dest, &tag, &comm.val, &0)
200200
end
201201

202-
function Send{T<:MPIDatatype}(buf::Array{T}, dest::Integer, tag::Integer,
202+
function Send{T}(buf::Array{T}, dest::Integer, tag::Integer,
203203
comm::Comm)
204204
Send(buf, length(buf), dest, tag, comm)
205205
end
206206

207-
function Send{T<:MPIDatatype}(obj::T, dest::Integer, tag::Integer, comm::Comm)
207+
function Send{T}(obj::T, dest::Integer, tag::Integer, comm::Comm)
208208
buf = [obj]
209209
Send(buf, dest, tag, comm)
210210
end
@@ -214,7 +214,7 @@ function send(obj, dest::Integer, tag::Integer, comm::Comm)
214214
Send(buf, dest, tag, comm)
215215
end
216216

217-
function Isend{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
217+
function Isend{T}(buf::Union{Ptr{T},Array{T}}, count::Integer,
218218
dest::Integer, tag::Integer, comm::Comm)
219219
rval = Ref{Cint}()
220220
ccall(MPI_ISEND, Void,
@@ -224,12 +224,12 @@ function Isend{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
224224
Request(rval[], buf)
225225
end
226226

227-
function Isend{T<:MPIDatatype}(buf::Array{T}, dest::Integer, tag::Integer,
227+
function Isend{T}(buf::Array{T}, dest::Integer, tag::Integer,
228228
comm::Comm)
229229
Isend(buf, length(buf), dest, tag, comm)
230230
end
231231

232-
function Isend{T<:MPIDatatype}(obj::T, dest::Integer, tag::Integer, comm::Comm)
232+
function Isend{T}(obj::T, dest::Integer, tag::Integer, comm::Comm)
233233
buf = [obj]
234234
Isend(buf, dest, tag, comm)
235235
end
@@ -239,7 +239,7 @@ function isend(obj, dest::Integer, tag::Integer, comm::Comm)
239239
Isend(buf, dest, tag, comm)
240240
end
241241

242-
function Recv!{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
242+
function Recv!{T}(buf::Union{Ptr{T},Array{T}}, count::Integer,
243243
src::Integer, tag::Integer, comm::Comm)
244244
stat = Status()
245245
ccall(MPI_RECV, Void,
@@ -249,12 +249,12 @@ function Recv!{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
249249
stat
250250
end
251251

252-
function Recv!{T<:MPIDatatype}(buf::Array{T}, src::Integer, tag::Integer,
252+
function Recv!{T}(buf::Array{T}, src::Integer, tag::Integer,
253253
comm::Comm)
254254
Recv!(buf, length(buf), src, tag, comm)
255255
end
256256

257-
function Recv{T<:MPIDatatype}(::Type{T}, src::Integer, tag::Integer, comm::Comm)
257+
function Recv{T}(::Type{T}, src::Integer, tag::Integer, comm::Comm)
258258
buf = Ref{T}
259259
stat = Recv!(buf, src, tag, comm)
260260
(buf[], stat)
@@ -268,7 +268,7 @@ function recv(src::Integer, tag::Integer, comm::Comm)
268268
(MPI.deserialize(buf), stat)
269269
end
270270

271-
function Irecv!{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
271+
function Irecv!{T}(buf::Union{Ptr{T},Array{T}}, count::Integer,
272272
src::Integer, tag::Integer, comm::Comm)
273273
val = Ref{Cint}()
274274
ccall(MPI_IRECV, Void,
@@ -278,7 +278,7 @@ function Irecv!{T<:MPIDatatype}(buf::Union{Ptr{T},Array{T}}, count::Integer,
278278
Request(val[], buf)
279279
end
280280

281-
function Irecv!{T<:MPIDatatype}(buf::Array{T}, src::Integer, tag::Integer,
281+
function Irecv!{T}(buf::Array{T}, src::Integer, tag::Integer,
282282
comm::Comm)
283283
Irecv!(buf, length(buf), src, tag, comm)
284284
end
@@ -450,20 +450,20 @@ function Barrier(comm::Comm)
450450
ccall(MPI_BARRIER, Void, (Ptr{Cint},Ptr{Cint}), &comm.val, &0)
451451
end
452452

453-
function Bcast!{T<:MPIDatatype}(buffer::Union{Ptr{T},Array{T}}, count::Integer,
453+
function Bcast!{T}(buffer::Union{Ptr{T},Array{T}}, count::Integer,
454454
root::Integer, comm::Comm)
455455
ccall(MPI_BCAST, Void,
456456
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
457457
buffer, &count, &mpitype(T), &root, &comm.val, &0)
458458
buffer
459459
end
460460

461-
function Bcast!{T<:MPIDatatype}(buffer::Array{T}, root::Integer, comm::Comm)
461+
function Bcast!{T}(buffer::Array{T}, root::Integer, comm::Comm)
462462
Bcast!(buffer, length(buffer), root, comm)
463463
end
464464

465465
#=
466-
function Bcast{T<:MPIDatatype}(obj::T, root::Integer, comm::Comm)
466+
function Bcast{T}(obj::T, root::Integer, comm::Comm)
467467
buf = [T]
468468
Bcast!(buf, root, comm)
469469
buf[1]
@@ -488,7 +488,7 @@ function bcast(obj, root::Integer, comm::Comm)
488488
obj
489489
end
490490

491-
function Reduce{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
491+
function Reduce{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
492492
op::Op, root::Integer, comm::Comm)
493493
isroot = Comm_rank(comm) == root
494494
recvbuf = Array(T, isroot ? count : 0)
@@ -500,19 +500,19 @@ function Reduce{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
500500
isroot ? recvbuf : nothing
501501
end
502502

503-
function Reduce{T<:MPIDatatype}(sendbuf::Array{T}, op::Op, root::Integer,
503+
function Reduce{T}(sendbuf::Array{T}, op::Op, root::Integer,
504504
comm::Comm)
505505
Reduce(sendbuf, length(sendbuf), op, root, comm)
506506
end
507507

508-
function Reduce{T<:MPIDatatype}(object::T, op::Op, root::Integer, comm::Comm)
508+
function Reduce{T}(object::T, op::Op, root::Integer, comm::Comm)
509509
isroot = Comm_rank(comm) == root
510510
sendbuf = T[object]
511511
recvbuf = Reduce(sendbuf, op, root, comm)
512512
isroot ? recvbuf[1] : nothing
513513
end
514514

515-
function Scatter{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}},
515+
function Scatter{T}(sendbuf::Union{Ptr{T},Array{T}},
516516
count::Integer, root::Integer, comm::Comm)
517517
recvbuf = Array(T, count)
518518
ccall(MPI_SCATTER, Void,
@@ -521,7 +521,7 @@ function Scatter{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}},
521521
recvbuf
522522
end
523523

524-
function Scatterv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}},
524+
function Scatterv{T}(sendbuf::Union{Ptr{T},Array{T}},
525525
counts::Vector{Cint}, root::Integer,
526526
comm::Comm)
527527
recvbuf = Array(T, counts[Comm_rank(comm) + 1])
@@ -533,7 +533,7 @@ function Scatterv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}},
533533
recvbuf
534534
end
535535

536-
function Gather{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
536+
function Gather{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
537537
root::Integer, comm::Comm)
538538
isroot = Comm_rank(comm) == root
539539
recvbuf = Array(T, isroot ? Comm_size(comm) * count : 0)
@@ -543,19 +543,19 @@ function Gather{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
543543
isroot ? recvbuf : nothing
544544
end
545545

546-
function Gather{T<:MPIDatatype}(sendbuf::Array{T}, root::Integer,
546+
function Gather{T}(sendbuf::Array{T}, root::Integer,
547547
comm::Comm)
548548
Gather(sendbuf, length(sendbuf), root, comm)
549549
end
550550

551-
function Gather{T<:MPIDatatype}(object::T, root::Integer, comm::Comm)
551+
function Gather{T}(object::T, root::Integer, comm::Comm)
552552
isroot = Comm_rank(comm) == root
553553
sendbuf = T[object]
554554
recvbuf = Gather(sendbuf, root, comm)
555555
isroot ? recvbuf : nothing
556556
end
557557

558-
function Allgather{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
558+
function Allgather{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
559559
comm::Comm)
560560
recvbuf = Array(T, Comm_size(comm) * count)
561561
ccall(MPI_ALLGATHER, Void,
@@ -564,17 +564,17 @@ function Allgather{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integ
564564
recvbuf
565565
end
566566

567-
function Allgather{T<:MPIDatatype}(sendbuf::Array{T}, comm::Comm)
567+
function Allgather{T}(sendbuf::Array{T}, comm::Comm)
568568
Allgather(sendbuf, length(sendbuf), comm)
569569
end
570570

571-
function Allgather{T<:MPIDatatype}(object::T, comm::Comm)
571+
function Allgather{T}(object::T, comm::Comm)
572572
sendbuf = T[object]
573573
recvbuf = Allgather(sendbuf, comm)
574574
recvbuf
575575
end
576576

577-
function Gatherv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
577+
function Gatherv{T}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
578578
root::Integer, comm::Comm)
579579
isroot = Comm_rank(comm) == root
580580
displs = cumsum(counts) - counts
@@ -586,7 +586,7 @@ function Gatherv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector
586586
isroot ? recvbuf : nothing
587587
end
588588

589-
function Allgatherv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
589+
function Allgatherv{T}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
590590
comm::Comm)
591591
displs = cumsum(counts) - counts
592592
sendcnt = counts[Comm_rank(comm) + 1]
@@ -597,7 +597,7 @@ function Allgatherv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vec
597597
recvbuf
598598
end
599599

600-
function Alltoall{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
600+
function Alltoall{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
601601
comm::Comm)
602602
recvbuf = Array(T, Comm_size(comm)*count)
603603
ccall(MPI_ALLTOALL, Void,
@@ -606,7 +606,7 @@ function Alltoall{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Intege
606606
recvbuf
607607
end
608608

609-
function Alltoallv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, scounts::Vector{Cint},
609+
function Alltoallv{T}(sendbuf::Union{Ptr{T},Array{T}}, scounts::Vector{Cint},
610610
rcounts::Vector{Cint}, comm::Comm)
611611
recvbuf = Array(T, sum(rcounts))
612612
sdispls = cumsum(scounts) - scounts
@@ -617,7 +617,7 @@ function Alltoallv{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, scounts::Vec
617617
recvbuf
618618
end
619619

620-
function Scan{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
620+
function Scan{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
621621
op::Op, comm::Comm)
622622
recvbuf = Array(T, count)
623623
ccall(MPI_SCAN, Void,
@@ -626,12 +626,12 @@ function Scan{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
626626
recvbuf
627627
end
628628

629-
function Scan{T<:MPIDatatype}(object::T, op::Op, comm::Comm)
629+
function Scan{T}(object::T, op::Op, comm::Comm)
630630
sendbuf = T[object]
631631
Scan(sendbuf,1,op,comm)
632632
end
633633

634-
function ExScan{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
634+
function ExScan{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
635635
op::Op, comm::Comm)
636636
recvbuf = Array(T, count)
637637
ccall(MPI_EXSCAN, Void,
@@ -640,7 +640,7 @@ function ExScan{T<:MPIDatatype}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
640640
recvbuf
641641
end
642642

643-
function ExScan{T<:MPIDatatype}(object::T, op::Op, comm::Comm)
643+
function ExScan{T}(object::T, op::Op, comm::Comm)
644644
sendbuf = T[object]
645645
ExScan(sendbuf,1,op,comm)
646646
end

0 commit comments

Comments
 (0)