@@ -34,26 +34,20 @@ function Base.copyto!(
34
34
},
35
35
)
36
36
space = axes (out)
37
- QS = Spaces. quadrature_style (space)
38
- Nq = Quadratures. degrees_of_freedom (QS)
39
- Nh = Topologies. nlocalelems (Spaces. topology (space))
40
- Nv = Spaces. nlevels (space)
41
- max_threads = 256
42
- @assert Nq * Nq ≤ max_threads
43
- Nvthreads = fld (max_threads, Nq * Nq)
44
- Nvblocks = cld (Nv, Nvthreads)
37
+ us = UniversalSize (Fields. field_values (out))
45
38
# executed
39
+ p = spectral_partition (us)
46
40
args = (
47
41
strip_space (out, space),
48
42
strip_space (sbc, space),
49
43
space,
50
- Val (Nvthreads),
44
+ Val (p . Nvthreads),
51
45
)
52
46
auto_launch! (
53
47
copyto_spectral_kernel!,
54
48
args;
55
- threads_s = (Nq, Nq, Nvthreads) ,
56
- blocks_s = (Nh, Nvblocks) ,
49
+ threads_s = p . threads ,
50
+ blocks_s = p . blocks ,
57
51
)
58
52
return out
59
53
end
@@ -66,32 +60,15 @@ function copyto_spectral_kernel!(
66
60
:: Val{Nvt} ,
67
61
) where {Nvt}
68
62
@inbounds begin
69
- i = threadIdx (). x
70
- j = threadIdx (). y
71
- k = threadIdx (). z
72
- h = blockIdx (). x
73
- vid = k + (blockIdx (). y - 1 ) * blockDim (). z
74
63
# allocate required shmem
75
-
76
64
sbc_reconstructed =
77
65
Operators. reconstruct_placeholder_broadcasted (space, sbc)
78
66
sbc_shmem = allocate_shmem (Val (Nvt), sbc_reconstructed)
79
67
80
-
81
68
# can loop over blocks instead?
82
- if space isa Spaces. AbstractSpectralElementSpace
83
- v = nothing
84
- elseif space isa Spaces. FaceExtrudedFiniteDifferenceSpace
85
- v = vid - half
86
- elseif space isa Spaces. CenterExtrudedFiniteDifferenceSpace
87
- v = vid
88
- else
89
- error (" Invalid space" )
90
- end
91
- ij = CartesianIndex ((i, j))
92
- slabidx = Fields. SlabIndex (v, h)
93
- # v may potentially be out-of-range: any time memory is accessed, it
94
- # should be checked by a call to is_valid_index(space, ij, slabidx)
69
+ (ij, slabidx) = spectral_universal_index (space)
70
+ # v in `slabidx` may potentially be out-of-range: any time memory is
71
+ # accessed, it should be checked by a call to is_valid_index(space, ij, slabidx)
95
72
96
73
# resolve_shmem! needs to be called even when out of range, so that
97
74
# sync_threads() is invoked collectively
0 commit comments