Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Nov 14, 2023
1 parent 3b43d09 commit 21fee87
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 52 deletions.
12 changes: 8 additions & 4 deletions test/Spaces/ddss1.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Logging
using Test
import CUDA
CUDA.allowscalar(false)

import ClimaCore:
Domains,
Expand Down Expand Up @@ -66,10 +68,12 @@ init_state_vector(local_geometry, p) = Geometry.Covariant12Vector(1.0, -1.0)

@test Topologies.nlocalelems(Spaces.topology(space)) == 4

@test Topologies.local_neighboring_elements(space.topology, 1) == [2, 4]
@test Topologies.local_neighboring_elements(space.topology, 2) == [1, 3]
@test Topologies.local_neighboring_elements(space.topology, 3) == [2, 4]
@test Topologies.local_neighboring_elements(space.topology, 4) == [1, 3]
CUDA.@allowscalar begin
@test Topologies.local_neighboring_elements(space.topology, 1) == [2, 4]
@test Topologies.local_neighboring_elements(space.topology, 2) == [1, 3]
@test Topologies.local_neighboring_elements(space.topology, 3) == [2, 4]
@test Topologies.local_neighboring_elements(space.topology, 4) == [1, 3]
end

y0 = init_state_scalar.(Fields.local_geometry_field(space), Ref(nothing))
nel = Topologies.nlocalelems(Spaces.topology(space))
Expand Down
12 changes: 8 additions & 4 deletions test/Spaces/distributed/ddss2.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CUDA
CUDA.allowscalar(false)
include("ddss_setup.jl")

#=
Expand All @@ -17,11 +19,13 @@ include("ddss_setup.jl")

@test Topologies.nlocalelems(Spaces.topology(space)) == 2

@test Topologies.local_neighboring_elements(space.topology, 1) == [2]
@test Topologies.local_neighboring_elements(space.topology, 2) == [1]
CUDA.@allowscalar begin
@test Topologies.local_neighboring_elements(space.topology, 1) == [2]
@test Topologies.local_neighboring_elements(space.topology, 2) == [1]

@test Topologies.ghost_neighboring_elements(space.topology, 1) == [2]
@test Topologies.ghost_neighboring_elements(space.topology, 2) == [1]
@test Topologies.ghost_neighboring_elements(space.topology, 1) == [2]
@test Topologies.ghost_neighboring_elements(space.topology, 2) == [1]
end

init_state(local_geometry, p) == 1.0)
y0 = init_state.(Fields.local_geometry_field(space), Ref(nothing))
Expand Down
44 changes: 24 additions & 20 deletions test/Spaces/distributed/ddss3.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CUDA
CUDA.allowscalar(false)
include("ddss_setup.jl")

#=
Expand Down Expand Up @@ -37,26 +39,28 @@ partition numbers
space, comms_ctx = distributed_space((4, 4), (false, false), (Nq, 1, 1))

@test Topologies.nlocalelems(Spaces.topology(space)) == (pid == 1 ? 6 : 5)
if pid == 1
# gidx 1
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 5, 6]
@test Topologies.ghost_neighboring_elements(space.topology, 1) == []
# gidx 6
@test Topologies.local_neighboring_elements(space.topology, 6) ==
[1, 2, 3, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
6,
)] == [7, 9, 10, 11]
elseif pid == 2
# gidx 7
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 4, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
1,
)] == [2, 3, 4, 6, 12]
CUDA.@allowscalar begin
if pid == 1
# gidx 1
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 5, 6]
@test Topologies.ghost_neighboring_elements(space.topology, 1) == []
# gidx 6
@test Topologies.local_neighboring_elements(space.topology, 6) ==
[1, 2, 3, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
6,
)] == [7, 9, 10, 11]
elseif pid == 2
# gidx 7
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 4, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
1,
)] == [2, 3, 4, 6, 12]
end
end

init_state(local_geometry, p) == 1.0)
Expand Down
2 changes: 2 additions & 0 deletions test/Spaces/distributed/ddss4.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CUDA
CUDA.allowscalar(false)
include("ddss_setup.jl")

#=
Expand Down
12 changes: 8 additions & 4 deletions test/Spaces/distributed_cuda/ddss2.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CUDA
CUDA.allowscalar(false)
using Logging
using Test

Expand Down Expand Up @@ -59,11 +61,13 @@ pid, nprocs = ClimaComms.init(context)

@test Topologies.nlocalelems(Spaces.topology(space)) == 2

@test Topologies.local_neighboring_elements(space.topology, 1) == [2]
@test Topologies.local_neighboring_elements(space.topology, 2) == [1]
CUDA.@allowscalar begin
@test Topologies.local_neighboring_elements(space.topology, 1) == [2]
@test Topologies.local_neighboring_elements(space.topology, 2) == [1]

@test Topologies.ghost_neighboring_elements(space.topology, 1) == [2]
@test Topologies.ghost_neighboring_elements(space.topology, 2) == [1]
@test Topologies.ghost_neighboring_elements(space.topology, 1) == [2]
@test Topologies.ghost_neighboring_elements(space.topology, 2) == [1]
end

init_state(local_geometry, p) == 1.0)
y0 = init_state.(Fields.local_geometry_field(space), Ref(nothing))
Expand Down
44 changes: 24 additions & 20 deletions test/Spaces/distributed_cuda/ddss3.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import CUDA
CUDA.allowscalar(false)
using Logging
using Test

Expand Down Expand Up @@ -78,26 +80,28 @@ partition numbers
space = Spaces.SpectralElementSpace2D(topology, quad)

@test Topologies.nlocalelems(Spaces.topology(space)) == (pid == 1 ? 6 : 5)
if pid == 1
# gidx 1
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 5, 6]
@test Topologies.ghost_neighboring_elements(space.topology, 1) == []
# gidx 6
@test Topologies.local_neighboring_elements(space.topology, 6) ==
[1, 2, 3, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
6,
)] == [7, 9, 10, 11]
elseif pid == 2
# gidx 7
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 4, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
1,
)] == [2, 3, 4, 6, 12]
CUDA.@allowscalar begin
if pid == 1
# gidx 1
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 5, 6]
@test Topologies.ghost_neighboring_elements(space.topology, 1) == []
# gidx 6
@test Topologies.local_neighboring_elements(space.topology, 6) ==
[1, 2, 3, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
6,
)] == [7, 9, 10, 11]
elseif pid == 2
# gidx 7
@test Topologies.local_neighboring_elements(space.topology, 1) ==
[2, 4, 5]
@test space.topology.recv_elem_gidx[Topologies.ghost_neighboring_elements(
space.topology,
1,
)] == [2, 3, 4, 6, 12]
end
end

init_state(local_geometry, p) == 1.0)
Expand Down

0 comments on commit 21fee87

Please sign in to comment.