Skip to content

Commit 0df99bf

Browse files
Merge pull request #216 from ChevronETC/wask/floatx2
more cso tests
2 parents 91962f7 + 1a1d131 commit 0df99bf

File tree

2 files changed

+56
-43
lines changed

2 files changed

+56
-43
lines changed

ext/MPIExt.jl

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -261,30 +261,31 @@ function Base.getindex(x::DevitoMPIAbstractArray{T,N}, I::Vararg{Int,N}) where {
261261
v
262262
end
263263

264-
function Base.setindex!(x::DevitoMPIAbstractArray{T,N}, v::T, I::Vararg{Int,N}) where {T,N}
265-
myrank = MPI.Comm_rank(MPI.COMM_WORLD)
266-
if myrank == 0
267-
@warn "`setindex!` for Devito MPI Arrays has suboptimal performance. consider using `copy!`"
268-
end
269-
wanted_rank = find_rank(x, I...)
270-
if wanted_rank == 0
271-
received_v = v
272-
else
273-
message_tag = 2*MPI.Comm_size(MPI.COMM_WORLD)
274-
source_rank = 0
275-
send_mesg = [v]
276-
recv_mesg = 0 .* send_mesg
277-
rreq = ( myrank == wanted_rank ? MPI.Irecv!(recv_mesg, source_rank, message_tag, MPI.COMM_WORLD) : MPI.Request())
278-
sreq = ( myrank == source_rank ? MPI.Isend(send_mesg, wanted_rank, message_tag, MPI.COMM_WORLD) : MPI.Request() )
279-
stats = MPI.Waitall!([rreq, sreq])
280-
received_v = recv_mesg[1]
281-
end
282-
if myrank == wanted_rank
283-
J = ntuple(idim-> Devito.shift_localindicies( I[idim], localindices(x)[idim]), N)
284-
setindex!(x.p, received_v, J...)
285-
end
286-
MPI.Barrier(MPI.COMM_WORLD)
287-
end
264+
# 2025-09-03 JKW this is never ever used in practice - remove?
265+
# function Base.setindex!(x::DevitoMPIAbstractArray{T,N}, v::T, I::Vararg{Int,N}) where {T,N}
266+
# myrank = MPI.Comm_rank(MPI.COMM_WORLD)
267+
# if myrank == 0
268+
# @warn "`setindex!` for Devito MPI Arrays has suboptimal performance. consider using `copy!`"
269+
# end
270+
# wanted_rank = find_rank(x, I...)
271+
# if wanted_rank == 0
272+
# received_v = v
273+
# else
274+
# message_tag = 2*MPI.Comm_size(MPI.COMM_WORLD)
275+
# source_rank = 0
276+
# send_mesg = [v]
277+
# recv_mesg = 0 .* send_mesg
278+
# rreq = ( myrank == wanted_rank ? MPI.Irecv!(recv_mesg, source_rank, message_tag, MPI.COMM_WORLD) : MPI.Request())
279+
# sreq = ( myrank == source_rank ? MPI.Isend(send_mesg, wanted_rank, message_tag, MPI.COMM_WORLD) : MPI.Request() )
280+
# stats = MPI.Waitall!([rreq, sreq])
281+
# received_v = recv_mesg[1]
282+
# end
283+
# if myrank == wanted_rank
284+
# J = ntuple(idim-> Devito.shift_localindicies( I[idim], localindices(x)[idim]), N)
285+
# setindex!(x.p, received_v, J...)
286+
# end
287+
# MPI.Barrier(MPI.COMM_WORLD)
288+
# end
288289

289290
Base.size(x::SparseDiscreteFunction{T,N,DevitoMPITrue}) where {T,N} = size(data(x))
290291

test/devitoprotests.jl

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Devito, PyCall, Test
22

3-
@testset "ABox Expanding Source" begin
3+
@test_skip @testset "ABox Expanding Source" begin
44
g = Grid(shape=(8,8), extent=(7.0,7.0))
55
nt = 3
66
coords = [0.5 2.5; 2.5 2.5; 0.5 4.5; 2.5 4.5]
@@ -20,7 +20,7 @@ end
2020
# TODO (9/2/2025) - failing with decoupler, mloubout is looking into the issue
2121
if get(ENV, "DEVITO_DECOUPLER", "0") != "1"
2222
# TODO - 2024-08-15 JKW these two ABox tests are broken -- some kind of API change?
23-
@testset "ABox Time Function" begin
23+
@test_skip @testset "ABox Time Function" begin
2424
g = Grid(shape=(5,5), extent=(4.0,4.0))
2525
nt = 3
2626
coords = [2. 2. ;]
@@ -46,7 +46,7 @@ end
4646

4747
# TODO (9/2/2025)- failing with decoupler, mloubout is looking into the issue
4848
if get(ENV, "DEVITO_DECOUPLER", "0") != "1"
49-
@testset "ABox Intersection Time Function" begin
49+
@test_skip @testset "ABox Intersection Time Function" begin
5050
mid = SubDomain("mid",[("middle",2,2),("middle",0,0)])
5151
g = Grid(shape=(5,5), extent=(4.0,4.0), subdomains=mid)
5252
nt = 3
@@ -73,7 +73,7 @@ if get(ENV, "DEVITO_DECOUPLER", "0") != "1"
7373
end
7474
end
7575

76-
@testset "FloatX dtypes with $(mytype), $(DT), $(CT)" for mytype [Float32, Float64], (nb, DT, CT) in zip([8, 16], [FloatX8, FloatX16], [UInt8, UInt16])
76+
@test_skip @testset "FloatX dtypes with $(mytype), $(DT), $(CT)" for mytype [Float32, Float64], (nb, DT, CT) in zip([8, 16], [FloatX8, FloatX16], [UInt8, UInt16])
7777
g = Grid(shape=(5,5))
7878
dtype = DT(1.5f0, 4.5f0)
7979
atol = Devito.scale(dtype)
@@ -116,7 +116,7 @@ end
116116
@test all(data(f) .== 1.5f0)
117117
end
118118

119-
@testset "FloatX addition" for DT (FloatX8, FloatX16)
119+
@test_skip @testset "FloatX addition" for DT (FloatX8, FloatX16)
120120
dtype = DT(1.5f0, 4.5f0)
121121
a = dtype(1.5f0)
122122
b = dtype(1.5f0)
@@ -125,7 +125,7 @@ end
125125
@test Base.:+(a,1.5f0) dtype(1.5f0 + 1.5f0).value
126126
end
127127

128-
@testset "FloatX subtraction" for DT (FloatX8, FloatX16)
128+
@test_skip @testset "FloatX subtraction" for DT (FloatX8, FloatX16)
129129
dtype = DT(1.5f0, 4.5f0)
130130
a = dtype(3.0f0)
131131
b = dtype(1.5f0)
@@ -134,7 +134,7 @@ end
134134
@test Base.:-(a,1.5f0) dtype(3.0f0 - 1.5f0).value
135135
end
136136

137-
@testset "FloatX multiplication" for DT (FloatX8, FloatX16)
137+
@test_skip @testset "FloatX multiplication" for DT (FloatX8, FloatX16)
138138
dtype = DT(1.5f0, 4.5f0)
139139
a = dtype(1.5f0)
140140
b = dtype(1.5f0)
@@ -143,7 +143,7 @@ end
143143
@test Base.:*(a,1.5f0) dtype(1.5f0 * 1.5f0).value
144144
end
145145

146-
@testset "FloatX division" for DT (FloatX8, FloatX16)
146+
@test_skip @testset "FloatX division" for DT (FloatX8, FloatX16)
147147
dtype = DT(1.5f0, 4.5f0)
148148
a = dtype(3.0f0)
149149
b = dtype(1.5f0)
@@ -152,7 +152,7 @@ end
152152
@test Base.:/(a,1.5f0) dtype(3.0f0 / 1.5f0).value
153153
end
154154

155-
@testset "FloatX comparison" for DT (FloatX8, FloatX16)
155+
@test_skip @testset "FloatX comparison" for DT (FloatX8, FloatX16)
156156
dtype = DT(1.5f0, 4.5f0)
157157
a = dtype(1.5f0)
158158
b = dtype(1.5f0)
@@ -164,20 +164,26 @@ end
164164
@test Base.isapprox(a,1.5f0)
165165
end
166166

167-
@testset "FloatX convert" for DT (FloatX8, FloatX16)
167+
@test_skip @testset "FloatX convert" for DT (FloatX8, FloatX16)
168168
dtype = DT(1.5f0, 4.5f0)
169169
a = dtype(1.5f0)
170170
@test Base.convert(typeof(a),1.5f0) == a
171171
@test Base.convert(Float32,a) 1.5f0
172172
end
173173

174-
@testset "FloatX eps with $(mytype), $(DT), $(CT)" for mytype [Float32, Float64], (DT, CT) in zip([FloatX8, FloatX16], [UInt8, UInt16])
175-
g = Grid(shape=(5,5))
176-
dtype = DT(mytype(1.5), mytype(4.5))
177-
@test eps(dtype) eps(mytype)
174+
@testset "FloatX promote_rule tests" begin
175+
fmin,fmax = 1.5, 4.5
176+
f32u08 = Devito.FloatX{fmin,fmax,Float32,UInt8}(Float32(2))
177+
f32u16 = Devito.FloatX{fmin,fmax,Float32,UInt16}(Float32(2))
178+
f64u08 = Devito.FloatX{fmin,fmax,Float64,UInt8}(Float64(2))
179+
f64u16 = Devito.FloatX{fmin,fmax,Float64,UInt16}(Float64(2))
180+
@test promote_type(typeof(f32u08), typeof(f32u16)) == typeof(f32u16)
181+
@test promote_type(typeof(f64u08), typeof(f64u16)) == typeof(f64u16)
182+
@test promote_type(typeof(f32u08), typeof(f64u08)) == typeof(f64u08)
183+
@test promote_type(typeof(f32u08), typeof(f64u16)) == typeof(f64u16)
178184
end
179185

180-
@testset "FloatX arrays with $(mytype), $(DT), $(CT), autopad=$(autopad)" for mytype [Float32, Float64], (DT, CT) in zip([FloatX8, FloatX16], [UInt8, UInt16]), autopad (true,false)
186+
@test_skip @testset "FloatX arrays with $(mytype), $(DT), $(CT), autopad=$(autopad)" for mytype [Float32, Float64], (DT, CT) in zip([FloatX8, FloatX16], [UInt8, UInt16]), autopad (true,false)
181187
configuration!("autopadding", autopad)
182188
g = Grid(shape=(5,5))
183189
dtype = DT(mytype(-1.1), mytype(+1.1))
@@ -189,11 +195,17 @@ end
189195
@test isapprox(Devito.decompress.(data(f)), Devito.decompress.(data(g)))
190196
end
191197

198+
@test_skip @testset "FloatX eps with $(mytype), $(DT), $(CT)" for mytype [Float32, Float64], (DT, CT) in zip([FloatX8, FloatX16], [UInt8, UInt16])
199+
g = Grid(shape=(5,5))
200+
dtype = DT(mytype(1.5), mytype(4.5))
201+
@test eps(dtype) eps(mytype)
202+
end
203+
192204
devito_arch = get(ENV, "DEVITO_ARCH", "gcc")
193205

194206
# TODO (9/2/2025) - failing with decoupler, mloubout is looking into the issue
195207
if get(ENV, "DEVITO_DECOUPLER", "0") != "1"
196-
@testset "CCall with printf" begin
208+
@test_skip @testset "CCall with printf" begin
197209
# CCall test written to use gcc
198210
carch = devito_arch in ["gcc", "clang"] ? devito_arch : "gcc"
199211
@pywith switchconfig(;compiler=get(ENV, "CC", carch)) begin
@@ -225,7 +237,7 @@ compression = []
225237
(lowercase(devito_arch) == "nvc") && (push!(compression, "bitcomp"))
226238
(lowercase(devito_arch) in ["gcc", "clang"]) && (push!(compression, "cvxcompress"))
227239

228-
@testset "Serialization with compression=$(compression)" for compression in compression
240+
@test_skip @testset "Serialization with compression=$(compression)" for compression in compression
229241
if compression == "bitcomp"
230242
configuration!("compiler", "nvc")
231243
else
@@ -268,7 +280,7 @@ compression = []
268280
end
269281
end
270282

271-
@testset "Serialization serial2str" begin
283+
@test_skip @testset "Serialization serial2str" begin
272284
nt = 11
273285
space_order = 8
274286
grid = Grid(shape=(21,21,21), dtype=Float32)
@@ -287,7 +299,7 @@ end
287299
end
288300

289301
# JKW: removing for now, not sure what is even being tested here
290-
# @testset "Serialization with CCall T=$T" for T in (Float32,Float64)
302+
# @test_skip @testset "Serialization with CCall T=$T" for T in (Float32,Float64)
291303
# space_order = 2
292304
# time_M = 3
293305
# filename = "testserialization.bin"

0 commit comments

Comments
 (0)