Skip to content

Commit 6d513bb

Browse files
authored
define operators for logical types (#719)
1 parent e09446f commit 6d513bb

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

src/buffers.jl

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
const MPIInteger = Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64}
2-
const MPIFloatingPoint = Union{Float32, Float64}
3-
const MPIComplex = Union{ComplexF32, ComplexF64}
4-
5-
const MPIDatatype = Union{Char,
6-
Int8, Int16, Int32, Int64,
7-
UInt8, UInt16, UInt32, UInt64,
8-
Float32, Float64, ComplexF32, ComplexF64}
9-
101
MPIBuffertype{T} = Union{Ptr{T}, Array{T}, SubArray{T}, Ref{T}}
112
MPIBuffertypeOrConst{T} = Union{MPIBuffertype{T}, SentinelPtr}
123

src/datatypes.jl

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ function to_type(datatype::Datatype)
8484
return nothing
8585
end
8686

87+
# "native" MPI datatypes
88+
const MPIInteger = Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64}
89+
const MPIFloatingPoint = Union{Float32, Float64}
90+
const MPIComplex = Union{ComplexF32, ComplexF64}
91+
const MPILogical = Union{Bool}
8792

8893
# predefined
8994
_defined_datatype_methods = Set{Type}()

src/deprecated.jl

+5
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,8 @@ import Base: @deprecate
244244
stat = Recv!(buf, Get_source(stat), Get_tag(stat), comm)
245245
(true, MPI.deserialize(buf), stat)
246246
end, false)
247+
248+
Base.@deprecate_binding MPIDatatype Union{Char,
249+
Int8, Int16, Int32, Int64,
250+
UInt8, UInt16, UInt32, UInt64,
251+
Float32, Float64, ComplexF32, ComplexF64} false

src/operators.jl

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ Op(::typeof(*), ::Type{T}; iscommutative=true) where {T<:Union{MPIInteger,MPIFlo
6161
Op(::typeof(&), ::Type{T}; iscommutative=true) where {T<:MPIInteger} = BAND
6262
Op(::typeof(|), ::Type{T}; iscommutative=true) where {T<:MPIInteger} = BOR
6363
Op(::typeof(), ::Type{T}; iscommutative=true) where {T<:MPIInteger} = BXOR
64+
Op(::typeof(&), ::Type{T}; iscommutative=true) where {T<:MPILogical} = LAND
65+
Op(::typeof(|), ::Type{T}; iscommutative=true) where {T<:MPILogical} = LOR
66+
Op(::typeof(), ::Type{T}; iscommutative=true) where {T<:MPILogical} = LXOR
6467

6568

6669
function free(op::Op)

test/test_allreduce.jl

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ for T = [Int]
4747
end
4848
end
4949

50+
@test !MPI.Allreduce(false, |, MPI.COMM_WORLD)
51+
@test MPI.Allreduce(true, |, MPI.COMM_WORLD)
52+
@test !MPI.Allreduce(false, &, MPI.COMM_WORLD)
53+
@test MPI.Allreduce(true, &, MPI.COMM_WORLD)
54+
@test !MPI.Allreduce(false, , MPI.COMM_WORLD)
55+
@test MPI.Allreduce(true, , MPI.COMM_WORLD) iseven(comm_size)
56+
57+
5058
MPI.Barrier( MPI.COMM_WORLD )
5159

5260
GC.gc()

0 commit comments

Comments
 (0)