@@ -3,15 +3,12 @@ typealias MPIDatatype Union{Char,
3
3
UInt64,
4
4
Float32, Float64, Complex64, Complex128}
5
5
6
- # Define a function mpitype(T) that returns the MPI datatype code
7
- # for a given type T. The dictonary is defined in __init__ so
8
- # the module can be precompiled
6
+ # Define a function mpitype(T) that returns the MPI datatype code for
7
+ # a given type T. The dictonary is defined in __init__ so the module
8
+ # can be precompiled
9
9
10
10
# accessor function for getting MPI datatypes
11
- # use a function in case more behavior is needed later
12
- function mpitype {T} (:: Type{T} )
13
- return mpitype_dict[T]
14
- end
11
+ mpitype {T} (:: Type{T} ) = mpitype_dict[T]
15
12
16
13
type Comm
17
14
val:: Cint
@@ -170,7 +167,6 @@ function type_create(T::DataType)
170
167
return nothing
171
168
end
172
169
173
-
174
170
# Point-to-point communication
175
171
176
172
function Probe (src:: Integer , tag:: Integer , comm:: Comm )
@@ -468,7 +464,7 @@ function Barrier(comm::Comm)
468
464
end
469
465
470
466
function Bcast! {T} (buffer:: Union{Ptr{T},Array{T}} , count:: Integer ,
471
- root:: Integer , comm:: Comm )
467
+ root:: Integer , comm:: Comm )
472
468
ccall (MPI_BCAST, Void,
473
469
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
474
470
buffer, & count, & mpitype (T), & root, & comm. val, & 0 )
@@ -506,7 +502,7 @@ function bcast(obj, root::Integer, comm::Comm)
506
502
end
507
503
508
504
function Reduce {T} (sendbuf:: Union{Ptr{T},Array{T}} , count:: Integer ,
509
- op:: Op , root:: Integer , comm:: Comm )
505
+ op:: Op , root:: Integer , comm:: Comm )
510
506
isroot = Comm_rank (comm) == root
511
507
recvbuf = Array (T, isroot ? count : 0 )
512
508
ccall (MPI_REDUCE, Void,
@@ -517,8 +513,7 @@ function Reduce{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
517
513
isroot ? recvbuf : nothing
518
514
end
519
515
520
- function Reduce {T} (sendbuf:: Array{T} , op:: Op , root:: Integer ,
521
- comm:: Comm )
516
+ function Reduce {T} (sendbuf:: Array{T} , op:: Op , root:: Integer , comm:: Comm )
522
517
Reduce (sendbuf, length (sendbuf), op, root, comm)
523
518
end
524
519
@@ -530,7 +525,7 @@ function Reduce{T}(object::T, op::Op, root::Integer, comm::Comm)
530
525
end
531
526
532
527
function Scatter {T} (sendbuf:: Union{Ptr{T},Array{T}} ,
533
- count:: Integer , root:: Integer , comm:: Comm )
528
+ count:: Integer , root:: Integer , comm:: Comm )
534
529
recvbuf = Array (T, count)
535
530
ccall (MPI_SCATTER, Void,
536
531
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
@@ -539,8 +534,8 @@ function Scatter{T}(sendbuf::Union{Ptr{T},Array{T}},
539
534
end
540
535
541
536
function Scatterv {T} (sendbuf:: Union{Ptr{T},Array{T}} ,
542
- counts:: Vector{Cint} , root:: Integer ,
543
- comm:: Comm )
537
+ counts:: Vector{Cint} , root:: Integer ,
538
+ comm:: Comm )
544
539
recvbuf = Array (T, counts[Comm_rank (comm) + 1 ])
545
540
recvcnt = counts[Comm_rank (comm) + 1 ]
546
541
disps = cumsum (counts) - counts
@@ -551,7 +546,7 @@ function Scatterv{T}(sendbuf::Union{Ptr{T},Array{T}},
551
546
end
552
547
553
548
function Gather {T} (sendbuf:: Union{Ptr{T},Array{T}} , count:: Integer ,
554
- root:: Integer , comm:: Comm )
549
+ root:: Integer , comm:: Comm )
555
550
isroot = Comm_rank (comm) == root
556
551
recvbuf = Array (T, isroot ? Comm_size (comm) * count : 0 )
557
552
ccall (MPI_GATHER, Void,
@@ -560,8 +555,7 @@ function Gather{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
560
555
isroot ? recvbuf : nothing
561
556
end
562
557
563
- function Gather {T} (sendbuf:: Array{T} , root:: Integer ,
564
- comm:: Comm )
558
+ function Gather {T} (sendbuf:: Array{T} , root:: Integer , comm:: Comm )
565
559
Gather (sendbuf, length (sendbuf), root, comm)
566
560
end
567
561
@@ -573,7 +567,7 @@ function Gather{T}(object::T, root::Integer, comm::Comm)
573
567
end
574
568
575
569
function Allgather {T} (sendbuf:: Union{Ptr{T},Array{T}} , count:: Integer ,
576
- comm:: Comm )
570
+ comm:: Comm )
577
571
recvbuf = Array (T, Comm_size (comm) * count)
578
572
ccall (MPI_ALLGATHER, Void,
579
573
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
@@ -592,7 +586,7 @@ function Allgather{T}(object::T, comm::Comm)
592
586
end
593
587
594
588
function Gatherv {T} (sendbuf:: Union{Ptr{T},Array{T}} , counts:: Vector{Cint} ,
595
- root:: Integer , comm:: Comm )
589
+ root:: Integer , comm:: Comm )
596
590
isroot = Comm_rank (comm) == root
597
591
displs = cumsum (counts) - counts
598
592
sendcnt = counts[Comm_rank (comm) + 1 ]
@@ -604,7 +598,7 @@ function Gatherv{T}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
604
598
end
605
599
606
600
function Allgatherv {T} (sendbuf:: Union{Ptr{T},Array{T}} , counts:: Vector{Cint} ,
607
- comm:: Comm )
601
+ comm:: Comm )
608
602
displs = cumsum (counts) - counts
609
603
sendcnt = counts[Comm_rank (comm) + 1 ]
610
604
recvbuf = Array (T, sum (counts))
@@ -615,7 +609,7 @@ function Allgatherv{T}(sendbuf::Union{Ptr{T},Array{T}}, counts::Vector{Cint},
615
609
end
616
610
617
611
function Alltoall {T} (sendbuf:: Union{Ptr{T},Array{T}} , count:: Integer ,
618
- comm:: Comm )
612
+ comm:: Comm )
619
613
recvbuf = Array (T, Comm_size (comm)* count)
620
614
ccall (MPI_ALLTOALL, Void,
621
615
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
@@ -624,7 +618,7 @@ function Alltoall{T}(sendbuf::Union{Ptr{T},Array{T}}, count::Integer,
624
618
end
625
619
626
620
function Alltoallv {T} (sendbuf:: Union{Ptr{T},Array{T}} , scounts:: Vector{Cint} ,
627
- rcounts:: Vector{Cint} , comm:: Comm )
621
+ rcounts:: Vector{Cint} , comm:: Comm )
628
622
recvbuf = Array (T, sum (rcounts))
629
623
sdispls = cumsum (scounts) - scounts
630
624
rdispls = cumsum (rcounts) - rcounts
@@ -635,7 +629,7 @@ function Alltoallv{T}(sendbuf::Union{Ptr{T},Array{T}}, scounts::Vector{Cint},
635
629
end
636
630
637
631
function Scan {T} (sendbuf:: Union{Ptr{T},Array{T}} , count:: Integer ,
638
- op:: Op , comm:: Comm )
632
+ op:: Op , comm:: Comm )
639
633
recvbuf = Array (T, count)
640
634
ccall (MPI_SCAN, Void,
641
635
(Ptr{T}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
@@ -649,7 +643,7 @@ function Scan{T}(object::T, op::Op, comm::Comm)
649
643
end
650
644
651
645
function ExScan {T} (sendbuf:: Union{Ptr{T},Array{T}} , count:: Integer ,
652
- op:: Op , comm:: Comm )
646
+ op:: Op , comm:: Comm )
653
647
recvbuf = Array (T, count)
654
648
ccall (MPI_EXSCAN, Void,
655
649
(Ptr{T}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
0 commit comments