Skip to content

Commit b94aa4d

Browse files
test multiregion (#4566)
1 parent 53237d0 commit b94aa4d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Utils/multi_region_transformation.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ macro apply_regionally(expr)
215215
Nret = length(expr.args[1].args)
216216
end
217217
exp = expr.args[2]
218+
if exp isa Symbol # It is not a function call! Just a variable assignment
219+
return quote
220+
$ret = $(esc(exp))
221+
end
222+
end
218223
func = exp.args[1]
219224
args = exp.args[2:end]
220225
multi_region = quote

test/test_multi_region_unit.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ include("dependencies_for_runtests.jl")
33
devices(::CPU, num) = nothing
44
devices(::GPU, num) = Tuple(0 for i in 1:num)
55

6+
# To be extended as we find new use cases
7+
@testset "Test @apply_regionally macro" begin
8+
a = 1
9+
b = 2
10+
@apply_regionally a = b + 1
11+
12+
@test a == 3
13+
14+
a = MultiRegionObject((1, 2, 3))
15+
b = MultiRegionObject((4, 5, 6))
16+
17+
@apply_regionally a = b + 1
18+
@test a == MultiRegionObject((5, 6, 7))
19+
end
20+
621
@testset "Testing multi region grids" begin
722
for arch in archs
823

0 commit comments

Comments
 (0)