Spectral element operator patterns (possible improvements)
- Dominant language
- Julia
- Stars
- 118
- Forks
- 19
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 38
Description
Following a review comment by [charleskawczynski](https://github.com/charleskawczynski), I'll leave this suggestion in an issue for future visibility - we currently use `@simd` in the spectral operator blocks, but an alternative is as follows:
###
```julia
e1 = length(input) ≥ 1 ? (mapreduce(k -> D[i, k] ⊠ input[1][k, j, vt], ⊞, 1:Nq), mapreduce(k -> D[j, k] ⊠ input[1][i, k, vt], ⊞, 1:Nq)) : ()
e2 = length(input) ≥ 2 ? (mapreduce(k -> D[i, k] ⊠ input[2][k, j, vt], ⊞, 1:Nq), mapreduce(k -> D[j, k] ⊠ input[2][i, k, vt], ⊞, 1:Nq)) : ()
e3 = length(input) ≥ 3 ? (mapreduce(k -> D[i, k] ⊠ input[3][k, j, vt], ⊞, 1:Nq), mapreduce(k -> D[j, k] ⊠ input[3][i, k, vt], ⊞, 1:Nq)) : ()
t = (e1...,e2...,e3...)
if length(input) == 1 # check types
return Geometry.Covariant12Vector(t...)
elseif length(input) == 2
return Geometry.AxisTensor((Geometry.Covariant12Axis(), Geometry.UVAxis()), t)
else
return Geometry.AxisTensor((Geometry.Covariant12Axis(), Geometry.UVWAxis()), t)
end
```
_Originally posted by @charleskawczynski in https://github.com/CliMA/ClimaCore.jl/pull/1736#discussion_r1710014985_
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names only the spectral operator blocks and the current @simd approach; start by locating those blocks and reviewing the linked discussion in PR 1736. Compare the proposed mapreduce pattern for correctness and performance, and consider the work done only after its trade-offs are established and validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100