diff --git a/NEWS.md b/NEWS.md index ce8a0b9412..b038023e0c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,12 +21,12 @@ PR [#2033](https://github.com/CliMA/ClimaCore.jl/pull/2033) introduces new constructors for `DataLayout`s. Instead of writing ```julia array = rand(FT, Nv, Nij, Nij, 3, Nh) -data = VIJFH{S, Nv, Nij}(array) +data = VIJHF{S, Nv, Nij}(array) ``` You can now write ```julia -data = VIJFH{S}(ArrayType{FT}, rand; Nv, Nij, Nh) +data = VIJHF{S}(ArrayType{FT}, rand; Nv, Nij, Nh) ``` and grab the `array` with `parent(data)` (if you need). diff --git a/docs/src/api.md b/docs/src/api.md index d4f9df8c3e..e7a8a2e064 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -28,10 +28,10 @@ DataLayouts.DataF DataLayouts.IF DataLayouts.IJF DataLayouts.VF -DataLayouts.IFH -DataLayouts.IJFH -DataLayouts.VIFH -DataLayouts.VIJFH +DataLayouts.IHF +DataLayouts.IJHF +DataLayouts.VIHF +DataLayouts.VIJHF ``` ## Geometry diff --git a/examples/hybrid/sphere/solid_body_rotation_3d.jl b/examples/hybrid/sphere/solid_body_rotation_3d.jl index ee0fb5d191..a43a3a0fcc 100644 --- a/examples/hybrid/sphere/solid_body_rotation_3d.jl +++ b/examples/hybrid/sphere/solid_body_rotation_3d.jl @@ -247,7 +247,7 @@ discrete_hydrostatic_balance!(ρ, p, z_top / n_vert, grav) # set up initial condition: not discretely balanced; only create a Field as a place holder Yc = map(coord -> init_sbr_thermo(coord.z), c_coords) # put the dicretely balanced ρ and ρe into Yc -parent(Yc.ρ) .= ρ # Yc.ρ is a VIJFH layout +parent(Yc.ρ) .= ρ # Yc.ρ is a VIJHF layout parent(Yc.ρe) .= ρe # initialize velocity: at rest diff --git a/ext/cuda/data_layouts.jl b/ext/cuda/data_layouts.jl index 6af88f897d..ff153fcb58 100644 --- a/ext/cuda/data_layouts.jl +++ b/ext/cuda/data_layouts.jl @@ -1,8 +1,8 @@ import ClimaCore.DataLayouts: AbstractData import ClimaCore.DataLayouts: FusedMultiBroadcast -import ClimaCore.DataLayouts: IJKFVH, IJFH, VIJFH, VIFH, IFH, IJF, IF, VF, DataF -import ClimaCore.DataLayouts: IJFHStyle, VIJFHStyle, VFStyle, DataFStyle +import ClimaCore.DataLayouts: IJKFVH, IJHF, VIJHF, VIHF, IHF, IJF, IF, VF, DataF +import ClimaCore.DataLayouts: IJHFStyle, VIJHFStyle, VFStyle, DataFStyle import ClimaCore.DataLayouts: promote_parent_array_type import ClimaCore.DataLayouts: parent_array_type import ClimaCore.DataLayouts: isascalar diff --git a/ext/cuda/data_layouts_mapreduce.jl b/ext/cuda/data_layouts_mapreduce.jl index 18435eade6..1fcdcf5c73 100644 --- a/ext/cuda/data_layouts_mapreduce.jl +++ b/ext/cuda/data_layouts_mapreduce.jl @@ -20,7 +20,7 @@ end function mapreduce_cuda( f, op, - data::Union{DataLayouts.VF, DataLayouts.IJFH, DataLayouts.VIJFH}; + data::Union{DataLayouts.VF, DataLayouts.IJHF, DataLayouts.VIJHF}; weighted_jacobian = OnesArray(parent(data)), opargs..., ) @@ -83,7 +83,7 @@ function mapreduce_cuda_kernel!( gidx = _get_gidx(tidx, bidx, effective_blksize) reduction = CUDA.CuStaticSharedArray(T, shmemsize) reduction[tidx] = 0 - (Nv, Nij, Nf, Nh) = _get_dims(dataview) + (Nv, Nij, Nh, Nf) = _get_dims(dataview) nitems = Nv * Nij * Nij * Nf * Nh # load shmem @@ -115,21 +115,21 @@ end @inline _dataview(pdata::AbstractArray{FT, 2}, fidx) where {FT} = view(pdata, :, fidx:fidx) -# for IJFH DataLayout +# for IJHF DataLayout @inline function _get_dims(pdata::AbstractArray{FT, 4}) where {FT} - (Nij, _, Nf, Nh) = size(pdata) - return (1, Nij, Nf, Nh) + (Nij, _, Nh, Nf) = size(pdata) + return (1, Nij, Nh, Nf) end @inline _dataview(pdata::AbstractArray{FT, 4}, fidx) where {FT} = - view(pdata, :, :, fidx:fidx, :) + view(pdata, :, :, :, fidx:fidx) -# for VIJFH DataLayout +# for VIJHF DataLayout @inline function _get_dims(pdata::AbstractArray{FT, 5}) where {FT} - (Nv, Nij, _, Nf, Nh) = size(pdata) - return (Nv, Nij, Nf, Nh) + (Nv, Nij, _, Nh, Nf) = size(pdata) + return (Nv, Nij, Nh, Nf) end @inline _dataview(pdata::AbstractArray{FT, 5}, fidx) where {FT} = - view(pdata, :, :, :, fidx:fidx, :) + view(pdata, :, :, :, :, fidx:fidx) @inline function _cuda_reduce!(op, reduction, tidx, reduction_size, N) if reduction_size > N diff --git a/ext/cuda/data_layouts_threadblock.jl b/ext/cuda/data_layouts_threadblock.jl index a221a7f02b..1011df034e 100644 --- a/ext/cuda/data_layouts_threadblock.jl +++ b/ext/cuda/data_layouts_threadblock.jl @@ -24,7 +24,7 @@ criteria: in the thread partition - The order of the thread partition should follow the fastest changing index in the - datalayout (e.g., VIJ in VIJFH) + datalayout (e.g., VIJ in VIJHF) """ function partition end @@ -46,25 +46,25 @@ bounds to ensure that the result of """ function is_valid_index end -##### VIJFH -@inline function partition(data::DataLayouts.VIJFH, n_max_threads::Integer) +##### VIJHF +@inline function partition(data::DataLayouts.VIJHF, n_max_threads::Integer) (Nij, _, _, Nv, Nh) = DataLayouts.universal_size(data) Nv_thread = min(Int(fld(n_max_threads, Nij * Nij)), Nv) Nv_blocks = cld(Nv, Nv_thread) @assert prod((Nv_thread, Nij, Nij)) ≤ n_max_threads "threads,n_max_threads=($(prod((Nv_thread, Nij, Nij))),$n_max_threads)" return (; threads = (Nv_thread, Nij, Nij), blocks = (Nv_blocks, Nh)) end -@inline function universal_index(::DataLayouts.VIJFH) +@inline function universal_index(::DataLayouts.VIJHF) (tv, i, j) = CUDA.threadIdx() (bv, h) = CUDA.blockIdx() v = tv + (bv - 1) * CUDA.blockDim().x return CartesianIndex((i, j, 1, v, h)) end -@inline is_valid_index(::DataLayouts.VIJFH, I::CI5, us::UniversalSize) = +@inline is_valid_index(::DataLayouts.VIJHF, I::CI5, us::UniversalSize) = 1 ≤ I[4] ≤ DataLayouts.get_Nv(us) -##### IJFH -@inline function partition(data::DataLayouts.IJFH, n_max_threads::Integer) +##### IJHF +@inline function partition(data::DataLayouts.IJHF, n_max_threads::Integer) (Nij, _, _, _, Nh) = DataLayouts.universal_size(data) Nh_thread = min( Int(fld(n_max_threads, Nij * Nij)), @@ -75,30 +75,30 @@ end @assert prod((Nij, Nij)) ≤ n_max_threads "threads,n_max_threads=($(prod((Nij, Nij))),$n_max_threads)" return (; threads = (Nij, Nij, Nh_thread), blocks = (Nh_blocks,)) end -@inline function universal_index(::DataLayouts.IJFH) +@inline function universal_index(::DataLayouts.IJHF) (i, j, th) = CUDA.threadIdx() (bh,) = CUDA.blockIdx() h = th + (bh - 1) * CUDA.blockDim().z return CartesianIndex((i, j, 1, 1, h)) end -@inline is_valid_index(::DataLayouts.IJFH, I::CI5, us::UniversalSize) = +@inline is_valid_index(::DataLayouts.IJHF, I::CI5, us::UniversalSize) = 1 ≤ I[5] ≤ DataLayouts.get_Nh(us) -##### IFH -@inline function partition(data::DataLayouts.IFH, n_max_threads::Integer) +##### IHF +@inline function partition(data::DataLayouts.IHF, n_max_threads::Integer) (Ni, _, _, _, Nh) = DataLayouts.universal_size(data) Nh_thread = min(Int(fld(n_max_threads, Ni)), Nh) Nh_blocks = cld(Nh, Nh_thread) @assert prod((Ni, Nh_thread)) ≤ n_max_threads "threads,n_max_threads=($(prod((Ni, Nh_thread))),$n_max_threads)" return (; threads = (Ni, Nh_thread), blocks = (Nh_blocks,)) end -@inline function universal_index(::DataLayouts.IFH) +@inline function universal_index(::DataLayouts.IHF) (i, th) = CUDA.threadIdx() (bh,) = CUDA.blockIdx() h = th + (bh - 1) * CUDA.blockDim().y return CartesianIndex((i, 1, 1, 1, h)) end -@inline is_valid_index(::DataLayouts.IFH, I::CI5, us::UniversalSize) = +@inline is_valid_index(::DataLayouts.IHF, I::CI5, us::UniversalSize) = 1 ≤ I[5] ≤ DataLayouts.get_Nh(us) ##### IJF @@ -125,21 +125,21 @@ end end @inline is_valid_index(::DataLayouts.IF, I::CI5, us::UniversalSize) = true -##### VIFH -@inline function partition(data::DataLayouts.VIFH, n_max_threads::Integer) +##### VIHF +@inline function partition(data::DataLayouts.VIHF, n_max_threads::Integer) (Ni, _, _, Nv, Nh) = DataLayouts.universal_size(data) Nv_thread = min(Int(fld(n_max_threads, Ni)), Nv) Nv_blocks = cld(Nv, Nv_thread) @assert prod((Nv_thread, Ni)) ≤ n_max_threads "threads,n_max_threads=($(prod((Nv_thread, Ni))),$n_max_threads)" return (; threads = (Nv_thread, Ni), blocks = (Nv_blocks, Nh)) end -@inline function universal_index(::DataLayouts.VIFH) +@inline function universal_index(::DataLayouts.VIHF) (tv, i) = CUDA.threadIdx() (bv, h) = CUDA.blockIdx() v = tv + (bv - 1) * CUDA.blockDim().x return CartesianIndex((i, 1, 1, v, h)) end -@inline is_valid_index(::DataLayouts.VIFH, I::CI5, us::UniversalSize) = +@inline is_valid_index(::DataLayouts.VIHF, I::CI5, us::UniversalSize) = 1 ≤ I[4] ≤ DataLayouts.get_Nv(us) ##### VF diff --git a/ext/cuda/topologies_dss.jl b/ext/cuda/topologies_dss.jl index 0d7952fb82..ff33c7619b 100644 --- a/ext/cuda/topologies_dss.jl +++ b/ext/cuda/topologies_dss.jl @@ -18,7 +18,7 @@ _configure_threadblock(nitems) = function Topologies.dss_load_perimeter_data!( ::ClimaComms.CUDADevice, dss_buffer::Topologies.DSSBuffer, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Topologies.Perimeter2D, ) (; perimeter_data) = dss_buffer @@ -37,13 +37,13 @@ end function dss_load_perimeter_data_kernel!( perimeter_data::DataLayouts.AbstractData, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Topologies.Perimeter2D{Nq}, ) where {Nq} gidx = threadIdx().x + (blockIdx().x - Int32(1)) * blockDim().x (nperimeter, _, _, nlevels, nelems) = size(perimeter_data) nfidx = DataLayouts.ncomponents(perimeter_data) - sizep = (nlevels, nperimeter, nfidx, nelems) # assume VIFH order + sizep = (nlevels, nperimeter, nfidx, nelems) # assume VIHF order CI = CartesianIndex if gidx ≤ prod(sizep) @@ -57,7 +57,7 @@ end function Topologies.dss_unload_perimeter_data!( ::ClimaComms.CUDADevice, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, dss_buffer::Topologies.DSSBuffer, perimeter, ) @@ -76,14 +76,14 @@ function Topologies.dss_unload_perimeter_data!( end function dss_unload_perimeter_data_kernel!( - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter_data::AbstractData, perimeter::Topologies.Perimeter2D{Nq}, ) where {Nq} gidx = threadIdx().x + (blockIdx().x - Int32(1)) * blockDim().x (nperimeter, _, _, nlevels, nelems) = size(perimeter_data) nfidx = DataLayouts.ncomponents(perimeter_data) - sizep = (nlevels, nperimeter, nfidx, nelems) # assume VIFH order + sizep = (nlevels, nperimeter, nfidx, nelems) # assume VIHF order CI = CartesianIndex if gidx ≤ prod(sizep) @@ -97,7 +97,7 @@ end function Topologies.dss_local!( ::ClimaComms.CUDADevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Topologies.Perimeter2D, topology::Topologies.Topology2D, ) @@ -127,7 +127,7 @@ function Topologies.dss_local!( end function dss_local_kernel!( - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, local_vertices::AbstractVector{Tuple{Int, Int}}, local_vertex_offset::AbstractVector{Int}, interior_faces::AbstractVector{Tuple{Int, Int, Int, Int, Bool}}, @@ -189,11 +189,11 @@ end function Topologies.dss_transform!( device::ClimaComms.CUDADevice, - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.VIJFH, DataLayouts.IJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.VIJHF, DataLayouts.IJHF}, perimeter::Topologies.Perimeter2D, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - weight::DataLayouts.IJFH, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + weight::DataLayouts.IJHF, localelems::AbstractVector{Int}, ) nlocalelems = length(localelems) @@ -224,11 +224,11 @@ function Topologies.dss_transform!( end function dss_transform_kernel!( - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.VIJFH, DataLayouts.IJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.VIJHF, DataLayouts.IJHF}, perimeter::Topologies.Perimeter2D, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - weight::DataLayouts.IJFH, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + weight::DataLayouts.IJHF, localelems::AbstractVector{Int}, ::Val{nlocalelems}, ) where {nlocalelems} @@ -255,9 +255,9 @@ end function Topologies.dss_untransform!( device::ClimaComms.CUDADevice, - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.VIJFH, DataLayouts.IJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.VIJHF, DataLayouts.IJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Topologies.Perimeter2D, localelems::AbstractVector{Int}, ) @@ -287,9 +287,9 @@ function Topologies.dss_untransform!( end function dss_untransform_kernel!( - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.VIJFH, DataLayouts.IJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.VIJHF, DataLayouts.IJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Topologies.Perimeter2D, localelems::AbstractVector{Int}, ::Val{nlocalelems}, @@ -316,7 +316,7 @@ end # TODO: Function stubs, code to be implemented, needed only for distributed GPU runs function Topologies.dss_local_ghost!( ::ClimaComms.CUDADevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Topologies.Perimeter2D, topology::Topologies.AbstractTopology, ) @@ -344,7 +344,7 @@ function Topologies.dss_local_ghost!( end function dss_local_ghost_kernel!( - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, ghost_vertices, ghost_vertex_offset, perimeter::Topologies.Perimeter2D, @@ -487,7 +487,7 @@ end function Topologies.dss_ghost!( ::ClimaComms.CUDADevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Topologies.Perimeter2D, topology::Topologies.Topology2D, ) diff --git a/lib/ClimaCorePlots/src/ClimaCorePlots.jl b/lib/ClimaCorePlots/src/ClimaCorePlots.jl index 40a7887212..df31220f55 100644 --- a/lib/ClimaCorePlots/src/ClimaCorePlots.jl +++ b/lib/ClimaCorePlots/src/ClimaCorePlots.jl @@ -104,7 +104,7 @@ RecipesBase.@recipe function f(space::Spaces.ExtrudedFiniteDifferenceSpace) data = Fields.field_values(coord_field) Ni, Nj, _, Nv, Nh = size(data) - #TODO: assumes VIFH layout + #TODO: assumes VIHF layout @assert Nj == 1 "plotting only defined for 1D extruded fields" hspace = Spaces.horizontal_space(space) @@ -431,7 +431,7 @@ function _unfolded_pannel_matrix(field, interpolate) # TODO: inefficient memory wise, but good enough for now panels = [fill(NaN, (panel_size * dof, panel_size * dof)) for _ in 1:6] - interpolated_data = DataLayouts.IJFH{FT, interpolate}(Array{FT}, nelem) + interpolated_data = DataLayouts.IJHF{FT, interpolate}(Array{FT}, nelem) field_data = Fields.field_values(field) Operators.tensor_product!(interpolated_data, field_data, Imat) @@ -445,7 +445,7 @@ function _unfolded_pannel_matrix(field, interpolate) x2_nodal_range = (dof * (ex2 - 1) + 1):(dof * ex2) # transpose the data as our plotting axis order is # reverse nodal element order (x1 axis varies fastest) - data_element = permutedims(parent(interpolated_data)[:, :, 1, lidx]) + data_element = permutedims(parent(interpolated_data)[:, :, lidx, 1]) panel_data[x2_nodal_range, x1_nodal_range] = data_element end diff --git a/lib/ClimaCoreTempestRemap/src/onlineremap.jl b/lib/ClimaCoreTempestRemap/src/onlineremap.jl index 4ea8abb2fd..d3aa3dfa82 100644 --- a/lib/ClimaCoreTempestRemap/src/onlineremap.jl +++ b/lib/ClimaCoreTempestRemap/src/onlineremap.jl @@ -28,7 +28,7 @@ end """ - remap!(target::IJFH{S, Nqt}, R::LinearMap, source::IJFH{S, Nqs}) + remap!(target::IJHF{S, Nqt}, R::LinearMap, source::IJHF{S, Nqs}) remap!(target::Fields.Field, R::LinearMap, source::Fields.Field) Applies the remapping `R` to a `source` @@ -38,9 +38,9 @@ function remap! end # This version of this function is used for serial remapping function remap!( - target::IJFH{S, Nqt}, + target::IJHF{S, Nqt}, R::LinearMap, - source::IJFH{S, Nqs}, + source::IJHF{S, Nqs}, ) where {S, Nqt, Nqs} source_array = parent(source) target_array = parent(target) @@ -62,7 +62,7 @@ function remap!( view(R.target_local_idxs[3], n)[1], ) for f in 1:Nf - target_array[it, jt, f, et] += wt * source_array[is, js, f, es] + target_array[it, jt, et, f] += wt * source_array[is, js, es, f] end end @@ -118,8 +118,8 @@ function remap!(target::Fields.Field, R::LinearMap, source::Fields.Field) # only use local weights - i.e. et, es != 0 if (et != 0) for f in 1:Nf - target_array[it, jt, f, et] += - wt * source_array[is, js, f, es] + target_array[it, jt, et, f] += + wt * source_array[is, js, es, f] end end end diff --git a/lib/ClimaCoreTempestRemap/test/netcdf.jl b/lib/ClimaCoreTempestRemap/test/netcdf.jl index 4f63575c0c..b32557a09e 100644 --- a/lib/ClimaCoreTempestRemap/test/netcdf.jl +++ b/lib/ClimaCoreTempestRemap/test/netcdf.jl @@ -135,7 +135,7 @@ end vspace = Spaces.CenterFiniteDifferenceSpace(device, vmesh) hvspace = Spaces.ExtrudedFiniteDifferenceSpace(hspace, vspace) - fhvspace = Spaces.FaceExtrudedFiniteDifferenceSpace(hvspace) + hfvspace = Spaces.FaceExtrudedFiniteDifferenceSpace(hvspace) # write mesh meshfile_cc = joinpath(OUTPUT_DIR, "mesh_cc_3d.g") @@ -145,15 +145,15 @@ end datafile_cc = joinpath(OUTPUT_DIR, "data_cc.nc") NCDataset(datafile_cc, "c") do nc def_space_coord(nc, hvspace; type = node_type) - def_space_coord(nc, fhvspace; type = node_type) + def_space_coord(nc, hfvspace; type = node_type) nc_xlat = defVar(nc, "xlat", Float64, hvspace) nc_xz = defVar(nc, "xz", Float64, hvspace) - nc_xz_half = defVar(nc, "xz_half", Float64, fhvspace) + nc_xz_half = defVar(nc, "xz_half", Float64, hfvspace) nc_xlat[:] = Fields.coordinate_field(hvspace).lat nc_xz[:] = Fields.coordinate_field(hvspace).z - nc_xz_half[:] = Fields.coordinate_field(fhvspace).z + nc_xz_half[:] = Fields.coordinate_field(hfvspace).z nothing end @@ -230,7 +230,7 @@ end vspace = Spaces.CenterFiniteDifferenceSpace(device, vmesh) hvspace = Spaces.ExtrudedFiniteDifferenceSpace(hspace, vspace) - fhvspace = Spaces.FaceExtrudedFiniteDifferenceSpace(hvspace) + hfvspace = Spaces.FaceExtrudedFiniteDifferenceSpace(hvspace) # write mesh meshfile_cc = joinpath(OUTPUT_DIR, "mesh_cc_3d.g") @@ -240,15 +240,15 @@ end datafile_cc = joinpath(OUTPUT_DIR, "data_cc.nc") NCDataset(datafile_cc, "c") do nc def_space_coord(nc, hvspace; type = node_type) - def_space_coord(nc, fhvspace; type = node_type) + def_space_coord(nc, hfvspace; type = node_type) nc_xlat = defVar(nc, "xlat", Float64, hvspace) nc_xz = defVar(nc, "xz", Float64, hvspace) - nc_xz_half = defVar(nc, "xz_half", Float64, fhvspace) + nc_xz_half = defVar(nc, "xz_half", Float64, hfvspace) nc_xlat[:] = Fields.coordinate_field(hvspace).lat nc_xz[:] = Fields.coordinate_field(hvspace).z - nc_xz_half[:] = Fields.coordinate_field(fhvspace).z + nc_xz_half[:] = Fields.coordinate_field(hfvspace).z nothing end @@ -379,12 +379,12 @@ end vmesh = Meshes.IntervalMesh(vdomain, nelems = nlevels) vfspace = Spaces.FaceFiniteDifferenceSpace(device, vmesh) z_surface = Geometry.ZPoint.(test_warp.(Fields.coordinate_field(hspace))) - fhvspace = Spaces.ExtrudedFiniteDifferenceSpace( + hfvspace = Spaces.ExtrudedFiniteDifferenceSpace( hspace, vfspace, Hypsography.LinearAdaption(z_surface), ) - chvspace = Spaces.CenterExtrudedFiniteDifferenceSpace(fhvspace) + chvspace = Spaces.CenterExtrudedFiniteDifferenceSpace(hfvspace) # write mesh meshfile_cc = joinpath(OUTPUT_DIR, "mesh_cc_3d.g") @@ -394,15 +394,15 @@ end datafile_cc = joinpath(OUTPUT_DIR, "data_cc.nc") NCDataset(datafile_cc, "c") do nc def_space_coord(nc, chvspace; type = node_type) - def_space_coord(nc, fhvspace; type = node_type) + def_space_coord(nc, hfvspace; type = node_type) nc_xlat = defVar(nc, "xlat", Float64, chvspace) nc_xz = defVar(nc, "xz", Float64, chvspace) - nc_xz_half = defVar(nc, "xz_half", Float64, fhvspace) + nc_xz_half = defVar(nc, "xz_half", Float64, hfvspace) nc_xlat[:] = Fields.coordinate_field(chvspace).lat nc_xz[:] = Fields.coordinate_field(chvspace).z - nc_xz_half[:] = Fields.coordinate_field(fhvspace).z + nc_xz_half[:] = Fields.coordinate_field(hfvspace).z nothing end @@ -504,21 +504,21 @@ end vspace = Spaces.CenterFiniteDifferenceSpace(device, vmesh) hvspace = Spaces.ExtrudedFiniteDifferenceSpace(hspace, vspace) - fhvspace = Spaces.FaceExtrudedFiniteDifferenceSpace(hvspace) + hfvspace = Spaces.FaceExtrudedFiniteDifferenceSpace(hvspace) # write data datafile_cc = joinpath(OUTPUT_DIR, "data_cc.nc") NCDataset(datafile_cc, "c") do nc def_space_coord(nc, hvspace; type = node_type) - def_space_coord(nc, fhvspace; type = node_type) + def_space_coord(nc, hfvspace; type = node_type) nc_x = defVar(nc, "xx", Float64, hvspace) nc_z = defVar(nc, "xz", Float64, hvspace) - nc_z_half = defVar(nc, "xz_half", Float64, fhvspace) + nc_z_half = defVar(nc, "xz_half", Float64, hfvspace) nc_x[:] = Fields.coordinate_field(hvspace).x nc_z[:] = Fields.coordinate_field(hvspace).z - nc_z_half[:] = Fields.coordinate_field(fhvspace).z + nc_z_half[:] = Fields.coordinate_field(hfvspace).z nothing end @test isfile(datafile_cc) diff --git a/lib/ClimaCoreTempestRemap/test/online_remap.jl b/lib/ClimaCoreTempestRemap/test/online_remap.jl index ab6da98e79..b93a97afed 100644 --- a/lib/ClimaCoreTempestRemap/test/online_remap.jl +++ b/lib/ClimaCoreTempestRemap/test/online_remap.jl @@ -122,7 +122,7 @@ end nothing end - ## for test below, apply offline map, read in the resulting field and reshape it to the IJFH format + ## for test below, apply offline map, read in the resulting field and reshape it to the IJHF format datafile_out = joinpath(OUTPUT_DIR, "data_out.nc") apply_remap(datafile_out, datafile_in, weightfile, ["sinlong"]) diff --git a/lib/ClimaCoreVTK/src/space.jl b/lib/ClimaCoreVTK/src/space.jl index 1eb1174261..52a2072fea 100644 --- a/lib/ClimaCoreVTK/src/space.jl +++ b/lib/ClimaCoreVTK/src/space.jl @@ -86,7 +86,7 @@ an unstuctured mesh of Lagrange polynomial cells, suitable for passing to function vtk_cells_lagrange(gspace::Spaces.SpectralElementSpace2D) quad = Spaces.quadrature_style(gspace) @assert quad isa Quadratures.ClosedUniform - Nq = Quadratures.degrees_of_freedom(quad) # TODO: this should depend on the backing DataLayouts (e.g. IJFH) + Nq = Quadratures.degrees_of_freedom(quad) # TODO: this should depend on the backing DataLayouts (e.g. IJHF) con_map = vtk_connectivity_map_lagrange(Nq, Nq) [ MeshCell( @@ -126,7 +126,7 @@ function vtk_cells_linear(gridspace::Spaces.FaceExtrudedFiniteDifferenceSpace2D) Nq = Quadratures.degrees_of_freedom(Spaces.quadrature_style(hspace)) Nh = Topologies.nlocalelems(hspace) Nv = Spaces.nlevels(gridspace) - ind = LinearIndices((1:Nv, 1:Nq, 1:Nh)) # assume VIFH + ind = LinearIndices((1:Nv, 1:Nq, 1:Nh)) # assume VIHF cells = [ MeshCell( VTKCellTypes.VTK_QUAD, @@ -145,7 +145,7 @@ function vtk_cells_linear(gridspace::Spaces.FaceExtrudedFiniteDifferenceSpace3D) Nq = Quadratures.degrees_of_freedom(Spaces.quadrature_style(hspace)) Nh = Topologies.nlocalelems(hspace) Nv = Spaces.nlevels(gridspace) - ind = LinearIndices((1:Nv, 1:Nq, 1:Nq, 1:Nh)) # assumes VIJFH + ind = LinearIndices((1:Nv, 1:Nq, 1:Nq, 1:Nh)) # assumes VIJHF cells = [ MeshCell( VTKCellTypes.VTK_HEXAHEDRON, diff --git a/src/DataLayouts/DataLayouts.jl b/src/DataLayouts/DataLayouts.jl index 879133fabc..1dd13d6b38 100644 --- a/src/DataLayouts/DataLayouts.jl +++ b/src/DataLayouts/DataLayouts.jl @@ -6,14 +6,14 @@ Defines the following DataLayouts (see individual docs for more info): TODO: Add links to these datalayouts - `IJKFVH` - - `IJFH` - - `IFH` + - `IJHF` + - `IHF` - `DataF` - `IJF` - `IF` - `VF` - - `VIJFH` - - `VIFH` + - `VIJHF` + - `VIHF` - `IH1JH2` - `IV1JH2` @@ -38,7 +38,7 @@ import MultiBroadcastFusion as MBF import Adapt import ..slab, ..slab_args, ..column, ..column_args, ..level -export slab, column, level, IJFH, IJF, IFH, IF, VF, VIJFH, VIFH, DataF +export slab, column, level, IJHF, IJF, IHF, IF, VF, VIJHF, VIHF, DataF # Internal types for managing CPU/GPU dispatching abstract type AbstractDispatchToDevice end @@ -326,14 +326,14 @@ end # we use to help reduce overspecialization abstract type AbstractDataSingleton end struct IJKFVHSingleton <: AbstractDataSingleton end -struct IJFHSingleton <: AbstractDataSingleton end -struct IFHSingleton <: AbstractDataSingleton end +struct IJHFSingleton <: AbstractDataSingleton end +struct IHFSingleton <: AbstractDataSingleton end struct DataFSingleton <: AbstractDataSingleton end struct IJFSingleton <: AbstractDataSingleton end struct IFSingleton <: AbstractDataSingleton end struct VFSingleton <: AbstractDataSingleton end -struct VIJFHSingleton <: AbstractDataSingleton end -struct VIFHSingleton <: AbstractDataSingleton end +struct VIJHFSingleton <: AbstractDataSingleton end +struct VIHFSingleton <: AbstractDataSingleton end struct IH1JH2Singleton <: AbstractDataSingleton end struct IV1JH2Singleton <: AbstractDataSingleton end @@ -401,8 +401,8 @@ end # ================== """ - IJFH{S, Nij, A} <: Data2D{S, Nij} - IJFH{S,Nij}(ArrayType, nelements) + IJHF{S, Nij, A} <: Data2D{S, Nij} + IJHF{S,Nij}(ArrayType, nelements) Backing `DataLayout` for 2D spectral element slabs. @@ -410,13 +410,13 @@ Backing `DataLayout` for 2D spectral element slabs. Element nodal point (I,J) data is contiguous for each datatype `S` struct field (F), for each 2D mesh element slab (H). -The `ArrayType`-constructor constructs a IJFH 2D Spectral +The `ArrayType`-constructor constructs a IJHF 2D Spectral DataLayout given the backing `ArrayType`, quadrature degrees of freedom `Nij × Nij`, and the number of mesh elements `nelements`. - IJFH{S}(ArrayType[, Base.ones | zeros | rand]; Nij, Nh) + IJHF{S}(ArrayType[, Base.ones | zeros | rand]; Nij, Nh) -The keyword constructor returns a `IJFH` given +The keyword constructor returns a `IJHF` given the `ArrayType` and (optionally) an initialization method (one of `Base.ones`, `Base.zeros`, `Random.rand`) and the keywords: @@ -430,64 +430,64 @@ and the keywords: object in a performance-critical section, and if you know the type parameters at compile time. """ -struct IJFH{S, Nij, A} <: Data2D{S, Nij} +struct IJHF{S, Nij, A} <: Data2D{S, Nij} array::A end -function IJFH{S, Nij}(array::AbstractArray{T, 4}) where {S, Nij, T} +function IJHF{S, Nij}(array::AbstractArray{T, 4}) where {S, Nij, T} check_basetype(T, S) @assert size(array, 1) == Nij @assert size(array, 2) == Nij - @assert size(array, 3) == typesize(T, S) - IJFH{S, Nij, typeof(array)}(array) + @assert size(array, 4) == typesize(T, S) + IJHF{S, Nij, typeof(array)}(array) end -function IJFH{S}( +function IJHF{S}( ::Type{ArrayType}, fun = similar; Nij::Integer, Nh::Integer, ) where {S, ArrayType} Nf = typesize(eltype(ArrayType), S) - array = similar(ArrayType, Nij, Nij, Nf, Nh) + array = similar(ArrayType, Nij, Nij, Nh, Nf) maybe_populate!(array, fun) - IJFH{S, Nij}(array) + IJHF{S, Nij}(array) end -@inline universal_size(data::IJFH{S, Nij}) where {S, Nij} = +@inline universal_size(data::IJHF{S, Nij}) where {S, Nij} = (Nij, Nij, 1, 1, get_Nh_dynamic(data)) -function IJFH{S, Nij}(::Type{ArrayType}, Nh::Integer) where {S, Nij, ArrayType} +function IJHF{S, Nij}(::Type{ArrayType}, Nh::Integer) where {S, Nij, ArrayType} T = eltype(ArrayType) - IJFH{S, Nij}(ArrayType(undef, Nij, Nij, typesize(T, S), Nh)) + IJHF{S, Nij}(ArrayType(undef, Nij, Nij, Nh, typesize(T, S))) end -Base.length(data::IJFH) = get_Nh_dynamic(data) +Base.length(data::IJHF) = get_Nh_dynamic(data) -Base.@propagate_inbounds slab(data::IJFH, h::Integer) = slab(data, 1, h) +Base.@propagate_inbounds slab(data::IJHF, h::Integer) = slab(data, 1, h) -@inline function slab(data::IJFH{S, Nij}, v::Integer, h::Integer) where {S, Nij} +@inline function slab(data::IJHF{S, Nij}, v::Integer, h::Integer) where {S, Nij} @boundscheck (v >= 1 && 1 <= h <= get_Nh_dynamic(data)) || throw(BoundsError(data, (v, h))) - dataview = @inbounds view(parent(data), :, :, :, h) + dataview = @inbounds view(parent(data), :, :, h, :) IJF{S, Nij}(dataview) end -@inline function column(data::IJFH{S, Nij}, i, j, h) where {S, Nij} +@inline function column(data::IJHF{S, Nij}, i, j, h) where {S, Nij} @boundscheck ( 1 <= j <= Nij && 1 <= i <= Nij && 1 <= h <= get_Nh_dynamic(data) ) || throw(BoundsError(data, (i, j, h))) - dataview = @inbounds view(parent(data), i, j, :, h) + dataview = @inbounds view(parent(data), i, j, h, :) DataF{S}(dataview) end function gather( ctx::ClimaComms.AbstractCommsContext, - data::IJFH{S, Nij}, + data::IJHF{S, Nij}, ) where {S, Nij} gatherdata = ClimaComms.gather(ctx, parent(data)) if ClimaComms.iamroot(ctx) - IJFH{S, Nij}(gatherdata) + IJHF{S, Nij}(gatherdata) else nothing end @@ -500,8 +500,8 @@ end Base.length(data::Data1D) = get_Nh_dynamic(data) """ - IFH{S,Ni,Nh,A} <: Data1D{S, Ni} - IFH{S,Ni,Nh}(ArrayType) + IHF{S,Ni,Nh,A} <: Data1D{S, Ni} + IHF{S,Ni,Nh}(ArrayType) Backing `DataLayout` for 1D spectral element slabs. @@ -509,14 +509,14 @@ Element nodal point (I) data is contiguous for each datatype `S` struct field (F), for each 1D mesh element (H). -The `ArrayType`-constructor makes a IFH 1D Spectral +The `ArrayType`-constructor makes a IHF 1D Spectral DataLayout given the backing `ArrayType`, quadrature degrees of freedom `Ni`, and the number of mesh elements `Nh`. - IFH{S}(ArrayType[, ones | zeros | rand]; Ni, Nh) + IHF{S}(ArrayType[, ones | zeros | rand]; Ni, Nh) -The keyword constructor returns a `IFH` given +The keyword constructor returns a `IHF` given the `ArrayType` and (optionally) an initialization method (one of `Base.ones`, `Base.zeros`, `Random.rand`) and the keywords: @@ -530,52 +530,52 @@ and the keywords: object in a performance-critical section, and if you know the type parameters at compile time. """ -struct IFH{S, Ni, A} <: Data1D{S, Ni} +struct IHF{S, Ni, A} <: Data1D{S, Ni} array::A end -function IFH{S, Ni}(array::AbstractArray{T, 3}) where {S, Ni, T} +function IHF{S, Ni}(array::AbstractArray{T, 3}) where {S, Ni, T} check_basetype(T, S) @assert size(array, 1) == Ni - @assert size(array, 2) == typesize(T, S) - IFH{S, Ni, typeof(array)}(array) + @assert size(array, 3) == typesize(T, S) + IHF{S, Ni, typeof(array)}(array) end -function IFH{S}( +function IHF{S}( ::Type{ArrayType}, fun = similar; Ni::Integer, Nh::Integer, ) where {S, ArrayType} Nf = typesize(eltype(ArrayType), S) - array = similar(ArrayType, Ni, Nf, Nh) + array = similar(ArrayType, Ni, Nh, Nf) maybe_populate!(array, fun) - IFH{S, Ni}(array) + IHF{S, Ni}(array) end -function IFH{S, Ni}(::Type{ArrayType}, Nh::Integer) where {S, Ni, ArrayType} +function IHF{S, Ni}(::Type{ArrayType}, Nh::Integer) where {S, Ni, ArrayType} T = eltype(ArrayType) - IFH{S, Ni}(ArrayType(undef, Ni, typesize(T, S), Nh)) + IHF{S, Ni}(ArrayType(undef, Ni, Nh, typesize(T, S))) end -@inline universal_size(data::IFH{S, Ni}) where {S, Ni} = +@inline universal_size(data::IHF{S, Ni}) where {S, Ni} = (Ni, 1, 1, 1, get_Nh_dynamic(data)) -@inline function slab(data::IFH{S, Ni}, h::Integer) where {S, Ni} +@inline function slab(data::IHF{S, Ni}, h::Integer) where {S, Ni} @boundscheck (1 <= h <= get_Nh_dynamic(data)) || throw(BoundsError(data, (h,))) - dataview = @inbounds view(parent(data), :, :, h) + dataview = @inbounds view(parent(data), :, h, :) IF{S, Ni}(dataview) end -Base.@propagate_inbounds slab(data::IFH, v::Integer, h::Integer) = slab(data, h) +Base.@propagate_inbounds slab(data::IHF, v::Integer, h::Integer) = slab(data, h) -@inline function column(data::IFH{S, Ni}, i, h) where {S, Ni} +@inline function column(data::IHF{S, Ni}, i, h) where {S, Ni} @boundscheck (1 <= h <= get_Nh_dynamic(data) && 1 <= i <= Ni) || throw(BoundsError(data, (i, h))) - dataview = @inbounds view(parent(data), i, :, h) + dataview = @inbounds view(parent(data), i, h, :) DataF{S}(dataview) end -Base.@propagate_inbounds column(data::IFH{S, Ni}, i, j, h) where {S, Ni} = +Base.@propagate_inbounds column(data::IHF{S, Ni}, i, j, h) where {S, Ni} = column(data, i, h) # ====================== @@ -905,16 +905,16 @@ end # ====================== """ - VIJFH{S, Nij, A} <: Data2DX{S, Nij} + VIJHF{S, Nij, A} <: Data2DX{S, Nij} Backing `DataLayout` for 2D spectral element slab + extruded 1D FV column data. Column levels (V) are contiguous for every element nodal point (I, J) for each `S` datatype struct field (F), for each 2D mesh element slab (H). - VIJFH{S}(ArrayType[, ones | zeros | rand]; Nv, Nij, Nh) + VIJHF{S}(ArrayType[, ones | zeros | rand]; Nv, Nij, Nh) -The keyword constructor returns a `VIJFH` given +The keyword constructor returns a `VIJHF` given the `ArrayType` and (optionally) an initialization method (one of `Base.ones`, `Base.zeros`, `Random.rand`) and the keywords: @@ -929,19 +929,19 @@ and the keywords: object in a performance-critical section, and if you know the type parameters at compile time. """ -struct VIJFH{S, Nv, Nij, A} <: Data2DX{S, Nv, Nij} +struct VIJHF{S, Nv, Nij, A} <: Data2DX{S, Nv, Nij} array::A end -function VIJFH{S, Nv, Nij}(array::AbstractArray{T, 5}) where {S, Nv, Nij, T} +function VIJHF{S, Nv, Nij}(array::AbstractArray{T, 5}) where {S, Nv, Nij, T} check_basetype(T, S) @assert size(array, 1) == Nv @assert size(array, 2) == size(array, 3) == Nij - @assert size(array, 4) == typesize(T, S) - VIJFH{S, Nv, Nij, typeof(array)}(array) + @assert size(array, 5) == typesize(T, S) + VIJHF{S, Nv, Nij, typeof(array)}(array) end -function VIJFH{S}( +function VIJHF{S}( ::Type{ArrayType}, fun = similar; Nv::Integer, @@ -949,20 +949,20 @@ function VIJFH{S}( Nh::Integer, ) where {S, ArrayType} Nf = typesize(eltype(ArrayType), S) - array = similar(ArrayType, Nv, Nij, Nij, Nf, Nh) + array = similar(ArrayType, Nv, Nij, Nij, Nh, Nf) maybe_populate!(array, fun) - VIJFH{S, Nv, Nij, typeof(array)}(array) + VIJHF{S, Nv, Nij, typeof(array)}(array) end -nlevels(::VIJFH{S, Nv}) where {S, Nv} = Nv +nlevels(::VIJHF{S, Nv}) where {S, Nv} = Nv -@inline universal_size(data::VIJFH{<:Any, Nv, Nij}) where {Nv, Nij} = +@inline universal_size(data::VIJHF{<:Any, Nv, Nij}) where {Nv, Nij} = (Nij, Nij, 1, Nv, get_Nh_dynamic(data)) -Base.length(data::VIJFH) = get_Nv(data) * get_Nh_dynamic(data) +Base.length(data::VIJHF) = get_Nv(data) * get_Nh_dynamic(data) # Note: construct the subarray view directly as optimizer fails in Base.to_indices (v1.7) -@inline function slab(data::VIJFH{S, Nv, Nij}, v, h) where {S, Nv, Nij} +@inline function slab(data::VIJHF{S, Nv, Nij}, v, h) where {S, Nv, Nij} array = parent(data) @boundscheck (1 <= v <= Nv && 1 <= h <= get_Nh_dynamic(data)) || throw(BoundsError(data, (v, h))) @@ -972,14 +972,14 @@ Base.length(data::VIJFH) = get_Nv(data) * get_Nh_dynamic(data) v, Base.Slice(Base.OneTo(Nij)), Base.Slice(Base.OneTo(Nij)), - Base.Slice(Base.OneTo(Nf)), h, + Base.Slice(Base.OneTo(Nf)), ) IJF{S, Nij}(dataview) end # Note: construct the subarray view directly as optimizer fails in Base.to_indices (v1.7) -@inline function column(data::VIJFH{S, Nv, Nij}, i, j, h) where {S, Nv, Nij} +@inline function column(data::VIJHF{S, Nv, Nij}, i, j, h) where {S, Nv, Nij} array = parent(data) @boundscheck ( 1 <= i <= Nij && 1 <= j <= Nij && 1 <= h <= get_Nh_dynamic(data) @@ -987,25 +987,25 @@ end Nf = ncomponents(data) dataview = @inbounds SubArray( array, - (Base.Slice(Base.OneTo(Nv)), i, j, Base.Slice(Base.OneTo(Nf)), h), + (Base.Slice(Base.OneTo(Nv)), i, j, h, Base.Slice(Base.OneTo(Nf))), ) VF{S, Nv}(dataview) end -@inline function level(data::VIJFH{S, Nv, Nij}, v) where {S, Nv, Nij} +@inline function level(data::VIJHF{S, Nv, Nij}, v) where {S, Nv, Nij} array = parent(data) @boundscheck (1 <= v <= Nv) || throw(BoundsError(data, (v,))) dataview = @inbounds view(array, v, :, :, :, :) - IJFH{S, Nij}(dataview) + IJHF{S, Nij}(dataview) end function gather( ctx::ClimaComms.AbstractCommsContext, - data::VIJFH{S, Nv, Nij}, + data::VIJHF{S, Nv, Nij}, ) where {S, Nv, Nij} gatherdata = ClimaComms.gather(ctx, parent(data)) if ClimaComms.iamroot(ctx) - VIJFH{S, Nv, Nij}(gatherdata) + VIJHF{S, Nv, Nij}(gatherdata) else nothing end @@ -1016,16 +1016,16 @@ end # ====================== """ - VIFH{S, Nv, Ni, A} <: Data1DX{S, Nv, Ni} + VIHF{S, Nv, Ni, A} <: Data1DX{S, Nv, Ni} Backing `DataLayout` for 1D spectral element slab + extruded 1D FV column data. Column levels (V) are contiguous for every element nodal point (I) for each datatype `S` struct field (F), for each 1D mesh element slab (H). - VIFH{S}(ArrayType[, ones | zeros | rand]; Nv, Ni, Nh) + VIHF{S}(ArrayType[, ones | zeros | rand]; Nv, Ni, Nh) -The keyword constructor returns a `VIFH` given +The keyword constructor returns a `VIHF` given the `ArrayType` and (optionally) an initialization method (one of `Base.ones`, `Base.zeros`, `Random.rand`) and the keywords: @@ -1040,19 +1040,19 @@ and the keywords: object in a performance-critical section, and if you know the type parameters at compile time. """ -struct VIFH{S, Nv, Ni, A} <: Data1DX{S, Nv, Ni} +struct VIHF{S, Nv, Ni, A} <: Data1DX{S, Nv, Ni} array::A end -function VIFH{S, Nv, Ni}(array::AbstractArray{T, 4}) where {S, Nv, Ni, T} +function VIHF{S, Nv, Ni}(array::AbstractArray{T, 4}) where {S, Nv, Ni, T} check_basetype(T, S) @assert size(array, 1) == Nv @assert size(array, 2) == Ni - @assert size(array, 3) == typesize(T, S) - VIFH{S, Nv, Ni, typeof(array)}(array) + @assert size(array, 4) == typesize(T, S) + VIHF{S, Nv, Ni, typeof(array)}(array) end -function VIFH{S}( +function VIHF{S}( ::Type{ArrayType}, fun = similar; Nv::Integer, @@ -1060,51 +1060,51 @@ function VIFH{S}( Nh::Integer, ) where {S, ArrayType} Nf = typesize(eltype(ArrayType), S) - array = similar(ArrayType, Nv, Ni, Nf, Nh) + array = similar(ArrayType, Nv, Ni, Nh, Nf) maybe_populate!(array, fun) - VIFH{S, Nv, Ni, typeof(array)}(array) + VIHF{S, Nv, Ni, typeof(array)}(array) end -nlevels(::VIFH{S, Nv}) where {S, Nv} = Nv +nlevels(::VIHF{S, Nv}) where {S, Nv} = Nv -@inline universal_size(data::VIFH{<:Any, Nv, Ni}) where {Nv, Ni} = +@inline universal_size(data::VIHF{<:Any, Nv, Ni}) where {Nv, Ni} = (Ni, 1, 1, Nv, get_Nh_dynamic(data)) -Base.length(data::VIFH) = nlevels(data) * get_Nh_dynamic(data) +Base.length(data::VIHF) = nlevels(data) * get_Nh_dynamic(data) # Note: construct the subarray view directly as optimizer fails in Base.to_indices (v1.7) -@inline function slab(data::VIFH{S, Nv, Ni}, v, h) where {S, Nv, Ni} +@inline function slab(data::VIHF{S, Nv, Ni}, v, h) where {S, Nv, Ni} array = parent(data) @boundscheck (1 <= v <= Nv && 1 <= h <= get_Nh_dynamic(data)) || throw(BoundsError(data, (v, h))) Nf = ncomponents(data) dataview = @inbounds SubArray( array, - (v, Base.Slice(Base.OneTo(Ni)), Base.Slice(Base.OneTo(Nf)), h), + (v, Base.Slice(Base.OneTo(Ni)), h, Base.Slice(Base.OneTo(Nf))), ) IF{S, Ni}(dataview) end -Base.@propagate_inbounds column(data::VIFH, i, h) = column(data, i, 1, h) +Base.@propagate_inbounds column(data::VIHF, i, h) = column(data, i, 1, h) # Note: construct the subarray view directly as optimizer fails in Base.to_indices (v1.7) -@inline function column(data::VIFH{S, Nv, Ni}, i, j, h) where {S, Nv, Ni} +@inline function column(data::VIHF{S, Nv, Ni}, i, j, h) where {S, Nv, Ni} array = parent(data) @boundscheck (1 <= i <= Ni && j == 1 && 1 <= h <= get_Nh_dynamic(data)) || throw(BoundsError(data, (i, j, h))) Nf = ncomponents(data) dataview = @inbounds SubArray( array, - (Base.Slice(Base.OneTo(Nv)), i, Base.Slice(Base.OneTo(Nf)), h), + (Base.Slice(Base.OneTo(Nv)), i, h, Base.Slice(Base.OneTo(Nf))), ) VF{S, Nv}(dataview) end -@inline function level(data::VIFH{S, Nv, Nij}, v) where {S, Nv, Nij} +@inline function level(data::VIHF{S, Nv, Nij}, v) where {S, Nv, Nij} array = parent(data) @boundscheck (1 <= v <= Nv) || throw(BoundsError(data, (v,))) dataview = @inbounds view(array, v, :, :, :) - IFH{S, Nij}(dataview) + IHF{S, Nij}(dataview) end # ========================================= @@ -1246,10 +1246,10 @@ empty_kernel_stats() = empty_kernel_stats(ClimaComms.device()) #! format: off @inline get_Nij(::IJKFVH{S, Nij}) where {S, Nij} = Nij -@inline get_Nij(::IJFH{S, Nij}) where {S, Nij} = Nij -@inline get_Nij(::VIJFH{S, Nv, Nij}) where {S, Nv, Nij} = Nij -@inline get_Nij(::VIFH{S, Nv, Nij}) where {S, Nv, Nij} = Nij -@inline get_Nij(::IFH{S, Nij}) where {S, Nij} = Nij +@inline get_Nij(::IJHF{S, Nij}) where {S, Nij} = Nij +@inline get_Nij(::VIJHF{S, Nv, Nij}) where {S, Nv, Nij} = Nij +@inline get_Nij(::VIHF{S, Nv, Nij}) where {S, Nv, Nij} = Nij +@inline get_Nij(::IHF{S, Nij}) where {S, Nij} = Nij @inline get_Nij(::IJF{S, Nij}) where {S, Nij} = Nij @inline get_Nij(::IF{S, Nij}) where {S, Nij} = Nij @@ -1265,24 +1265,24 @@ code, when reconstructing new datalayouts with new type parameters. """ @inline field_dim(::IJKFVHSingleton) = 4 -@inline field_dim(::IJFHSingleton) = 3 -@inline field_dim(::IFHSingleton) = 2 +@inline field_dim(::IJHFSingleton) = 4 +@inline field_dim(::IHFSingleton) = 3 @inline field_dim(::DataFSingleton) = 1 @inline field_dim(::IJFSingleton) = 3 @inline field_dim(::IFSingleton) = 2 @inline field_dim(::VFSingleton) = 2 -@inline field_dim(::VIJFHSingleton) = 4 -@inline field_dim(::VIFHSingleton) = 3 +@inline field_dim(::VIJHFSingleton) = 5 +@inline field_dim(::VIHFSingleton) = 4 @inline field_dim(::Type{IJKFVH}) = 4 -@inline field_dim(::Type{IJFH}) = 3 -@inline field_dim(::Type{IFH}) = 2 +@inline field_dim(::Type{IJHF}) = 4 +@inline field_dim(::Type{IHF}) = 3 @inline field_dim(::Type{DataF}) = 1 @inline field_dim(::Type{IJF}) = 3 @inline field_dim(::Type{IF}) = 2 @inline field_dim(::Type{VF}) = 2 -@inline field_dim(::Type{VIJFH}) = 4 -@inline field_dim(::Type{VIFH}) = 3 +@inline field_dim(::Type{VIJHF}) = 5 +@inline field_dim(::Type{VIHF}) = 4 """ h_dim(::AbstractDataSingleton) @@ -1296,27 +1296,27 @@ code, when reconstructing new datalayouts with new type parameters. """ @inline h_dim(::IJKFVHSingleton) = 5 -@inline h_dim(::IJFHSingleton) = 4 -@inline h_dim(::IFHSingleton) = 3 -@inline h_dim(::VIJFHSingleton) = 5 -@inline h_dim(::VIFHSingleton) = 4 +@inline h_dim(::IJHFSingleton) = 3 +@inline h_dim(::IHFSingleton) = 2 +@inline h_dim(::VIJHFSingleton) = 4 +@inline h_dim(::VIHFSingleton) = 3 @inline to_data_specific(::VFSingleton, I::Tuple) = (I[4], 1) @inline to_data_specific(::IFSingleton, I::Tuple) = (I[1], 1) @inline to_data_specific(::IJFSingleton, I::Tuple) = (I[1], I[2], 1) -@inline to_data_specific(::IJFHSingleton, I::Tuple) = (I[1], I[2], 1, I[5]) -@inline to_data_specific(::IFHSingleton, I::Tuple) = (I[1], 1, I[5]) -@inline to_data_specific(::VIJFHSingleton, I::Tuple) = (I[4], I[1], I[2], 1, I[5]) -@inline to_data_specific(::VIFHSingleton, I::Tuple) = (I[4], I[1], 1, I[5]) +@inline to_data_specific(::IJHFSingleton, I::Tuple) = (I[1], I[2], I[5], 1) +@inline to_data_specific(::IHFSingleton, I::Tuple) = (I[1], I[5], 1) +@inline to_data_specific(::VIJHFSingleton, I::Tuple) = (I[4], I[1], I[2], I[5], 1) +@inline to_data_specific(::VIHFSingleton, I::Tuple) = (I[4], I[1], I[5], 1) @inline to_data_specific_field(::DataFSingleton, I::Tuple) = (I[3],) @inline to_data_specific_field(::VFSingleton, I::Tuple) = (I[4], I[3]) @inline to_data_specific_field(::IFSingleton, I::Tuple) = (I[1], I[3]) @inline to_data_specific_field(::IJFSingleton, I::Tuple) = (I[1], I[2], I[3]) -@inline to_data_specific_field(::IJFHSingleton, I::Tuple) = (I[1], I[2], I[3], I[5]) -@inline to_data_specific_field(::IFHSingleton, I::Tuple) = (I[1], I[3], I[5]) -@inline to_data_specific_field(::VIJFHSingleton, I::Tuple) = (I[4], I[1], I[2], I[3], I[5]) -@inline to_data_specific_field(::VIFHSingleton, I::Tuple) = (I[4], I[1], I[3], I[5]) +@inline to_data_specific_field(::IJHFSingleton, I::Tuple) = (I[1], I[2], I[3], I[5]) +@inline to_data_specific_field(::IHFSingleton, I::Tuple) = (I[1], I[3], I[5]) +@inline to_data_specific_field(::VIJHFSingleton, I::Tuple) = (I[4], I[1], I[2], I[3], I[5]) +@inline to_data_specific_field(::VIHFSingleton, I::Tuple) = (I[4], I[1], I[3], I[5]) """ bounds_condition(data::AbstractData, I::Tuple) @@ -1344,14 +1344,14 @@ type parameters. """ @inline type_params(data::AbstractData) = type_params(typeof(data)) @inline type_params(::Type{IJKFVH{S, Nij, Nk, Nv, A}}) where {S, Nij, Nk, Nv, A} = (S, Nij, Nk, Nv) -@inline type_params(::Type{IJFH{S, Nij, A}}) where {S, Nij, A} = (S, Nij) -@inline type_params(::Type{IFH{S, Ni, A}}) where {S, Ni, A} = (S, Ni) +@inline type_params(::Type{IJHF{S, Nij, A}}) where {S, Nij, A} = (S, Nij) +@inline type_params(::Type{IHF{S, Ni, A}}) where {S, Ni, A} = (S, Ni) @inline type_params(::Type{DataF{S, A}}) where {S, A} = (S,) @inline type_params(::Type{IJF{S, Nij, A}}) where {S, Nij, A} = (S, Nij) @inline type_params(::Type{IF{S, Ni, A}}) where {S, Ni, A} = (S, Ni) @inline type_params(::Type{VF{S, Nv, A}}) where {S, Nv, A} = (S, Nv) -@inline type_params(::Type{VIJFH{S, Nv, Nij, A}}) where {S, Nv, Nij, A} = (S, Nv, Nij) -@inline type_params(::Type{VIFH{S, Nv, Ni, A}}) where {S, Nv, Ni, A} = (S, Nv, Ni) +@inline type_params(::Type{VIJHF{S, Nv, Nij, A}}) where {S, Nv, Nij, A} = (S, Nv, Nij) +@inline type_params(::Type{VIHF{S, Nv, Ni, A}}) where {S, Nv, Ni, A} = (S, Nv, Ni) @inline type_params(::Type{IH1JH2{S, Nij, A}}) where {S, Nij, A} = (S, Nij) @inline type_params(::Type{IV1JH2{S, n1, Ni, A}}) where {S, n1, Ni, A} = (S, n1, Ni) @@ -1369,14 +1369,14 @@ code, when reconstructing new datalayouts with new type parameters. """ @inline union_all(::IJKFVHSingleton) = IJKFVH -@inline union_all(::IJFHSingleton) = IJFH -@inline union_all(::IFHSingleton) = IFH +@inline union_all(::IJHFSingleton) = IJHF +@inline union_all(::IHFSingleton) = IHF @inline union_all(::DataFSingleton) = DataF @inline union_all(::IJFSingleton) = IJF @inline union_all(::IFSingleton) = IF @inline union_all(::VFSingleton) = VF -@inline union_all(::VIJFHSingleton) = VIJFH -@inline union_all(::VIFHSingleton) = VIFH +@inline union_all(::VIJHFSingleton) = VIJHF +@inline union_all(::VIHFSingleton) = VIHF @inline union_all(::IH1JH2Singleton) = IH1JH2 @inline union_all(::IV1JH2Singleton) = IV1JH2 @@ -1394,14 +1394,14 @@ type parameters. """ @inline array_size(data::AbstractData, i::Integer) = array_size(data)[i] @inline array_size(data::IJKFVH{S, Nij, Nk, Nv}) where {S, Nij, Nk, Nv} = (Nij, Nij, Nk, 1, Nv, get_Nh_dynamic(data)) -@inline array_size(data::IJFH{S, Nij}) where {S, Nij} = (Nij, Nij, 1, get_Nh_dynamic(data)) -@inline array_size(data::IFH{S, Ni}) where {S, Ni} = (Ni, 1, get_Nh_dynamic(data)) +@inline array_size(data::IJHF{S, Nij}) where {S, Nij} = (Nij, Nij, get_Nh_dynamic(data), 1) +@inline array_size(data::IHF{S, Ni}) where {S, Ni} = (Ni, get_Nh_dynamic(data), 1) @inline array_size(data::DataF{S}) where {S} = (1,) @inline array_size(data::IJF{S, Nij}) where {S, Nij} = (Nij, Nij, 1) @inline array_size(data::IF{S, Ni}) where {S, Ni} = (Ni, 1) @inline array_size(data::VF{S, Nv}) where {S, Nv} = (Nv, 1) -@inline array_size(data::VIJFH{S, Nv, Nij}) where {S, Nv, Nij} = (Nv, Nij, Nij, 1, get_Nh_dynamic(data)) -@inline array_size(data::VIFH{S, Nv, Ni}) where {S, Nv, Ni} = (Nv, Ni, 1, get_Nh_dynamic(data)) +@inline array_size(data::VIJHF{S, Nv, Nij}) where {S, Nv, Nij} = (Nv, Nij, Nij, get_Nh_dynamic(data), 1) +@inline array_size(data::VIHF{S, Nv, Ni}) where {S, Nv, Ni} = (Nv, Ni, get_Nh_dynamic(data), 1) """ farray_size(data::AbstractData) @@ -1416,14 +1416,14 @@ type parameters. """ @inline farray_size(data::AbstractData, i::Integer) = farray_size(data)[i] @inline farray_size(data::IJKFVH{S, Nij, Nk, Nv}) where {S, Nij, Nk, Nv} = (Nij, Nij, Nk, ncomponents(data), Nv, get_Nh_dynamic(data)) -@inline farray_size(data::IJFH{S, Nij}) where {S, Nij} = (Nij, Nij, ncomponents(data), get_Nh_dynamic(data)) -@inline farray_size(data::IFH{S, Ni}) where {S, Ni} = (Ni, ncomponents(data), get_Nh_dynamic(data)) +@inline farray_size(data::IJHF{S, Nij}) where {S, Nij} = (Nij, Nij, get_Nh_dynamic(data), ncomponents(data)) +@inline farray_size(data::IHF{S, Ni}) where {S, Ni} = (Ni, get_Nh_dynamic(data), ncomponents(data)) @inline farray_size(data::DataF{S}) where {S} = (ncomponents(data),) @inline farray_size(data::IJF{S, Nij}) where {S, Nij} = (Nij, Nij, ncomponents(data)) @inline farray_size(data::IF{S, Ni}) where {S, Ni} = (Ni, ncomponents(data)) @inline farray_size(data::VF{S, Nv}) where {S, Nv} = (Nv, ncomponents(data)) -@inline farray_size(data::VIJFH{S, Nv, Nij}) where {S, Nv, Nij} = (Nv, Nij, Nij, ncomponents(data), get_Nh_dynamic(data)) -@inline farray_size(data::VIFH{S, Nv, Ni}) where {S, Nv, Ni} = (Nv, Ni, ncomponents(data), get_Nh_dynamic(data)) +@inline farray_size(data::VIJHF{S, Nv, Nij}) where {S, Nv, Nij} = (Nv, Nij, Nij, get_Nh_dynamic(data), ncomponents(data)) +@inline farray_size(data::VIHF{S, Nv, Ni}) where {S, Nv, Ni} = (Nv, Ni, get_Nh_dynamic(data), ncomponents(data)) # Keep in sync with definition(s) in libs. @inline slab_index(i::T, j::T) where {T} = CartesianIndex(i, j, T(1), T(1), T(1)) @@ -1444,14 +1444,14 @@ type parameters. @inline parent_array_type(data::AbstractData) = parent_array_type(typeof(data)) # Equivalent to: # @generated parent_array_type(::Type{A}) where {A <: AbstractData} = Tuple(A.parameters)[end] -@inline parent_array_type(::Type{IFH{S, Ni, A}}) where {S, Ni, A} = A +@inline parent_array_type(::Type{IHF{S, Ni, A}}) where {S, Ni, A} = A @inline parent_array_type(::Type{DataF{S, A}}) where {S, A} = A @inline parent_array_type(::Type{IJF{S, Nij, A}}) where {S, Nij, A} = A @inline parent_array_type(::Type{IF{S, Ni, A}}) where {S, Ni, A} = A @inline parent_array_type(::Type{VF{S, Nv, A}}) where {S, Nv, A} = A -@inline parent_array_type(::Type{VIJFH{S, Nv, Nij, A}}) where {S, Nv, Nij, A} = A -@inline parent_array_type(::Type{VIFH{S, Nv, Ni, A}}) where {S, Nv, Ni, A} = A -@inline parent_array_type(::Type{IJFH{S, Nij, A}}) where {S, Nij, A} = A +@inline parent_array_type(::Type{VIJHF{S, Nv, Nij, A}}) where {S, Nv, Nij, A} = A +@inline parent_array_type(::Type{VIHF{S, Nv, Ni, A}}) where {S, Nv, Ni, A} = A +@inline parent_array_type(::Type{IJHF{S, Nij, A}}) where {S, Nij, A} = A @inline parent_array_type(::Type{IH1JH2{S, Nij, A}}) where {S, Nij, A} = A @inline parent_array_type(::Type{IV1JH2{S, n1, Ni, A}}) where {S, n1, Ni, A} = A @inline parent_array_type(::Type{IJKFVH{S, Nij, Nk, Nv, A}}) where {S, Nij, Nk, Nv, A} = A @@ -1463,7 +1463,7 @@ Base.ndims(::Type{T}) where {T <: AbstractData} = Base.ndims(parent_array_type(T)) @inline function Base.getindex( - data::Union{IJF, IJFH, IFH, VIJFH, VIFH, VF, IF}, + data::Union{IJF, IJHF, IHF, VIJHF, VIHF, VF, IF}, I::CartesianIndex, ) @boundscheck bounds_condition(data, I) || throw(BoundsError(data, I)) @@ -1477,7 +1477,7 @@ Base.ndims(::Type{T}) where {T <: AbstractData} = end @inline function Base.setindex!( - data::Union{IJF, IJFH, IFH, VIJFH, VIFH, VF, IF}, + data::Union{IJF, IJHF, IHF, VIJHF, VIHF, VF, IF}, val, I::CartesianIndex, ) @@ -1501,7 +1501,7 @@ The universal index order is `CartesianIndex(i, j, f, v, h)`, see see the notation in [`DataLayouts`](@ref) for more information. """ @inline function getindex_field( - data::Union{DataF, IJF, IJFH, IFH, VIJFH, VIFH, VF, IF}, + data::Union{DataF, IJF, IJHF, IHF, VIJHF, VIHF, VF, IF}, I::CartesianIndex, # universal index ) @boundscheck bounds_condition(data, I) || throw(BoundsError(data, I)) @@ -1521,7 +1521,7 @@ The universal index order is `CartesianIndex(i, j, f, v, h)`, see see the notation in [`DataLayouts`](@ref) for more information. """ @inline function setindex_field!( - data::Union{DataF, IJF, IJFH, IFH, VIJFH, VIFH, VF, IF}, + data::Union{DataF, IJF, IJHF, IHF, VIJHF, VIHF, VF, IF}, val::Real, I::CartesianIndex, # universal index ) @@ -1538,7 +1538,7 @@ if VERSION ≥ v"1.11.0-beta" # TODO: can we remove this? It's not needed for Julia 1.10, # but seems needed in Julia 1.11. @inline Base.getindex( - data::Union{IJF, IJFH, IFH, VIJFH, VIFH, VF, IF}, + data::Union{IJF, IJHF, IHF, VIJHF, VIHF, VF, IF}, I::Vararg{Int, N}, ) where {N} = Base.getindex( data, @@ -1546,7 +1546,7 @@ if VERSION ≥ v"1.11.0-beta" ) @inline Base.setindex!( - data::Union{IJF, IJFH, IFH, VIJFH, VIFH, VF, IF}, + data::Union{IJF, IJHF, IHF, VIJHF, VIHF, VF, IF}, val, I::Vararg{Int, N}, ) where {N} = Base.setindex!( @@ -1586,9 +1586,9 @@ Also, this assumes that `eltype(data) <: Real`. """ function data2array end -data2array(data::Union{IF, IFH}) = reshape(parent(data), :) -data2array(data::Union{IJF, IJFH}) = reshape(parent(data), :) -data2array(data::Union{VF{S, Nv}, VIFH{S, Nv}, VIJFH{S, Nv}}) where {S, Nv} = +data2array(data::Union{IF, IHF}) = reshape(parent(data), :) +data2array(data::Union{IJF, IJHF}) = reshape(parent(data), :) +data2array(data::Union{VF{S, Nv}, VIHF{S, Nv}, VIJHF{S, Nv}}) where {S, Nv} = reshape(parent(data), Nv, :) """ @@ -1619,14 +1619,14 @@ device_dispatch(x::SArray) = ToCPU() device_dispatch(x::MArray) = ToCPU() @inline singleton(@nospecialize(::IJKFVH)) = IJKFVHSingleton() -@inline singleton(@nospecialize(::IJFH)) = IJFHSingleton() -@inline singleton(@nospecialize(::IFH)) = IFHSingleton() +@inline singleton(@nospecialize(::IJHF)) = IJHFSingleton() +@inline singleton(@nospecialize(::IHF)) = IHFSingleton() @inline singleton(@nospecialize(::DataF)) = DataFSingleton() @inline singleton(@nospecialize(::IJF)) = IJFSingleton() @inline singleton(@nospecialize(::IF)) = IFSingleton() @inline singleton(@nospecialize(::VF)) = VFSingleton() -@inline singleton(@nospecialize(::VIJFH)) = VIJFHSingleton() -@inline singleton(@nospecialize(::VIFH)) = VIFHSingleton() +@inline singleton(@nospecialize(::VIJHF)) = VIJHFSingleton() +@inline singleton(@nospecialize(::VIHF)) = VIHFSingleton() @inline singleton(@nospecialize(::IH1JH2)) = IH1JH2Singleton() @inline singleton(@nospecialize(::IV1JH2)) = IV1JH2Singleton() diff --git a/src/DataLayouts/broadcast.jl b/src/DataLayouts/broadcast.jl index ca7d921e83..51cc2617b2 100644 --- a/src/DataLayouts/broadcast.jl +++ b/src/DataLayouts/broadcast.jl @@ -23,12 +23,12 @@ DataStyle(::Type{VF{S, Nv, A}}) where {S, Nv, A} = DataColumnStyle(::Type{VFStyle{Nv, A}}) where {Nv, A} = VFStyle{Nv, A} abstract type Data1DStyle{Ni} <: DataStyle end -struct IFHStyle{Ni, A} <: Data1DStyle{Ni} end -DataStyle(::Type{IFH{S, Ni, A}}) where {S, Ni, A} = - IFHStyle{Ni, parent_array_type(A)}() +struct IHFStyle{Ni, A} <: Data1DStyle{Ni} end +DataStyle(::Type{IHF{S, Ni, A}}) where {S, Ni, A} = + IHFStyle{Ni, parent_array_type(A)}() abstract type DataSlab1DStyle{Ni} <: DataStyle end -DataSlab1DStyle(::Type{IFHStyle{Ni, A}}) where {Ni, A} = IFStyle{Ni, A} +DataSlab1DStyle(::Type{IHFStyle{Ni, A}}) where {Ni, A} = IFStyle{Ni, A} struct IFStyle{Ni, A} <: DataSlab1DStyle{Ni} end DataStyle(::Type{IF{S, Ni, A}}) where {S, Ni, A} = @@ -40,29 +40,29 @@ DataStyle(::Type{IJF{S, Nij, A}}) where {S, Nij, A} = IJFStyle{Nij, parent_array_type(A)}() abstract type Data2DStyle{Nij} <: DataStyle end -struct IJFHStyle{Nij, A} <: Data2DStyle{Nij} end -DataStyle(::Type{IJFH{S, Nij, A}}) where {S, Nij, A} = - IJFHStyle{Nij, parent_array_type(A)}() -DataSlab2DStyle(::Type{IJFHStyle{Nij, A}}) where {Nij, A} = IJFStyle{Nij, A} +struct IJHFStyle{Nij, A} <: Data2DStyle{Nij} end +DataStyle(::Type{IJHF{S, Nij, A}}) where {S, Nij, A} = + IJHFStyle{Nij, parent_array_type(A)}() +DataSlab2DStyle(::Type{IJHFStyle{Nij, A}}) where {Nij, A} = IJFStyle{Nij, A} abstract type Data1DXStyle{Nv, Ni} <: DataStyle end -struct VIFHStyle{Nv, Ni, A} <: Data1DXStyle{Nv, Ni} end -DataStyle(::Type{VIFH{S, Nv, Ni, A}}) where {S, Nv, Ni, A} = - VIFHStyle{Nv, Ni, parent_array_type(A)}() -Data1DXStyle(::Type{VIFHStyle{Nv, Ni, A}}) where {Ni, Nv, A} = - VIFHStyle{Nv, Ni, A} -DataColumnStyle(::Type{VIFHStyle{Nv, Ni, A}}) where {Ni, Nv, A} = VFStyle{Nv, A} -DataSlab1DStyle(::Type{VIFHStyle{Nv, Ni, A}}) where {Ni, Nv, A} = IFStyle{Ni, A} +struct VIHFStyle{Nv, Ni, A} <: Data1DXStyle{Nv, Ni} end +DataStyle(::Type{VIHF{S, Nv, Ni, A}}) where {S, Nv, Ni, A} = + VIHFStyle{Nv, Ni, parent_array_type(A)}() +Data1DXStyle(::Type{VIHFStyle{Nv, Ni, A}}) where {Ni, Nv, A} = + VIHFStyle{Nv, Ni, A} +DataColumnStyle(::Type{VIHFStyle{Nv, Ni, A}}) where {Ni, Nv, A} = VFStyle{Nv, A} +DataSlab1DStyle(::Type{VIHFStyle{Nv, Ni, A}}) where {Ni, Nv, A} = IFStyle{Ni, A} abstract type Data2DXStyle{Nv, Nij} <: DataStyle end -struct VIJFHStyle{Nv, Nij, A} <: Data2DXStyle{Nv, Nij} end -DataStyle(::Type{VIJFH{S, Nv, Nij, A}}) where {S, Nv, Nij, A} = - VIJFHStyle{Nv, Nij, parent_array_type(A)}() -Data2DXStyle(::Type{VIJFHStyle{Nv, Nij, A}}) where {Nv, Nij, A} = - VIJFHStyle{Nv, Nij, A} -DataColumnStyle(::Type{VIJFHStyle{Nv, Nij, A}}) where {Nv, Nij, A} = +struct VIJHFStyle{Nv, Nij, A} <: Data2DXStyle{Nv, Nij} end +DataStyle(::Type{VIJHF{S, Nv, Nij, A}}) where {S, Nv, Nij, A} = + VIJHFStyle{Nv, Nij, parent_array_type(A)}() +Data2DXStyle(::Type{VIJHFStyle{Nv, Nij, A}}) where {Nv, Nij, A} = + VIJHFStyle{Nv, Nij, A} +DataColumnStyle(::Type{VIJHFStyle{Nv, Nij, A}}) where {Nv, Nij, A} = VFStyle{Nv, A} -DataSlab2DStyle(::Type{VIJFHStyle{Nv, Nij, A}}) where {Nv, Nij, A} = +DataSlab2DStyle(::Type{VIJHFStyle{Nv, Nij, A}}) where {Nv, Nij, A} = IJFStyle{Nij, A} ##### @@ -70,12 +70,12 @@ DataSlab2DStyle(::Type{VIJFHStyle{Nv, Nij, A}}) where {Nv, Nij, A} = ##### #! format: off -const BroadcastedUnionIJFH{S, Nij, A} = Union{Base.Broadcast.Broadcasted{IJFHStyle{Nij, A}}, IJFH{S, Nij, A}} -const BroadcastedUnionIFH{S, Ni, A} = Union{Base.Broadcast.Broadcasted{IFHStyle{Ni, A}}, IFH{S, Ni, A}} +const BroadcastedUnionIJHF{S, Nij, A} = Union{Base.Broadcast.Broadcasted{IJHFStyle{Nij, A}}, IJHF{S, Nij, A}} +const BroadcastedUnionIHF{S, Ni, A} = Union{Base.Broadcast.Broadcasted{IHFStyle{Ni, A}}, IHF{S, Ni, A}} const BroadcastedUnionIJF{S, Nij, A} = Union{Base.Broadcast.Broadcasted{IJFStyle{Nij, A}}, IJF{S, Nij, A}} const BroadcastedUnionIF{S, Ni, A} = Union{Base.Broadcast.Broadcasted{IFStyle{Ni, A}}, IF{S, Ni, A}} -const BroadcastedUnionVIFH{S, Nv, Ni, A} = Union{Base.Broadcast.Broadcasted{VIFHStyle{Nv, Ni, A}}, VIFH{S, Nv, Ni, A}} -const BroadcastedUnionVIJFH{S, Nv, Nij, A} = Union{Base.Broadcast.Broadcasted{VIJFHStyle{Nv, Nij, A}}, VIJFH{S, Nv, Nij, A}} +const BroadcastedUnionVIHF{S, Nv, Ni, A} = Union{Base.Broadcast.Broadcasted{VIHFStyle{Nv, Ni, A}}, VIHF{S, Nv, Ni, A}} +const BroadcastedUnionVIJHF{S, Nv, Nij, A} = Union{Base.Broadcast.Broadcasted{VIJHFStyle{Nv, Nij, A}}, VIJHF{S, Nv, Nij, A}} const BroadcastedUnionVF{S, Nv, A} = Union{Base.Broadcast.Broadcasted{VFStyle{Nv, A}}, VF{S, Nv, A}} const BroadcastedUnionDataF{S, A} = Union{Base.Broadcast.Broadcasted{DataFStyle{A}}, DataF{S, A}} #! format: on @@ -108,27 +108,27 @@ Base.Broadcast.BroadcastStyle( ::IFStyle{Ni, A2}, ) where {Ni, A1, A2} = IFStyle{Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( - ::IFHStyle{Ni, A1}, - ::IFHStyle{Ni, A2}, -) where {Ni, A1, A2} = IFHStyle{Ni, promote_parent_array_type(A1, A2)}() + ::IHFStyle{Ni, A1}, + ::IHFStyle{Ni, A2}, +) where {Ni, A1, A2} = IHFStyle{Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( - ::VIFHStyle{Nv, Ni, A1}, - ::VIFHStyle{Nv, Ni, A2}, + ::VIHFStyle{Nv, Ni, A1}, + ::VIHFStyle{Nv, Ni, A2}, ) where {Nv, Ni, A1, A2} = - VIFHStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() + VIHFStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::IJFStyle{Nij, A1}, ::IJFStyle{Nij, A2}, ) where {Nij, A1, A2} = IJFStyle{Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( - ::IJFHStyle{Nij, A1}, - ::IJFHStyle{Nij, A2}, -) where {Nij, A1, A2} = IJFHStyle{Nij, promote_parent_array_type(A1, A2)}() + ::IJHFStyle{Nij, A1}, + ::IJHFStyle{Nij, A2}, +) where {Nij, A1, A2} = IJHFStyle{Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( - ::VIJFHStyle{Nv, Nij, A1}, - ::VIJFHStyle{Nv, Nij, A2}, + ::VIJHFStyle{Nv, Nij, A1}, + ::VIJHFStyle{Nv, Nij, A2}, ) where {Nv, Nij, A1, A2} = - VIJFHStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() + VIJHFStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::DataFStyle{A1}, @@ -147,61 +147,61 @@ Base.Broadcast.BroadcastStyle( Base.Broadcast.BroadcastStyle( ::DataFStyle{A1}, - ::IFHStyle{Ni, A2}, -) where {Ni, A1, A2} = IFHStyle{Ni, promote_parent_array_type(A1, A2)}() + ::IHFStyle{Ni, A2}, +) where {Ni, A1, A2} = IHFStyle{Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::DataFStyle{A1}, - ::IJFHStyle{Nij, A2}, -) where {Nij, A1, A2} = IJFHStyle{Nij, promote_parent_array_type(A1, A2)}() + ::IJHFStyle{Nij, A2}, +) where {Nij, A1, A2} = IJHFStyle{Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::DataFStyle{A1}, - ::VIFHStyle{Nv, Ni, A2}, + ::VIHFStyle{Nv, Ni, A2}, ) where {Nv, Ni, A1, A2} = - VIFHStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() + VIHFStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::DataFStyle{A1}, - ::VIJFHStyle{Nv, Nij, A2}, + ::VIJHFStyle{Nv, Nij, A2}, ) where {Nv, Nij, A1, A2} = - VIJFHStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() + VIJHFStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::VFStyle{Nv, A1}, - ::IFHStyle{Ni, A2}, + ::IHFStyle{Ni, A2}, ) where {Nv, Ni, A1, A2} = - VIFHStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() + VIHFStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::VFStyle{Nv, A1}, - ::IJFHStyle{Nij, A2}, + ::IJHFStyle{Nij, A2}, ) where {Nv, Nij, A1, A2} = - VIJFHStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() + VIJHFStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::VFStyle{Nv, A1}, - ::VIFHStyle{Nv, Ni, A2}, + ::VIHFStyle{Nv, Ni, A2}, ) where {Nv, Ni, A1, A2} = - VIFHStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() + VIHFStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( ::VFStyle{Nv, A1}, - ::VIJFHStyle{Nv, Nij, A2}, + ::VIJHFStyle{Nv, Nij, A2}, ) where {Nv, Nij, A1, A2} = - VIJFHStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() + VIJHFStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( - ::IFHStyle{Ni, A1}, - ::VIFHStyle{Nv, Ni, A2}, + ::IHFStyle{Ni, A1}, + ::VIHFStyle{Nv, Ni, A2}, ) where {Nv, Ni, A1, A2} = - VIFHStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() + VIHFStyle{Nv, Ni, promote_parent_array_type(A1, A2)}() Base.Broadcast.BroadcastStyle( - ::IJFHStyle{Nij, A1}, - ::VIJFHStyle{Nv, Nij, A2}, + ::IJHFStyle{Nij, A1}, + ::VIJHFStyle{Nv, Nij, A2}, ) where {Nv, Nij, A1, A2} = - VIJFHStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() + VIJHFStyle{Nv, Nij, promote_parent_array_type(A1, A2)}() Base.Broadcast.broadcastable(data::AbstractData) = data @@ -293,23 +293,23 @@ function Base.similar( end function Base.similar( - bc::BroadcastedUnionIJFH{<:Any, Nij, A}, + bc::BroadcastedUnionIJHF{<:Any, Nij, A}, ::Type{Eltype}, (_, _, _, _, Nh) = size(bc), ) where {Nij, A, Eltype} PA = parent_array_type(A) - array = similar(PA, (Nij, Nij, typesize(eltype(A), Eltype), Nh)) - return IJFH{Eltype, Nij}(array) + array = similar(PA, (Nij, Nij, Nh, typesize(eltype(A), Eltype))) + return IJHF{Eltype, Nij}(array) end function Base.similar( - bc::BroadcastedUnionIFH{<:Any, Ni, A}, + bc::BroadcastedUnionIHF{<:Any, Ni, A}, ::Type{Eltype}, (_, _, _, _, Nh) = size(bc), ) where {Ni, A, Eltype} PA = parent_array_type(A) - array = similar(PA, (Ni, typesize(eltype(A), Eltype), Nh)) - return IFH{Eltype, Ni}(array) + array = similar(PA, (Ni, Nh, typesize(eltype(A), Eltype))) + return IHF{Eltype, Ni}(array) end function Base.similar( @@ -346,35 +346,35 @@ function Base.similar( end Base.similar( - bc::BroadcastedUnionVIFH{<:Any, Nv}, + bc::BroadcastedUnionVIHF{<:Any, Nv}, ::Type{Eltype}, ) where {Nv, Eltype} = Base.similar(bc, Eltype, Val(Nv)) function Base.similar( - bc::BroadcastedUnionVIFH{<:Any, Nv, Ni, A}, + bc::BroadcastedUnionVIHF{<:Any, Nv, Ni, A}, ::Type{Eltype}, ::Val{newNv}, ) where {Nv, Ni, A, Eltype, newNv} (_, _, _, _, Nh) = size(bc) PA = parent_array_type(A) - array = similar(PA, (newNv, Ni, typesize(eltype(A), Eltype), Nh)) - return VIFH{Eltype, newNv, Ni}(array) + array = similar(PA, (newNv, Ni, Nh, typesize(eltype(A), Eltype))) + return VIHF{Eltype, newNv, Ni}(array) end Base.similar( - bc::BroadcastedUnionVIJFH{<:Any, Nv, Nij, A}, + bc::BroadcastedUnionVIJHF{<:Any, Nv, Nij, A}, ::Type{Eltype}, ) where {Nv, Nij, A, Eltype} = similar(bc, Eltype, Val(Nv)) function Base.similar( - bc::BroadcastedUnionVIJFH{<:Any, Nv, Nij, A}, + bc::BroadcastedUnionVIJHF{<:Any, Nv, Nij, A}, ::Type{Eltype}, ::Val{newNv}, ) where {Nv, Nij, A, Eltype, newNv} (_, _, _, _, Nh) = size(bc) PA = parent_array_type(A) - array = similar(PA, (newNv, Nij, Nij, typesize(eltype(A), Eltype), Nh)) - return VIJFH{Eltype, newNv, Nij}(array) + array = similar(PA, (newNv, Nij, Nij, Nh, typesize(eltype(A), Eltype))) + return VIJHF{Eltype, newNv, Nij}(array) end # ============= FusedMultiBroadcast diff --git a/src/DataLayouts/copyto.jl b/src/DataLayouts/copyto.jl index ec82a918f1..ce8a9de1fc 100644 --- a/src/DataLayouts/copyto.jl +++ b/src/DataLayouts/copyto.jl @@ -44,8 +44,8 @@ function Base.copyto!( end function Base.copyto!( - dest::IJFH{S, Nij}, - bc::BroadcastedUnionIJFH{S, Nij}, + dest::IJHF{S, Nij}, + bc::BroadcastedUnionIJHF{S, Nij}, ::ToCPU, ) where {S, Nij} (_, _, _, _, Nh) = size(dest) @@ -57,8 +57,8 @@ function Base.copyto!( end function Base.copyto!( - dest::IFH{S, Ni}, - bc::BroadcastedUnionIFH{S, Ni}, + dest::IHF{S, Ni}, + bc::BroadcastedUnionIHF{S, Ni}, ::ToCPU, ) where {S, Ni} (_, _, _, _, Nh) = size(dest) @@ -121,8 +121,8 @@ function Base.copyto!( end function Base.copyto!( - dest::VIFH{S, Nv, Ni}, - bc::BroadcastedUnionVIFH{S, Nv, Ni}, + dest::VIHF{S, Nv, Ni}, + bc::BroadcastedUnionVIHF{S, Nv, Ni}, ::ToCPU, ) where {S, Nv, Ni} # copy contiguous columns @@ -135,8 +135,8 @@ function Base.copyto!( end function Base.copyto!( - dest::VIJFH{S, Nv, Nij}, - bc::BroadcastedUnionVIJFH{S, Nv, Nij}, + dest::VIJHF{S, Nv, Nij}, + bc::BroadcastedUnionVIJHF{S, Nv, Nij}, ::ToCPU, ) where {S, Nv, Nij} # copy contiguous columns diff --git a/src/DataLayouts/fill.jl b/src/DataLayouts/fill.jl index c165e61b2a..f097cf5362 100644 --- a/src/DataLayouts/fill.jl +++ b/src/DataLayouts/fill.jl @@ -1,4 +1,4 @@ -function Base.fill!(data::IJFH, val, ::ToCPU) +function Base.fill!(data::IJHF, val, ::ToCPU) (_, _, _, _, Nh) = size(data) @inbounds for h in 1:Nh fill!(slab(data, h), val) @@ -6,7 +6,7 @@ function Base.fill!(data::IJFH, val, ::ToCPU) return data end -function Base.fill!(data::IFH, val, ::ToCPU) +function Base.fill!(data::IHF, val, ::ToCPU) (_, _, _, _, Nh) = size(data) @inbounds for h in 1:Nh fill!(slab(data, h), val) @@ -41,7 +41,7 @@ function Base.fill!(data::VF, val, ::ToCPU) return data end -function Base.fill!(data::VIJFH, val, ::ToCPU) +function Base.fill!(data::VIJHF, val, ::ToCPU) (Ni, Nj, _, Nv, Nh) = size(data) @inbounds for h in 1:Nh, v in 1:Nv fill!(slab(data, v, h), val) @@ -49,7 +49,7 @@ function Base.fill!(data::VIJFH, val, ::ToCPU) return data end -function Base.fill!(data::VIFH, val, ::ToCPU) +function Base.fill!(data::VIHF, val, ::ToCPU) (Ni, _, _, Nv, Nh) = size(data) @inbounds for h in 1:Nh, v in 1:Nv fill!(slab(data, v, h), val) diff --git a/src/DataLayouts/fused_copyto.jl b/src/DataLayouts/fused_copyto.jl index 93010cc888..3fe5ce0e5d 100644 --- a/src/DataLayouts/fused_copyto.jl +++ b/src/DataLayouts/fused_copyto.jl @@ -23,7 +23,7 @@ end function fused_copyto!( fmbc::FusedMultiBroadcast, - dest1::VIJFH{S1, Nv1, Nij}, + dest1::VIJHF{S1, Nv1, Nij}, ::ToCPU, ) where {S1, Nv1, Nij} for (dest, bc) in fmbc.pairs @@ -40,7 +40,7 @@ end function fused_copyto!( fmbc::FusedMultiBroadcast, - dest1::IJFH{S, Nij}, + dest1::IJHF{S, Nij}, ::ToCPU, ) where {S, Nij} # copy contiguous columns @@ -58,7 +58,7 @@ end function fused_copyto!( fmbc::FusedMultiBroadcast, - dest1::VIFH{S, Nv1, Ni}, + dest1::VIHF{S, Nv1, Ni}, ::ToCPU, ) where {S, Nv1, Ni} # copy contiguous columns diff --git a/src/DataLayouts/mapreduce.jl b/src/DataLayouts/mapreduce.jl index a67f86941f..98850199b0 100644 --- a/src/DataLayouts/mapreduce.jl +++ b/src/DataLayouts/mapreduce.jl @@ -15,7 +15,7 @@ end function Base.mapreduce( fn::F, op::Op, - bc::BroadcastedUnionIJFH{<:Any, Nij, A}, + bc::BroadcastedUnionIJHF{<:Any, Nij, A}, ) where {F, Op, Nij, A} # mapreduce across DataSlab2D (_, _, _, _, Nh) = size(bc) @@ -29,7 +29,7 @@ end function Base.mapreduce( fn::F, op::Op, - bc::BroadcastedUnionIFH{<:Any, Ni, A}, + bc::BroadcastedUnionIHF{<:Any, Ni, A}, ) where {F, Op, Ni, A} # mapreduce across DataSlab1D (_, _, _, _, Nh) = size(bc) @@ -77,7 +77,7 @@ end function Base.mapreduce( fn::F, op::Op, - bc::BroadcastedUnionVIFH{<:Any, Nv, Ni, A}, + bc::BroadcastedUnionVIHF{<:Any, Nv, Ni, A}, ) where {F, Op, Nv, Ni, A} # mapreduce across columns (_, _, _, _, Nh) = size(bc) @@ -91,7 +91,7 @@ end function Base.mapreduce( fn::F, op::Op, - bc::BroadcastedUnionVIJFH{<:Any, Nv, Nij, A}, + bc::BroadcastedUnionVIJHF{<:Any, Nv, Nij, A}, ) where {F, Op, Nv, Nij, A} # mapreduce across columns (_, _, _, _, Nh) = size(bc) diff --git a/src/Grids/spectralelement.jl b/src/Grids/spectralelement.jl index c304b2e86f..ba83fa77ef 100644 --- a/src/Grids/spectralelement.jl +++ b/src/Grids/spectralelement.jl @@ -60,7 +60,7 @@ function _SpectralElementGrid1D( Nq = Quadratures.degrees_of_freedom(quadrature_style) LG = Geometry.LocalGeometry{AIdx, CoordType, FT, SMatrix{1, 1, FT, 1}} - local_geometry = DataLayouts.IFH{LG, Nq}(Array{FT}, Nh) + local_geometry = DataLayouts.IHF{LG, Nq}(Array{FT}, Nh) quad_points, quad_weights = Quadratures.quadrature_points(FT, quadrature_style) @@ -241,7 +241,7 @@ function _SpectralElementGrid2D( LG = Geometry.LocalGeometry{AIdx, CoordType2D, FT, SMatrix{2, 2, FT, 4}} - local_geometry = DataLayouts.IJFH{LG, Nq}(Array{FT}, Nh) + local_geometry = DataLayouts.IJHF{LG, Nq}(Array{FT}, Nh) quad_points, quad_weights = Quadratures.quadrature_points(FT, quadrature_style) @@ -399,7 +399,7 @@ function _SpectralElementGrid2D( if quadrature_style isa Quadratures.GLL internal_surface_geometry = - DataLayouts.IFH{SG, Nq}(Array{FT}, length(interior_faces)) + DataLayouts.IHF{SG, Nq}(Array{FT}, length(interior_faces)) for (iface, (lidx⁻, face⁻, lidx⁺, face⁺, reversed)) in enumerate(interior_faces) internal_surface_geometry_slab = @@ -438,7 +438,7 @@ function _SpectralElementGrid2D( boundary_faces = Topologies.boundary_faces(topology, boundarytag) boundary_surface_geometry = - DataLayouts.IFH{SG, Nq}(Array{FT}, length(boundary_faces)) + DataLayouts.IHF{SG, Nq}(Array{FT}, length(boundary_faces)) for (iface, (elem, face)) in enumerate(boundary_faces) boundary_surface_geometry_slab = slab(boundary_surface_geometry, iface) diff --git a/src/InputOutput/readers.jl b/src/InputOutput/readers.jl index 2fa02f09e1..c7f5cc6805 100644 --- a/src/InputOutput/readers.jl +++ b/src/InputOutput/readers.jl @@ -145,23 +145,23 @@ function _scan_quadrature_style(quadraturestring::AbstractString, npts) end function _scan_data_layout(layoutstring::AbstractString) - @assert layoutstring ∈ ("IJFH", "IJF", "IFH", "IF", "VIJFH", "VIFH") - layoutstring == "IJFH" && return DataLayouts.IJFH + @assert layoutstring ∈ ("IJHF", "IJF", "IHF", "IF", "VIJHF", "VIHF") + layoutstring == "IJHF" && return DataLayouts.IJHF layoutstring == "IJF" && return DataLayouts.IJF - layoutstring == "IFH" && return DataLayouts.IFH + layoutstring == "IHF" && return DataLayouts.IHF layoutstring == "IF" && return DataLayouts.IF - layoutstring == "VIJFH" && return DataLayouts.VIJFH - return DataLayouts.VIFH + layoutstring == "VIJHF" && return DataLayouts.VIJHF + return DataLayouts.VIHF end # for when Nh is in type-domain # function Nh_dim(layoutstring::AbstractString) -# @assert layoutstring ∈ ("IJFH", "IJF", "IFH", "IF", "VIJFH", "VIFH") -# layoutstring == "IJFH" && return 4 +# @assert layoutstring ∈ ("IJHF", "IJF", "IHF", "IF", "VIJHF", "VIHF") +# layoutstring == "IJHF" && return 4 # layoutstring == "IJF" && return -1 -# layoutstring == "IFH" && return 3 +# layoutstring == "IHF" && return 3 # layoutstring == "IF" && return -1 -# layoutstring == "VIJFH" && return 5 +# layoutstring == "VIJHF" && return 5 # return 4 # end @@ -469,7 +469,9 @@ function read_field(reader::HDF5Reader, name::AbstractString) ArrayType = ClimaComms.array_type(topology) if topology isa Topologies.Topology2D nd = ndims(obj) - localidx = ntuple(d -> d < nd ? (:) : topology.local_elem_gidx, nd) + h_dim = nd - 1 + localidx = + ntuple(d -> d == h_dim ? topology.local_elem_gidx : (:), nd) data = ArrayType(obj[localidx...]) else data = ArrayType(read(obj)) @@ -481,7 +483,7 @@ function read_field(reader::HDF5Reader, name::AbstractString) # Nhd = Nh_dim(data_layout) # Nht = Nhd == -1 ? () : (size(data, Nhd),) ElType = eval(Meta.parse(attrs(obj)["value_type"])) - if data_layout in ("VIJFH", "VIFH") + if data_layout in ("VIJHF", "VIHF") Nv = size(data, 1) # values = DataLayout{ElType, Nv, Nij, Nht...}(data) # when Nh is in type-domain values = DataLayout{ElType, Nv, Nij}(data) diff --git a/src/InputOutput/writers.jl b/src/InputOutput/writers.jl index 68576886d5..951d0694ba 100644 --- a/src/InputOutput/writers.jl +++ b/src/InputOutput/writers.jl @@ -435,7 +435,8 @@ function write!(writer::HDF5Writer, field::Fields.Field, name::AbstractString) !(writer.context isa ClimaComms.SingletonCommsContext) nelems = Topologies.nelems(topology) dims = ntuple(d -> d == nd ? nelems : size(array, d), nd) - localidx = ntuple(d -> d < nd ? (:) : topology.local_elem_gidx, nd) + h_dim = nd - 1 + localidx = ntuple(d -> d == h_dim ? topology.local_elem_gidx : (:), nd) dataset = create_dataset( writer.file, "fields/$name", diff --git a/src/Limiters/quasimonotone.jl b/src/Limiters/quasimonotone.jl index 9f41645948..62d55414f9 100644 --- a/src/Limiters/quasimonotone.jl +++ b/src/Limiters/quasimonotone.jl @@ -68,18 +68,18 @@ function QuasiMonotoneLimiter(ρq::Fields.Field; rtol = eps(eltype(parent(ρq))) end function make_q_bounds( - ρq::Union{DataLayouts.IFH{S}, DataLayouts.IJFH{S}}, + ρq::Union{DataLayouts.IHF{S}, DataLayouts.IJHF{S}}, ) where {S} Nf = DataLayouts.ncomponents(ρq) _, _, _, _, Nh = size(ρq) - return DataLayouts.IFH{S, 2}(similar(parent(ρq), (2, Nf, Nh))) + return DataLayouts.IHF{S, 2}(similar(parent(ρq), (2, Nh, Nf))) end function make_q_bounds( - ρq::Union{DataLayouts.VIFH{S}, DataLayouts.VIJFH{S}}, + ρq::Union{DataLayouts.VIHF{S}, DataLayouts.VIJHF{S}}, ) where {S} Nf = DataLayouts.ncomponents(ρq) _, _, _, Nv, Nh = size(ρq) - return DataLayouts.VIFH{S, Nv, 2}(similar(parent(ρq), (Nv, 2, Nf, Nh))) + return DataLayouts.VIHF{S, Nv, 2}(similar(parent(ρq), (Nv, 2, Nh, Nf))) end diff --git a/src/Spaces/dss.jl b/src/Spaces/dss.jl index 607a1487c7..343ce5d9c0 100644 --- a/src/Spaces/dss.jl +++ b/src/Spaces/dss.jl @@ -20,14 +20,14 @@ perimeter(space::AbstractSpectralElementSpace) = Topologies.Perimeter2D( """ create_dss_buffer( - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, hspace::AbstractSpectralElementSpace, ) Creates a [`DSSBuffer`](@ref) for the field data corresponding to `data` """ function create_dss_buffer( - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, hspace::SpectralElementSpace2D, ) create_dss_buffer( @@ -39,7 +39,7 @@ function create_dss_buffer( end function create_dss_buffer( - data::Union{DataLayouts.IFH, DataLayouts.VIFH}, + data::Union{DataLayouts.IHF, DataLayouts.VIHF}, hspace::SpectralElementSpace1D, ) nothing @@ -48,10 +48,10 @@ end """ function weighted_dss!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{ AbstractSpectralElementSpace, @@ -72,10 +72,10 @@ It comprises of the following steps: """ function weighted_dss!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{AbstractSpectralElementSpace, ExtrudedFiniteDifferenceSpace}, dss_buffer::Union{DSSBuffer, Nothing}, @@ -92,7 +92,7 @@ function weighted_dss_prepare!(data, space, dss_buffer::Nothing) end function weighted_dss_prepare!( - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, space::Union{ Spaces.SpectralElementSpace2D, Spaces.ExtrudedFiniteDifferenceSpace, @@ -127,10 +127,10 @@ cuda_synchronize(device::ClimaComms.AbstractDevice; kwargs...) = nothing """ weighted_dss_start!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{ AbstractSpectralElementSpace, @@ -155,7 +155,7 @@ representative ghost vertices which store result of "ghost local" DSS are loaded 4). Start DSS communication with neighboring processes """ function weighted_dss_start!( - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, space::Union{ Spaces.SpectralElementSpace2D, Spaces.ExtrudedFiniteDifferenceSpace, @@ -175,10 +175,10 @@ weighted_dss_start!(data, space, dss_buffer::Nothing) = nothing """ weighted_dss_internal!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{ AbstractSpectralElementSpace, @@ -196,10 +196,10 @@ and perimeter elements to facilitate overlapping of communication with computati """ weighted_dss_internal!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{AbstractSpectralElementSpace, ExtrudedFiniteDifferenceSpace}, dss_buffer::Union{DSSBuffer, Nothing}, @@ -208,10 +208,10 @@ weighted_dss_internal!( function weighted_dss_internal!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{AbstractSpectralElementSpace, ExtrudedFiniteDifferenceSpace}, hspace::AbstractSpectralElementSpace, @@ -259,10 +259,10 @@ end """ weighted_dss_ghost!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{ AbstractSpectralElementSpace, @@ -284,10 +284,10 @@ This transforms the DSS'd local vectors back to Covariant12 vectors, and copies """ weighted_dss_ghost!( data::Union{ - DataLayouts.IFH, - DataLayouts.VIFH, - DataLayouts.IJFH, - DataLayouts.VIJFH, + DataLayouts.IHF, + DataLayouts.VIHF, + DataLayouts.IJHF, + DataLayouts.VIJHF, }, space::Union{AbstractSpectralElementSpace, ExtrudedFiniteDifferenceSpace}, dss_buffer::Union{DSSBuffer, Nothing}, @@ -296,7 +296,7 @@ weighted_dss_ghost!( function weighted_dss_ghost!( - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, space::Union{AbstractSpectralElementSpace, ExtrudedFiniteDifferenceSpace}, hspace::SpectralElementSpace2D, dss_buffer::DSSBuffer, diff --git a/src/Topologies/dss.jl b/src/Topologies/dss.jl index 281c6a2dbc..838998d4b4 100644 --- a/src/Topologies/dss.jl +++ b/src/Topologies/dss.jl @@ -11,7 +11,7 @@ struct DSSBuffer{S, G, D, A, B, VI} "ClimaComms graph context for communication" graph_context::G """ - Perimeter `DataLayout` object: typically a `VIFH{TT,Nv,Np,Nh}`, where `TT` is the + Perimeter `DataLayout` object: typically a `VIHF{TT,Nv,Np,Nh}`, where `TT` is the transformed type, `Nv` is the number of vertical levels, and `Np` is the length of the perimeter """ perimeter_data::D @@ -31,7 +31,7 @@ end """ create_dss_buffer( - data::Union{DataLayouts.IJFH{S}, DataLayouts.VIJFH{S}}, + data::Union{DataLayouts.IJHF{S}, DataLayouts.VIJHF{S}}, topology::Topology2D, local_geometry = nothing, local_weights = nothing, @@ -40,10 +40,10 @@ end Creates a [`DSSBuffer`](@ref) for the field data corresponding to `data` """ function create_dss_buffer( - data::Union{DataLayouts.IJFH{S}, DataLayouts.VIJFH{S}}, + data::Union{DataLayouts.IJHF{S}, DataLayouts.VIJHF{S}}, topology::Topology2D, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH, Nothing} = nothing, - local_weights::Union{DataLayouts.IJFH, DataLayouts.VIJFH, Nothing} = nothing, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF, Nothing} = nothing, + local_weights::Union{DataLayouts.IJHF, DataLayouts.VIJHF, Nothing} = nothing, ) where {S} Nij = DataLayouts.get_Nij(data) Nij_lg = @@ -70,7 +70,7 @@ function create_dss_buffer( else _transformed_type(data, local_geometry, local_weights, DA) # extract transformed type end - perimeter_data = DataLayouts.VIFH{TS, Nv, Np}(DA{T}(undef, Nv, Np, Nf, Nh)) + perimeter_data = DataLayouts.VIHF{TS, Nv, Np}(DA{T}(undef, Nv, Np, Nh, Nf)) if context isa ClimaComms.SingletonCommsContext graph_context = ClimaComms.SingletonGraphContext(context) send_data, recv_data = T[], T[] @@ -131,9 +131,9 @@ assert_same_eltype(::DataLayouts.AbstractData, ::Nothing) = nothing function dss_transform!( device::ClimaComms.AbstractDevice, dss_buffer::DSSBuffer, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - weight::DataLayouts.IJFH, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + weight::DataLayouts.IJHF, perimeter::AbstractPerimeter, localelems::Vector{Int}, ) @@ -156,9 +156,9 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). function dss_transform!( device::ClimaComms.AbstractDevice, dss_buffer::DSSBuffer, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - weight::DataLayouts.IJFH, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + weight::DataLayouts.IJHF, perimeter::Perimeter2D, localelems::AbstractVector{Int}, ) @@ -200,8 +200,8 @@ to `UVVector` if `T <: UVVector`. """ function dss_transform!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::AbstractPerimeter, bc, localelems::Vector{Int}, @@ -222,8 +222,8 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). """ function dss_transform!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.VIJFH, DataLayouts.IJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.VIJHF, DataLayouts.IJHF}, perimeter::Perimeter2D{Nq}, local_geometry, weight, @@ -254,8 +254,8 @@ end dss_untransform!( device::ClimaComms.AbstractDevice, dss_buffer::DSSBuffer, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::AbstractPerimeter, ) @@ -276,8 +276,8 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). function dss_untransform!( device::ClimaComms.AbstractDevice, dss_buffer::DSSBuffer, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Perimeter2D, localelems::AbstractVector{Int}, ) @@ -297,8 +297,8 @@ end """ function dss_untransform!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, local_geometry, localelems::Vector{Int}, ) @@ -317,9 +317,9 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). function dss_untransform!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, - data::Union{DataLayouts.VIJFH, DataLayouts.IJFH}, - local_geometry::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + perimeter_data::DataLayouts.VIHF, + data::Union{DataLayouts.VIJHF, DataLayouts.IJHF}, + local_geometry::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Perimeter2D, localelems::Vector{Int}, ) @@ -342,7 +342,7 @@ end function dss_load_perimeter_data!( ::ClimaComms.AbstractCPUDevice, dss_buffer::DSSBuffer, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, perimeter::Perimeter2D, ) (; perimeter_data) = dss_buffer @@ -359,7 +359,7 @@ end function dss_unload_perimeter_data!( ::ClimaComms.AbstractCPUDevice, - data::Union{DataLayouts.IJFH, DataLayouts.VIJFH}, + data::Union{DataLayouts.IJHF, DataLayouts.VIJHF}, dss_buffer::DSSBuffer, perimeter::Perimeter2D, ) @@ -378,7 +378,7 @@ end """ function dss_local!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::AbstractPerimeter, topology::AbstractTopology, ) @@ -389,7 +389,7 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). """ function dss_local!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Perimeter2D, topology::Topology2D, ) @@ -400,7 +400,7 @@ end """ dss_local_vertices!( - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Perimeter2D, topology::Topology2D, ) @@ -408,7 +408,7 @@ end Apply dss to local vertices. """ function dss_local_vertices!( - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Perimeter2D, topology::Topology2D, ) @@ -438,7 +438,7 @@ function dss_local_vertices!( end function dss_local_faces!( - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::Perimeter2D, topology::Topology2D, ) @@ -466,7 +466,7 @@ end """ function dss_local_ghost!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::AbstractPerimeter, topology::AbstractTopology, ) @@ -479,7 +479,7 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). """ function dss_local_ghost!( ::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::AbstractPerimeter, topology::AbstractTopology, ) @@ -524,7 +524,7 @@ end """ dss_ghost!( device::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::AbstractPerimeter, topology::AbstractTopology, ) @@ -536,7 +536,7 @@ Part of [`ClimaCore.Spaces.weighted_dss!`](@ref). """ function dss_ghost!( device::ClimaComms.AbstractCPUDevice, - perimeter_data::DataLayouts.VIFH, + perimeter_data::DataLayouts.VIHF, perimeter::AbstractPerimeter, topology::AbstractTopology, ) @@ -632,7 +632,7 @@ end Computed unweighted/pure DSS of `data`. """ function dss!( - data::Union{DataLayouts.IJFH{S, Nij}, DataLayouts.VIJFH{S, <:Any, Nij}}, + data::Union{DataLayouts.IJHF{S, Nij}, DataLayouts.VIJHF{S, <:Any, Nij}}, topology::Topology2D, ) where {S, Nij} length(parent(data)) == 0 && return nothing diff --git a/src/Topologies/dss_transform.jl b/src/Topologies/dss_transform.jl index 5cd23a3470..a03085338b 100644 --- a/src/Topologies/dss_transform.jl +++ b/src/Topologies/dss_transform.jl @@ -250,7 +250,7 @@ recv_buffer(ghost::GhostBuffer) = ghost.recv_data create_ghost_buffer(data, topology::Topologies.AbstractTopology) = nothing create_ghost_buffer( - data::Union{DataLayouts.IJFH{S, Nij}, DataLayouts.VIJFH{S, <:Any, Nij}}, + data::Union{DataLayouts.IJHF{S, Nij}, DataLayouts.VIJHF{S, <:Any, Nij}}, topology::Topologies.Topology2D, ) where {S, Nij} = create_ghost_buffer( data, @@ -261,22 +261,22 @@ create_ghost_buffer( function create_ghost_buffer( - data::Union{DataLayouts.IJFH{S, Nij}, DataLayouts.VIJFH{S, <:Any, Nij}}, + data::Union{DataLayouts.IJHF{S, Nij}, DataLayouts.VIJHF{S, <:Any, Nij}}, topology::Topologies.Topology2D, Nhsend, Nhrec, ) where {S, Nij} - if data isa DataLayouts.IJFH - send_data = DataLayouts.IJFH{S, Nij}(typeof(parent(data)), Nhsend) - recv_data = DataLayouts.IJFH{S, Nij}(typeof(parent(data)), Nhrec) + if data isa DataLayouts.IJHF + send_data = DataLayouts.IJHF{S, Nij}(typeof(parent(data)), Nhsend) + recv_data = DataLayouts.IJHF{S, Nij}(typeof(parent(data)), Nhrec) k = stride(parent(send_data), 4) else Nv, _, _, Nf, _ = DataLayouts.farray_size(data) - send_data = DataLayouts.VIJFH{S, Nv, Nij}( - similar(parent(data), (Nv, Nij, Nij, Nf, Nhsend)), + send_data = DataLayouts.VIJHF{S, Nv, Nij}( + similar(parent(data), (Nv, Nij, Nij, Nhsend, Nf)), ) - recv_data = DataLayouts.VIJFH{S, Nv, Nij}( - similar(parent(data), (Nv, Nij, Nij, Nf, Nhrec)), + recv_data = DataLayouts.VIJHF{S, Nv, Nij}( + similar(parent(data), (Nv, Nij, Nij, Nhrec, Nf)), ) k = stride(parent(send_data), 5) end diff --git a/test/DataLayouts/benchmark_copyto.jl b/test/DataLayouts/benchmark_copyto.jl index ead88942f8..29856769f4 100644 --- a/test/DataLayouts/benchmark_copyto.jl +++ b/test/DataLayouts/benchmark_copyto.jl @@ -51,10 +51,10 @@ end data = DataF{S}(ArrayType{FT}, zeros) benchmarkcopyto!(bm, device, data, 3) @test all(parent(data) .== 3) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) benchmarkcopyto!(bm, device, data, 3) @test all(parent(data) .== 3) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) benchmarkcopyto!(bm, device, data, 3) @test all(parent(data) .== 3) # The parent array of IJF and IF datalayouts are MArrays, and can therefore not bm, be passed into CUDA kernels on the RHS. @@ -63,10 +63,10 @@ end data = VF{S}(ArrayType{FT}, zeros; Nv) benchmarkcopyto!(bm, device, data, 3) @test all(parent(data) .== 3) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) benchmarkcopyto!(bm, device, data, 3) @test all(parent(data) .== 3) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) benchmarkcopyto!(bm, device, data, 3) @test all(parent(data) .== 3) diff --git a/test/DataLayouts/benchmark_fill.jl b/test/DataLayouts/benchmark_fill.jl index 0ec876eb93..09d52e22eb 100644 --- a/test/DataLayouts/benchmark_fill.jl +++ b/test/DataLayouts/benchmark_fill.jl @@ -48,10 +48,10 @@ end data = DataF{S}(ArrayType{FT}, zeros) benchmarkfill!(bm, device, data, 3) @test all(parent(data) .== 3) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) benchmarkfill!(bm, device, data, 3) @test all(parent(data) .== 3) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) benchmarkfill!(bm, device, data, 3) @test all(parent(data) .== 3) data = IJF{S}(ArrayType{FT}, zeros; Nij) @@ -63,10 +63,10 @@ end data = VF{S}(ArrayType{FT}, zeros; Nv) benchmarkfill!(bm, device, data, 3) @test all(parent(data) .== 3) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) benchmarkfill!(bm, device, data, 3) @test all(parent(data) .== 3) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) benchmarkfill!(bm, device, data, 3) @test all(parent(data) .== 3) diff --git a/test/DataLayouts/cuda.jl b/test/DataLayouts/cuda.jl index ac8d84e4c4..4977492695 100644 --- a/test/DataLayouts/cuda.jl +++ b/test/DataLayouts/cuda.jl @@ -32,8 +32,8 @@ end device = ClimaComms.device() ArrayType = ClimaComms.array_type(device) Nh = 10 - src = IJFH{S}(ArrayType{Float64}, rand; Nij = 4, Nh) - dst = IJFH{S}(ArrayType{Float64}, zeros; Nij = 4, Nh) + src = IJHF{S}(ArrayType{Float64}, rand; Nij = 4, Nh) + dst = IJHF{S}(ArrayType{Float64}, zeros; Nij = 4, Nh) test_copy!(dst, src) @@ -47,23 +47,23 @@ end Nh = 2 device = ClimaComms.device() ArrayType = ClimaComms.array_type(device) - data1 = IJFH{S1}(ArrayType{FT}, ones; Nij = 2, Nh) - data2 = IJFH{S2}(ArrayType{FT}, ones; Nij = 2, Nh) + data1 = IJHF{S1}(ArrayType{FT}, ones; Nij = 2, Nh) + data2 = IJHF{S2}(ArrayType{FT}, ones; Nij = 2, Nh) f1(a1, a2) = a1.a.re * a2 + a1.b res = f1.(data1, data2) - @test res isa IJFH{Float64} - @test Array(parent(res)) == FT[2 for i in 1:2, j in 1:2, f in 1:1, h in 1:2] + @test res isa IJHF{Float64} + @test Array(parent(res)) == FT[2 for i in 1:2, j in 1:2, h in 1:2, f in 1:1] Nv = 33 - data1 = VIJFH{S1}(ArrayType{FT}, ones; Nv, Nij = 4, Nh = 2) - data2 = VIJFH{S2}(ArrayType{FT}, ones; Nv, Nij = 4, Nh = 2) + data1 = VIJHF{S1}(ArrayType{FT}, ones; Nv, Nij = 4, Nh = 2) + data2 = VIJHF{S2}(ArrayType{FT}, ones; Nv, Nij = 4, Nh = 2) f2(a1, a2) = a1.a.re * a2 + a1.b res = f2.(data1, data2) - @test res isa VIJFH{Float64, Nv} + @test res isa VIJHF{Float64, Nv} @test Array(parent(res)) == - FT[2 for v in 1:Nv, i in 1:4, j in 1:4, f in 1:1, h in 1:2] + FT[2 for v in 1:Nv, i in 1:4, j in 1:4, h in 1:2, f in 1:1] end @@ -73,16 +73,16 @@ end Nh = 3 device = ClimaComms.device() ArrayType = ClimaComms.array_type(device) - data = IJFH{S}(ArrayType{FT}; Nij = 2, Nh) + data = IJHF{S}(ArrayType{FT}; Nij = 2, Nh) data .= Complex(1.0, 2.0) @test Array(parent(data)) == - FT[f == 1 ? 1 : 2 for i in 1:2, j in 1:2, f in 1:2, h in 1:3] + FT[f == 1 ? 1 : 2 for i in 1:2, j in 1:2, h in 1:3, f in 1:2] Nv = 33 - data = VIJFH{S}(ArrayType{FT}; Nv, Nij = 4, Nh) + data = VIJHF{S}(ArrayType{FT}; Nv, Nij = 4, Nh) data .= Complex(1.0, 2.0) @test Array(parent(data)) == FT[ - f == 1 ? 1 : 2 for v in 1:Nv, i in 1:4, j in 1:4, f in 1:2, h in 1:3 + f == 1 ? 1 : 2 for v in 1:Nv, i in 1:4, j in 1:4, h in 1:3, f in 1:2 ] data = DataF{S}(ArrayType{FT}) diff --git a/test/DataLayouts/data0d.jl b/test/DataLayouts/data0d.jl index 3b09eee70d..a82460a5da 100644 --- a/test/DataLayouts/data0d.jl +++ b/test/DataLayouts/data0d.jl @@ -123,15 +123,15 @@ end @test size(data_if2) == (2, 1, 1, 1, 1) end -@testset "broadcasting DataF + IFH data object => IFH" begin +@testset "broadcasting DataF + IHF data object => IHF" begin FT = Float64 S = Complex{FT} Nh = 3 data_f = DataF{S}(ArrayType{FT}, ones) - data_ifh = IFH{S}(ArrayType{FT}, ones; Ni = 2, Nh) - data_ifh2 = data_f .+ data_ifh - @test data_ifh2 isa IFH{S} - @test size(data_ifh2) == (2, 1, 1, 1, 3) + data_ihf = IHF{S}(ArrayType{FT}, ones; Ni = 2, Nh) + data_ihf2 = data_f .+ data_ihf + @test data_ihf2 isa IHF{S} + @test size(data_ihf2) == (2, 1, 1, 1, 3) end @testset "broadcasting DataF + IJF data object => IJF" begin @@ -144,39 +144,39 @@ end @test size(data_ijf2) == (2, 2, 1, 1, 1) end -@testset "broadcasting DataF + IJFH data object => IJFH" begin +@testset "broadcasting DataF + IJHF data object => IJHF" begin FT = Float64 S = Complex{FT} Nh = 3 data_f = DataF{S}(ArrayType{FT}, ones) - data_ijfh = IJFH{S}(ArrayType{FT}, ones; Nij = 2, Nh) - data_ijfh2 = data_f .+ data_ijfh - @test data_ijfh2 isa IJFH{S} - @test size(data_ijfh2) == (2, 2, 1, 1, Nh) + data_ijhf = IJHF{S}(ArrayType{FT}, ones; Nij = 2, Nh) + data_ijhf2 = data_f .+ data_ijhf + @test data_ijhf2 isa IJHF{S} + @test size(data_ijhf2) == (2, 2, 1, 1, Nh) end -@testset "broadcasting DataF + VIFH data object => VIFH" begin +@testset "broadcasting DataF + VIHF data object => VIHF" begin FT = Float64 S = Complex{FT} Nh = 10 data_f = DataF{S}(ArrayType{FT}, ones) Nv = 10 - data_vifh = VIFH{S}(ArrayType{FT}, ones; Nv, Ni = 4, Nh) - data_vifh2 = data_f .+ data_vifh - @test data_vifh2 isa VIFH{S, Nv} - @test size(data_vifh2) == (4, 1, 1, Nv, Nh) + data_vihf = VIHF{S}(ArrayType{FT}, ones; Nv, Ni = 4, Nh) + data_vihf2 = data_f .+ data_vihf + @test data_vihf2 isa VIHF{S, Nv} + @test size(data_vihf2) == (4, 1, 1, Nv, Nh) end -@testset "broadcasting DataF + VIJFH data object => VIJFH" begin +@testset "broadcasting DataF + VIJHF data object => VIJHF" begin FT = Float64 S = Complex{FT} Nv = 2 Nh = 2 data_f = DataF{S}(ArrayType{FT}, ones) - data_vijfh = VIJFH{S}(ArrayType{FT}, ones; Nv, Nij = 2, Nh) - data_vijfh2 = data_f .+ data_vijfh - @test data_vijfh2 isa VIJFH{S, Nv} - @test size(data_vijfh2) == (2, 2, 1, Nv, Nh) + data_vijhf = VIJHF{S}(ArrayType{FT}, ones; Nv, Nij = 2, Nh) + data_vijhf2 = data_f .+ data_vijhf + @test data_vijhf2 isa VIJHF{S, Nv} + @test size(data_vijhf2) == (2, 2, 1, Nv, Nh) end @testset "column IF => DataF" begin @@ -191,18 +191,18 @@ end @test_throws BoundsError column(data_if, 3) end -@testset "column IFH => DataF" begin +@testset "column IHF => DataF" begin FT = Float64 S = Complex{FT} Nh = 3 - data_ifh = IFH{S}(ArrayType{FT}; Ni = 2, Nh) - array = parent(data_ifh) - array[1, :, 1] .= FT[3, 4] - ifh_column = column(data_ifh, 1, 1) - @test ifh_column isa DataF - @test ifh_column[] == 3.0 + 4.0im - @test_throws BoundsError column(data_ifh, 3, 2) - @test_throws BoundsError column(data_ifh, 2, 4) + data_ihf = IHF{S}(ArrayType{FT}; Ni = 2, Nh) + array = parent(data_ihf) + array[1, 1, :] .= FT[3, 4] + ihf_column = column(data_ihf, 1, 1) + @test ihf_column isa DataF + @test ihf_column[] == 3.0 + 4.0im + @test_throws BoundsError column(data_ihf, 3, 2) + @test_throws BoundsError column(data_ihf, 2, 4) end @testset "column IJF => DataF" begin @@ -218,19 +218,19 @@ end @test_throws BoundsError column(data_ijf, 1, 3) end -@testset "column IJFH => DataF" begin +@testset "column IJHF => DataF" begin FT = Float64 S = Complex{FT} Nh = 3 - data_ijfh = IJFH{S}(ArrayType{FT}; Nij = 2, Nh) - array = parent(data_ijfh) - array[1, 1, :, 2] .= FT[3, 4] - ijfh_column = column(data_ijfh, 1, 1, 2) - @test ijfh_column isa DataF - @test ijfh_column[] == 3.0 + 4.0im - @test_throws BoundsError column(data_ijfh, 3, 1, 1) - @test_throws BoundsError column(data_ijfh, 1, 3, 1) - @test_throws BoundsError column(data_ijfh, 1, 1, 4) + data_ijhf = IJHF{S}(ArrayType{FT}; Nij = 2, Nh) + array = parent(data_ijhf) + array[1, 1, 2, :] .= FT[3, 4] + ijhf_column = column(data_ijhf, 1, 1, 2) + @test ijhf_column isa DataF + @test ijhf_column[] == 3.0 + 4.0im + @test_throws BoundsError column(data_ijhf, 3, 1, 1) + @test_throws BoundsError column(data_ijhf, 1, 3, 1) + @test_throws BoundsError column(data_ijhf, 1, 1, 4) end @testset "level VF => DataF" begin diff --git a/test/DataLayouts/data1dx.jl b/test/DataLayouts/data1dx.jl index d493fbd687..70d5abdce8 100644 --- a/test/DataLayouts/data1dx.jl +++ b/test/DataLayouts/data1dx.jl @@ -5,11 +5,11 @@ using Revise; include(joinpath("test", "DataLayouts", "data1dx.jl")) using Test using ClimaComms using ClimaCore.DataLayouts -import ClimaCore.DataLayouts: VIFH, slab, column, VF, IFH, vindex, slab_index +import ClimaCore.DataLayouts: VIHF, slab, column, VF, IHF, vindex, slab_index device = ClimaComms.device() ArrayType = ClimaComms.array_type(device) -@testset "VIFH" begin +@testset "VIHF" begin TestFloatTypes = (Float32, Float64) for FT in TestFloatTypes S = Tuple{Complex{FT}, FT} @@ -20,12 +20,12 @@ ArrayType = ClimaComms.array_type(device) # construct a data object with 10 cells in vertical and # 10 elements in horizontal with 4 nodal points per element in horizontal - data = VIFH{S}(ArrayType{FT}, rand; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, rand; Nv, Ni, Nh) array = parent(data) sum(x -> x[2], data) - @test getfield(data.:1, :array) == @view(array[:, :, 1:2, :]) - @test getfield(data.:2, :array) == @view(array[:, :, 3:3, :]) + @test getfield(data.:1, :array) == @view(array[:, :, :, 1:2]) + @test getfield(data.:2, :array) == @view(array[:, :, :, 3:3]) @test size(data) == (Ni, 1, 1, Nv, Nh) @@ -33,8 +33,8 @@ ArrayType = ClimaComms.array_type(device) val = (Complex{FT}(-1.0, -2.0), FT(-3.0)) column(data, 1, 1)[vindex(1)] = val @test array[1, 1, 1, 1] == -1.0 - @test array[1, 1, 2, 1] == -2.0 - @test array[1, 1, 3, 1] == -3.0 + @test array[1, 1, 1, 2] == -2.0 + @test array[1, 1, 1, 3] == -3.0 # test value of assing tuple on slab sdata = slab(data, 1, 1) @@ -42,18 +42,18 @@ ArrayType = ClimaComms.array_type(device) # sum of all the first field elements @test sum(data.:1) ≈ - Complex{FT}(sum(array[:, :, 1, :]), sum(array[:, :, 2, :])) - @test sum(x -> x[2], data) ≈ sum(array[:, :, 3, :]) + Complex{FT}(sum(array[:, :, :, 1]), sum(array[:, :, :, 2])) + @test sum(x -> x[2], data) ≈ sum(array[:, :, :, 3]) end end -@testset "VIFH boundscheck" begin +@testset "VIHF boundscheck" begin Nv = 1 # number of vertical levels Ni = 1 # number of nodal points Nh = 2 # number of elements S = Tuple{Complex{Float64}, Float64} - data = VIFH{S}(ArrayType{Float64}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{Float64}, zeros; Nv, Ni, Nh) @test_throws BoundsError slab(data, -1, -1) @test_throws BoundsError slab(data, 1, 3) @@ -69,7 +69,7 @@ end end -@testset "VIFH type safety" begin +@testset "VIHF type safety" begin Nv = 1 # number of vertical levels Ni = 1 # number of nodal points per element Nh = 1 # number of elements @@ -78,7 +78,7 @@ end SA = (a = 1.0, b = 2.0) SB = (c = 1.0, d = 2.0) - data = VIFH{typeof(SA)}(ArrayType{Float64}, zeros; Nv, Ni, Nh) + data = VIHF{typeof(SA)}(ArrayType{Float64}, zeros; Nv, Ni, Nh) cdata = column(data, 1, 1) cdata[slab_index(1)] = SA @@ -90,42 +90,42 @@ end @test_throws MethodError sdata[slab_index(1)] = SB end -@testset "broadcasting between VIFH data object + scalars" begin +@testset "broadcasting between VIHF data object + scalars" begin FT = Float64 Nv = 2 Nh = 2 S = Complex{Float64} - data1 = VIFH{S}(ArrayType{FT}, ones; Nv, Ni = 2, Nh = 2) + data1 = VIHF{S}(ArrayType{FT}, ones; Nv, Ni = 2, Nh = 2) res = data1 .+ 1 - @test res isa VIFH{S, Nv} + @test res isa VIHF{S, Nv} @test parent(res) == - FT[f == 1 ? 2 : 1 for i in 1:2, j in 1:2, f in 1:2, h in 1:2] + FT[f == 1 ? 2 : 1 for i in 1:2, j in 1:2, h in 1:2, f in 1:2] @test sum(res) == Complex(16.0, 8.0) @test sum(Base.Broadcast.broadcasted(+, data1, 1)) == Complex(16.0, 8.0) end -@testset "broadcasting between VF + IFH data object => VIFH" begin +@testset "broadcasting between VF + IHF data object => VIHF" begin FT = Float64 S = Complex{FT} Nv = 3 Nh = 2 data_vf = VF{S}(ArrayType{FT}, ones; Nv) - data_ifh = IFH{FT}(ArrayType{FT}, ones; Ni = 2, Nh = 2) - data_vifh = data_vf .+ data_ifh - @test data_vifh isa VIFH{S, Nv} - @test size(data_vifh) == (2, 1, 1, 3, 2) - @test parent(data_vifh) == - FT[f == 1 ? 2 : 1 for v in 1:3, i in 1:2, f in 1:2, h in 1:2] - - @test parent(data_vifh .+ data_vf) == - FT[f == 1 ? 3 : 2 for v in 1:3, i in 1:2, f in 1:2, h in 1:2] - @test parent(data_vifh .+ data_ifh) == - FT[f == 1 ? 3 : 1 for v in 1:3, i in 1:2, f in 1:2, h in 1:2] + data_ihf = IHF{FT}(ArrayType{FT}, ones; Ni = 2, Nh = 2) + data_vihf = data_vf .+ data_ihf + @test data_vihf isa VIHF{S, Nv} + @test size(data_vihf) == (2, 1, 1, 3, 2) + @test parent(data_vihf) == + FT[f == 1 ? 2 : 1 for v in 1:3, i in 1:2, h in 1:2, f in 1:2] + + @test parent(data_vihf .+ data_vf) == + FT[f == 1 ? 3 : 2 for v in 1:3, i in 1:2, h in 1:2, f in 1:2] + @test parent(data_vihf .+ data_ihf) == + FT[f == 1 ? 3 : 1 for v in 1:3, i in 1:2, h in 1:2, f in 1:2] end @testset "fill" begin - data = IFH{Float64}(ArrayType{Float64}, ones; Ni = 3, Nh = 3) + data = IHF{Float64}(ArrayType{Float64}, ones; Ni = 3, Nh = 3) data .= 2.0 @test all(==(2.0), parent(data)) end diff --git a/test/DataLayouts/data2d.jl b/test/DataLayouts/data2d.jl index d88de4b267..9d6250c1ce 100644 --- a/test/DataLayouts/data2d.jl +++ b/test/DataLayouts/data2d.jl @@ -44,37 +44,37 @@ end @test get_struct(array, S, Val(1), CartesianIndex(1)) == (4.0 + 2.0im, 6.0) end -@testset "IJFH" begin +@testset "IJHF" begin Nij = 2 # number of nodal points Nh = 2 # number of elements FT = Float64 S = Tuple{Complex{FT}, FT} - data = IJFH{S}(ArrayType{FT}, rand; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, rand; Nij, Nh) array = parent(data) - @test getfield(data.:1, :array) == @view(array[:, :, 1:2, :]) + @test getfield(data.:1, :array) == @view(array[:, :, :, 1:2]) data_slab = slab(data, 1) @test data_slab[slab_index(2, 1)] == - (Complex(array[2, 1, 1, 1], array[2, 1, 2, 1]), array[2, 1, 3, 1]) + (Complex(array[2, 1, 1, 1], array[2, 1, 1, 2]), array[2, 1, 1, 3]) data_slab[slab_index(2, 1)] = (Complex(-1.0, -2.0), -3.0) @test array[2, 1, 1, 1] == -1.0 - @test array[2, 1, 2, 1] == -2.0 - @test array[2, 1, 3, 1] == -3.0 + @test array[2, 1, 1, 2] == -2.0 + @test array[2, 1, 1, 3] == -3.0 subdata_slab = data_slab.:2 @test subdata_slab[slab_index(2, 1)] == -3.0 subdata_slab[slab_index(2, 1)] = -5.0 - @test array[2, 1, 3, 1] == -5.0 + @test array[2, 1, 1, 3] == -5.0 - @test sum(data.:1) ≈ Complex(sum(array[:, :, 1, :]), sum(array[:, :, 2, :])) atol = + @test sum(data.:1) ≈ Complex(sum(array[:, :, :, 1]), sum(array[:, :, :, 2])) atol = 10eps() - @test sum(x -> x[2], data) ≈ sum(array[:, :, 3, :]) atol = 10eps() + @test sum(x -> x[2], data) ≈ sum(array[:, :, :, 3]) atol = 10eps() end -@testset "IJFH boundscheck" begin +@testset "IJHF boundscheck" begin Nij = 1 # number of nodal points Nh = 2 # number of elements S = Tuple{Complex{Float64}, Float64} - data = IJFH{S}(ArrayType{Float64}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{Float64}, zeros; Nij, Nh) @test_throws BoundsError slab(data, -1) @test_throws BoundsError slab(data, 3) @@ -89,7 +89,7 @@ end @test_throws BoundsError sdata[slab_index(1, 2)] end -@testset "IJFH type safety" begin +@testset "IJHF type safety" begin Nij = 2 # number of nodal points per element Nh = 1 # number of elements @@ -97,7 +97,7 @@ end SA = (a = 1.0, b = 2.0) SB = (c = 1.0, d = 2.0) - data = IJFH{typeof(SA)}(ArrayType{Float64}, zeros; Nij, Nh) + data = IJHF{typeof(SA)}(ArrayType{Float64}, zeros; Nij, Nh) data_slab = slab(data, 1) ret = begin data_slab[slab_index(1, 1)] = SA @@ -112,8 +112,8 @@ end Nh = 2 # number of elements S1 = Float64 S2 = Float32 - data1 = IJFH{S1}(ArrayType{S1}, ones; Nij, Nh) - data2 = IJFH{S2}(ArrayType{S2}, ones; Nij, Nh) + data1 = IJHF{S1}(ArrayType{S1}, ones; Nij, Nh) + data2 = IJHF{S2}(ArrayType{S2}, ones; Nij, Nh) for h in 1:Nh slab1 = slab(data1, h) @@ -129,11 +129,11 @@ end FT = Float64 Nh = 2 S = Complex{Float64} - data1 = IJFH{S}(ArrayType{FT}, ones; Nij = 2, Nh) + data1 = IJHF{S}(ArrayType{FT}, ones; Nij = 2, Nh) res = data1 .+ 1 - @test res isa IJFH{S} + @test res isa IJHF{S} @test parent(res) == - FT[f == 1 ? 2 : 1 for i in 1:2, j in 1:2, f in 1:2, h in 1:2] + FT[f == 1 ? 2 : 1 for i in 1:2, j in 1:2, h in 1:2, f in 1:2] @test sum(res) == Complex(16.0, 8.0) @test sum(Base.Broadcast.broadcasted(+, data1, 1)) == Complex(16.0, 8.0) @@ -143,14 +143,14 @@ end FT = Float64 S = Complex{FT} Nh = 3 - data = IJFH{S}(ArrayType{FT}; Nij = 2, Nh) + data = IJHF{S}(ArrayType{FT}; Nij = 2, Nh) data .= Complex(1.0, 2.0) @test parent(data) == - FT[f == 1 ? 1 : 2 for i in 1:2, j in 1:2, f in 1:2, h in 1:3] + FT[f == 1 ? 1 : 2 for i in 1:2, j in 1:2, h in 1:3, f in 1:2] data .= 1 @test parent(data) == - FT[f == 1 ? 1 : 0 for i in 1:2, j in 1:2, f in 1:2, h in 1:3] + FT[f == 1 ? 1 : 0 for i in 1:2, j in 1:2, h in 1:3, f in 1:2] end @@ -159,12 +159,12 @@ end Nh = 2 S1 = Complex{Float64} S2 = Float64 - data1 = IJFH{S1}(ArrayType{FT}, ones; Nij = 2, Nh) - data2 = IJFH{S2}(ArrayType{FT}, ones; Nij = 2, Nh) + data1 = IJHF{S1}(ArrayType{FT}, ones; Nij = 2, Nh) + data2 = IJHF{S2}(ArrayType{FT}, ones; Nij = 2, Nh) res = data1 .+ data2 - @test res isa IJFH{S1} + @test res isa IJHF{S1} @test parent(res) == - FT[f == 1 ? 2 : 1 for i in 1:2, j in 1:2, f in 1:2, h in 1:2] + FT[f == 1 ? 2 : 1 for i in 1:2, j in 1:2, h in 1:2, f in 1:2] @test sum(res) == Complex(16.0, 8.0) @test sum(Base.Broadcast.broadcasted(+, data1, data2)) == Complex(16.0, 8.0) @@ -175,11 +175,11 @@ end S1 = NamedTuple{(:a, :b), Tuple{Complex{Float64}, Float64}} Nh = 2 S2 = Float64 - data1 = IJFH{S1}(ArrayType{FT}, ones; Nij = 2, Nh) - data2 = IJFH{S2}(ArrayType{FT}, ones; Nij = 2, Nh) + data1 = IJHF{S1}(ArrayType{FT}, ones; Nij = 2, Nh) + data2 = IJHF{S2}(ArrayType{FT}, ones; Nij = 2, Nh) f(a1, a2) = a1.a.re * a2 + a1.b res = f.(data1, data2) - @test res isa IJFH{Float64} - @test parent(res) == FT[2 for i in 1:2, j in 1:2, f in 1:1, h in 1:2] + @test res isa IJHF{Float64} + @test parent(res) == FT[2 for i in 1:2, j in 1:2, h in 1:2, f in 1:1] end diff --git a/test/DataLayouts/data2dx.jl b/test/DataLayouts/data2dx.jl index 1b2621b4dd..0d293b2d84 100644 --- a/test/DataLayouts/data2dx.jl +++ b/test/DataLayouts/data2dx.jl @@ -5,11 +5,11 @@ using Revise; include(joinpath("test", "DataLayouts", "data2dx.jl")) using Test using ClimaComms using ClimaCore.DataLayouts -import ClimaCore.DataLayouts: VF, IJFH, VIJFH, slab, column, slab_index, vindex +import ClimaCore.DataLayouts: VF, IJHF, VIJHF, slab, column, slab_index, vindex device = ClimaComms.device() ArrayType = ClimaComms.array_type(device) -@testset "VIJFH" begin +@testset "VIJHF" begin Nv = 10 # number of vertical levels Nij = 4 # Nij × Nij nodal points per element Nh = 10 # number of elements @@ -20,11 +20,11 @@ ArrayType = ClimaComms.array_type(device) # construct a data object with 10 cells in vertical and # 10 elements in horizontal with 4 × 4 nodal points per element in horizontal - data = VIJFH{S}(ArrayType{FT}, rand; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, rand; Nv, Nij, Nh) array = parent(data) - @test getfield(data.:1, :array) == @view(array[:, :, :, 1:2, :]) - @test getfield(data.:2, :array) == @view(array[:, :, :, 3:3, :]) + @test getfield(data.:1, :array) == @view(array[:, :, :, :, 1:2]) + @test getfield(data.:2, :array) == @view(array[:, :, :, :, 3:3]) @test size(data) == (Nij, Nij, 1, Nv, Nh) @@ -33,8 +33,8 @@ ArrayType = ClimaComms.array_type(device) column(data, 1, 2, 1)[vindex(1)] = val @test array[1, 1, 2, 1, 1] == -1.0 - @test array[1, 1, 2, 2, 1] == -2.0 - @test array[1, 1, 2, 3, 1] == -3.0 + @test array[1, 1, 2, 1, 2] == -2.0 + @test array[1, 1, 2, 1, 3] == -3.0 # test value of assing tuple on slab sdata = slab(data, 1, 1) @@ -42,18 +42,18 @@ ArrayType = ClimaComms.array_type(device) # sum of all the first field elements @test sum(data.:1) ≈ - Complex{FT}(sum(array[:, :, :, 1, :]), sum(array[:, :, :, 2, :])) - @test sum(x -> x[2], data) ≈ sum(array[:, :, :, 3, :]) + Complex{FT}(sum(array[:, :, :, :, 1]), sum(array[:, :, :, :, 2])) + @test sum(x -> x[2], data) ≈ sum(array[:, :, :, :, 3]) end end -@testset "VIJFH boundscheck" begin +@testset "VIJHF boundscheck" begin Nv = 1 # number of vertical levels Nij = 1 # number of nodal points Nh = 2 # number of elements S = Tuple{Complex{Float64}, Float64} - data = VIJFH{S}(ArrayType{Float64}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{Float64}, zeros; Nv, Nij, Nh) @test_throws BoundsError slab(data, -1, 1) @test_throws BoundsError slab(data, 1, -1) @@ -68,7 +68,7 @@ end @test_throws BoundsError column(data, 1, 1, 3) end -@testset "VIJFH type safety" begin +@testset "VIJHF type safety" begin Nv = 1 # number of vertical levels Nij = 2 # Nij × Nij nodal points per element Nh = 1 # number of elements @@ -77,7 +77,7 @@ end SA = (a = 1.0, b = 2.0) SB = (c = 1.0, d = 2.0) - data = VIJFH{typeof(SA)}(ArrayType{Float64}, zeros; Nv, Nij, Nh) + data = VIJHF{typeof(SA)}(ArrayType{Float64}, zeros; Nv, Nij, Nh) cdata = column(data, 1, 2, 1) cdata[vindex(1)] = SA @@ -89,41 +89,43 @@ end @test_throws MethodError sdata[slab_index(1)] = SB end -@testset "broadcasting between VIJFH data object + scalars" begin +@testset "broadcasting between VIJHF data object + scalars" begin FT = Float64 S = Complex{Float64} - data1 = VIJFH{S}(ArrayType{FT}, ones; Nv = 2, Nij = 2, Nh = 2) + data1 = VIJHF{S}(ArrayType{FT}, ones; Nv = 2, Nij = 2, Nh = 2) array = parent(data1) Nv = size(array, 1) Nh = size(array, 5) + S = Complex{Float64} + data1 = VIJHF{S, Nv, 2}(array) res = data1 .+ 1 - @test res isa VIJFH{S, Nv} + @test res isa VIJHF{S, Nv} @test parent(res) == FT[ - f == 1 ? 2 : 1 for v in 1:2, i in 1:2, j in 1:2, f in 1:2, h in 1:2 + f == 1 ? 2 : 1 for v in 1:2, i in 1:2, j in 1:2, h in 1:2, f in 1:2 ] @test sum(res) == Complex(FT(32.0), FT(16.0)) @test sum(Base.Broadcast.broadcasted(+, data1, 1)) == Complex(FT(32.0), FT(16.0)) end -@testset "broadcasting between VF + IJFH data object => VIJFH" begin +@testset "broadcasting between VF + IJHF data object => VIJHF" begin FT = Float64 S = Complex{FT} Nv = 3 Nh = 2 data_vf = VF{S}(ArrayType{FT}, ones; Nv) - data_ijfh = IJFH{FT}(ArrayType{FT}, ones; Nij = 2, Nh) - data_vijfh = data_vf .+ data_ijfh - @test data_vijfh isa VIJFH{S, Nv} - @test size(data_vijfh) == (2, 2, 1, 3, 2) + data_ijhf = IJHF{FT}(ArrayType{FT}, ones; Nij = 2, Nh) + data_vijhf = data_vf .+ data_ijhf + @test data_vijhf isa VIJHF{S, Nv} + @test size(data_vijhf) == (2, 2, 1, 3, 2) - @test parent(data_vijfh) == FT[ - f == 1 ? 2 : 1 for v in 1:3, i in 1:2, j in 1:2, f in 1:2, h in 1:2 + @test parent(data_vijhf) == FT[ + f == 1 ? 2 : 1 for v in 1:3, i in 1:2, j in 1:2, h in 1:2, f in 1:2 ] - @test parent(data_vijfh .+ data_vf) == FT[ - f == 1 ? 3 : 2 for v in 1:3, i in 1:2, j in 1:2, f in 1:2, h in 1:2 + @test parent(data_vijhf .+ data_vf) == FT[ + f == 1 ? 3 : 2 for v in 1:3, i in 1:2, j in 1:2, h in 1:2, f in 1:2 ] - @test parent(data_vijfh .+ data_ijfh) == FT[ - f == 1 ? 3 : 1 for v in 1:3, i in 1:2, j in 1:2, f in 1:2, h in 1:2 + @test parent(data_vijhf .+ data_ijhf) == FT[ + f == 1 ? 3 : 1 for v in 1:3, i in 1:2, j in 1:2, h in 1:2, f in 1:2 ] end diff --git a/test/DataLayouts/opt_similar.jl b/test/DataLayouts/opt_similar.jl index 2ff0b053a3..95e00c75a7 100644 --- a/test/DataLayouts/opt_similar.jl +++ b/test/DataLayouts/opt_similar.jl @@ -12,7 +12,7 @@ ClimaComms.@import_required_backends using JET function test_similar!(data) - if data isa VF || data isa VIFH || data isa VIJFH + if data isa VF || data isa VIHF || data isa VIJHF FT = eltype(parent(data)) CT = Geometry.ZPoint{FT} AIdx = (3,) @@ -37,9 +37,9 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_similar!(data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_similar!(data) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_similar!(data) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_similar!(data) @@ -47,9 +47,9 @@ end test_similar!(data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_similar!(data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_similar!(data) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_similar!(data) # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_similar!(data) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_similar!(data) # TODO: test diff --git a/test/DataLayouts/opt_universal_size.jl b/test/DataLayouts/opt_universal_size.jl index 27a5e69b0b..a27bead9c7 100644 --- a/test/DataLayouts/opt_universal_size.jl +++ b/test/DataLayouts/opt_universal_size.jl @@ -59,9 +59,9 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_universal_size(data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_universal_size(data) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_universal_size(data) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_universal_size(data) @@ -69,9 +69,9 @@ end test_universal_size(data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_universal_size(data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_universal_size(data) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_universal_size(data) # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_universal_size(data) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_universal_size(data) # TODO: test diff --git a/test/DataLayouts/unit_copyto.jl b/test/DataLayouts/unit_copyto.jl index 6bf260bb08..00c6255fca 100644 --- a/test/DataLayouts/unit_copyto.jl +++ b/test/DataLayouts/unit_copyto.jl @@ -52,9 +52,9 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_copyto_float!(data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_copyto_float!(data) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_copyto_float!(data) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_copyto_float!(data) @@ -62,9 +62,9 @@ end test_copyto_float!(data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_copyto_float!(data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_copyto_float!(data) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_copyto_float!(data) # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_copyto_float!(data) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_copyto_float!(data) # TODO: test @@ -81,9 +81,9 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_copyto!(data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_copyto!(data) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_copyto!(data) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_copyto!(data) @@ -91,9 +91,9 @@ end test_copyto!(data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_copyto!(data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_copyto!(data) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_copyto!(data) # TODO: test this # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_copyto!(data) # TODO: test @@ -121,9 +121,9 @@ end Nk = 6 # Rather than using level/slab/column, let's just make views/SubArrays # directly so that we can easily test all cases: - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_copyto!(data_view(data)) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_copyto!(data_view(data)) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_copyto!(data_view(data)) @@ -131,9 +131,9 @@ end test_copyto!(data_view(data)) data = VF{S}(ArrayType{FT}, zeros; Nv) test_copyto!(data_view(data)) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_copyto!(data_view(data)) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_copyto!(data_view(data)) # TODO: test this # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_copyto!(data) # TODO: test diff --git a/test/DataLayouts/unit_data2array.jl b/test/DataLayouts/unit_data2array.jl index 8ce5084064..1f01a444de 100644 --- a/test/DataLayouts/unit_data2array.jl +++ b/test/DataLayouts/unit_data2array.jl @@ -25,7 +25,7 @@ end @test DataLayouts.data2array(data) == reshape(parent(data), :) @test is_data2array2data_identity(data) - data = IFH{FT}(ArrayType{FT}, rand; Ni, Nh) + data = IHF{FT}(ArrayType{FT}, rand; Ni, Nh) @test DataLayouts.data2array(data) == reshape(parent(data), :) @test is_data2array2data_identity(data) @@ -33,15 +33,15 @@ end @test DataLayouts.data2array(data) == reshape(parent(data), :) @test is_data2array2data_identity(data) - data = IJFH{FT}(ArrayType{FT}, rand; Nij, Nh) + data = IJHF{FT}(ArrayType{FT}, rand; Nij, Nh) @test DataLayouts.data2array(data) == reshape(parent(data), :) @test is_data2array2data_identity(data) - data = VIFH{FT}(ArrayType{FT}, rand; Nv, Ni, Nh) + data = VIHF{FT}(ArrayType{FT}, rand; Nv, Ni, Nh) @test DataLayouts.data2array(data) == reshape(parent(data), Nv, :) @test is_data2array2data_identity(data) - data = VIJFH{FT}(ArrayType{FT}, rand; Nv, Nij, Nh) + data = VIJHF{FT}(ArrayType{FT}, rand; Nv, Nij, Nh) @test DataLayouts.data2array(data) == reshape(parent(data), Nv, :) @test is_data2array2data_identity(data) end diff --git a/test/DataLayouts/unit_fill.jl b/test/DataLayouts/unit_fill.jl index 472a30a296..12a9f7a82a 100644 --- a/test/DataLayouts/unit_fill.jl +++ b/test/DataLayouts/unit_fill.jl @@ -29,9 +29,9 @@ end data = DataF{S}(ArrayType{FT}, zeros) test_fill!(data, 3) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_fill!(data, 3) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_fill!(data, 3) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_fill!(data, 3) @@ -39,9 +39,9 @@ end test_fill!(data, 3) data = VF{S}(ArrayType{FT}, zeros; Nv) test_fill!(data, 3) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_fill!(data, 3) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_fill!(data, 3) # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_fill!(data, 3) # TODO: test @@ -60,9 +60,9 @@ end data = DataF{S}(ArrayType{FT}, zeros) test_fill!(data, (2, 3)) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_fill!(data, (2, 3)) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_fill!(data, (2, 3)) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_fill!(data, (2, 3)) @@ -70,9 +70,9 @@ end test_fill!(data, (2, 3)) data = VF{S}(ArrayType{FT}, zeros; Nv) test_fill!(data, (2, 3)) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_fill!(data, (2, 3)) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_fill!(data, (2, 3)) # TODO: test this @@ -102,9 +102,9 @@ end # Rather than using level/slab/column, let's just make views/SubArrays # directly so that we can easily test all cases: - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_fill!(data_view(data), (2, 3)) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_fill!(data_view(data), (2, 3)) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_fill!(data_view(data), (2, 3)) @@ -112,9 +112,9 @@ end test_fill!(data_view(data), (2, 3)) data = VF{S}(ArrayType{FT}, zeros; Nv) test_fill!(data_view(data), (2, 3)) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_fill!(data_view(data), (2, 3)) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_fill!(data_view(data), (2, 3)) # TODO: test this @@ -134,9 +134,13 @@ end # ReshapedArray, but it works for several cases. Tests when # are commented out for cases when Julia Base manages to return # a parent-similar array. + + # After moving from FH -> HF, we no longer make + # `Base.ReshapedArray`s, because field views + # simply return arrays. data = data.:2 array₀ = DataLayouts.data2array(data) - @test typeof(array₀) <: Base.ReshapedArray + @test typeof(array₀) <: Base.AbstractArray rdata = DataLayouts.array2data(array₀, data) newdata = DataLayouts.rebuild( data, @@ -149,9 +153,9 @@ end ), ) rarray = parent(parent(newdata)) - @test typeof(rarray) <: Base.ReshapedArray + @test typeof(rarray) <: Base.AbstractArray subarray = parent(rarray) - @test typeof(subarray) <: Base.SubArray + @test typeof(subarray) <: Base.AbstractArray array = parent(subarray) newdata end @@ -163,16 +167,16 @@ end Nk = 6 # directly so that we can easily test all cases: - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_fill!(reshaped_array(data), 2) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_fill!(reshaped_array(data), 2) # data = IJF{S}(ArrayType{FT}, zeros; Nij); test_fill!(reshaped_array(data), 2) # data = IF{S}(ArrayType{FT}, zeros; Ni); test_fill!(reshaped_array(data), 2) # data = VF{S}(ArrayType{FT}, zeros; Nv); test_fill!(reshaped_array(data), 2) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_fill!(reshaped_array(data), 2) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_fill!(reshaped_array(data), 2) # TODO: test this diff --git a/test/DataLayouts/unit_getindex_field.jl b/test/DataLayouts/unit_getindex_field.jl index 17dd7f783b..e793a97b35 100644 --- a/test/DataLayouts/unit_getindex_field.jl +++ b/test/DataLayouts/unit_getindex_field.jl @@ -81,9 +81,9 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_copyto_float!(data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_copyto_float!(data) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_copyto_float!(data) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_copyto_float!(data) @@ -91,9 +91,9 @@ end test_copyto_float!(data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_copyto_float!(data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_copyto_float!(data) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_copyto_float!(data) # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_copyto_float!(data) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_copyto_float!(data) # TODO: test @@ -110,9 +110,9 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_copyto!(data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_copyto!(data) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_copyto!(data) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_copyto!(data) @@ -120,9 +120,9 @@ end test_copyto!(data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_copyto!(data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_copyto!(data) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_copyto!(data) # TODO: test this # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_copyto!(data) # TODO: test @@ -150,9 +150,9 @@ end Nk = 6 # Rather than using level/slab/column, let's just make views/SubArrays # directly so that we can easily test all cases: - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_copyto!(data_view(data)) - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) test_copyto!(data_view(data)) data = IJF{S}(ArrayType{FT}, zeros; Nij) test_copyto!(data_view(data)) @@ -160,9 +160,9 @@ end test_copyto!(data_view(data)) data = VF{S}(ArrayType{FT}, zeros; Nv) test_copyto!(data_view(data)) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_copyto!(data_view(data)) - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) test_copyto!(data_view(data)) # TODO: test this # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_copyto!(data) # TODO: test diff --git a/test/DataLayouts/unit_mapreduce.jl b/test/DataLayouts/unit_mapreduce.jl index b1d69471ea..65587872c5 100644 --- a/test/DataLayouts/unit_mapreduce.jl +++ b/test/DataLayouts/unit_mapreduce.jl @@ -75,16 +75,16 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_mapreduce_1!(context, data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_mapreduce_1!(context, data) - # data = IFH{S}(ArrayType{FT}, zeros; Ni,Nh); test_mapreduce_1!(context, data) + # data = IHF{S}(ArrayType{FT}, zeros; Ni,Nh); test_mapreduce_1!(context, data) # data = IJF{S}(ArrayType{FT}, zeros; Nij); test_mapreduce_1!(context, data) # data = IF{S}(ArrayType{FT}, zeros; Ni); test_mapreduce_1!(context, data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_mapreduce_1!(context, data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_mapreduce_1!(context, data) - # data = VIFH{S}(ArrayType{FT}, zeros; Nv,Nij,Nh); test_mapreduce_1!(context, data) + # data = VIHF{S}(ArrayType{FT}, zeros; Nv,Nij,Nh); test_mapreduce_1!(context, data) # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_mapreduce_1!(context, data) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_mapreduce_1!(context, data) # TODO: test end @@ -99,16 +99,16 @@ end Nk = 6 data = DataF{S}(ArrayType{FT}, zeros) test_mapreduce_2!(context, data) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_mapreduce_2!(context, data) - # data = IFH{S}(ArrayType{FT}, zeros; Ni,Nh); test_mapreduce_2!(context, data) + # data = IHF{S}(ArrayType{FT}, zeros; Ni,Nh); test_mapreduce_2!(context, data) # data = IJF{S}(ArrayType{FT}, zeros; Nij); test_mapreduce_2!(context, data) # data = IF{S}(ArrayType{FT}, zeros; Ni); test_mapreduce_2!(context, data) data = VF{S}(ArrayType{FT}, zeros; Nv) test_mapreduce_2!(context, data) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_mapreduce_2!(context, data) - # data = VIFH{S}(ArrayType{FT}, zeros; Nv,Nij,Nh); test_mapreduce_2!(context, data) + # data = VIHF{S}(ArrayType{FT}, zeros; Nv,Nij,Nh); test_mapreduce_2!(context, data) # TODO: test this # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_mapreduce_2!(context, data) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_mapreduce_2!(context, data) # TODO: test @@ -136,16 +136,16 @@ end # directly so that we can easily test all cases: data = DataF{S}(ArrayType{FT}, zeros) test_mapreduce_2!(context, data_view(data)) - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) test_mapreduce_2!(context, data_view(data)) - # data = IFH{S}(ArrayType{FT}, zeros; Ni,Nh); test_mapreduce_2!(context, data_view(data)) + # data = IHF{S}(ArrayType{FT}, zeros; Ni,Nh); test_mapreduce_2!(context, data_view(data)) # data = IJF{S}(ArrayType{FT}, zeros; Nij); test_mapreduce_2!(context, data_view(data)) # data = IF{S}(ArrayType{FT}, zeros; Ni); test_mapreduce_2!(context, data_view(data)) data = VF{S}(ArrayType{FT}, zeros; Nv) test_mapreduce_2!(context, data_view(data)) - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) test_mapreduce_2!(context, data_view(data)) - # data = VIFH{S}(ArrayType{FT}, zeros; Nv,Nij,Nh); test_mapreduce_2!(context, data_view(data)) + # data = VIHF{S}(ArrayType{FT}, zeros; Nv,Nij,Nh); test_mapreduce_2!(context, data_view(data)) # TODO: test this # data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij,Nk,Nv,Nh); test_mapreduce_2!(context, data_view(data)) # TODO: test # data = DataLayouts.IH1JH2{S}(ArrayType{FT}, zeros; Nij); test_mapreduce_2!(context, data_view(data)) # TODO: test diff --git a/test/DataLayouts/unit_ndims.jl b/test/DataLayouts/unit_ndims.jl index 50114d514d..470aeff392 100644 --- a/test/DataLayouts/unit_ndims.jl +++ b/test/DataLayouts/unit_ndims.jl @@ -26,19 +26,19 @@ ClimaComms.@import_required_backends data = VF{S}(ArrayType{FT}, zeros; Nv) @test ndims(data) == 2 @test ndims(typeof(data)) == 2 - data = IFH{S}(ArrayType{FT}, zeros; Ni, Nh) + data = IHF{S}(ArrayType{FT}, zeros; Ni, Nh) @test ndims(data) == 3 @test ndims(typeof(data)) == 3 data = IJF{S}(ArrayType{FT}, zeros; Nij) @test ndims(data) == 3 @test ndims(typeof(data)) == 3 - data = IJFH{S}(ArrayType{FT}, zeros; Nij, Nh) + data = IJHF{S}(ArrayType{FT}, zeros; Nij, Nh) @test ndims(data) == 4 @test ndims(typeof(data)) == 4 - data = VIFH{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) + data = VIHF{S}(ArrayType{FT}, zeros; Nv, Ni, Nh) @test ndims(data) == 4 @test ndims(typeof(data)) == 4 - data = VIJFH{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) + data = VIJHF{S}(ArrayType{FT}, zeros; Nv, Nij, Nh) @test ndims(data) == 5 @test ndims(typeof(data)) == 5 data = DataLayouts.IJKFVH{S}(ArrayType{FT}, zeros; Nij, Nk, Nv, Nh) diff --git a/test/DataLayouts/unit_struct.jl b/test/DataLayouts/unit_struct.jl index 05b79ba1f9..bec6b05268 100644 --- a/test/DataLayouts/unit_struct.jl +++ b/test/DataLayouts/unit_struct.jl @@ -25,7 +25,7 @@ end Base.zero(::Type{Foo{T}}) where {T} = Foo{T}(0, 0) -@testset "get_struct - IFH indexing" begin +@testset "get_struct - IHF indexing" begin FT = Float64 S = Foo{FT} s_array = (3, 2, 4) @@ -69,7 +69,7 @@ end @test_throws BoundsError get_struct(a, S, Val(3), CI(s)[13]) end -@testset "get_struct - VIJFH indexing" begin +@testset "get_struct - VIJHF indexing" begin FT = Float64 S = Foo{FT} s_array = (2, 2, 2, 2, 2) diff --git a/test/Fields/benchmark_field_multi_broadcast_fusion.jl b/test/Fields/benchmark_field_multi_broadcast_fusion.jl index e30f00f4ca..a1063411f3 100644 --- a/test/Fields/benchmark_field_multi_broadcast_fusion.jl +++ b/test/Fields/benchmark_field_multi_broadcast_fusion.jl @@ -6,7 +6,7 @@ using Revise; include(joinpath("test", "Fields", "benchmark_field_multi_broadcas =# include("utils_field_multi_broadcast_fusion.jl") -@testset "FusedMultiBroadcast VIJFH and VF" begin +@testset "FusedMultiBroadcast VIJHF and VF" begin FT = Float64 device = ClimaComms.device() space = TU.CenterExtrudedFiniteDifferenceSpace( @@ -37,7 +37,7 @@ include("utils_field_multi_broadcast_fusion.jl") nothing end -@testset "FusedMultiBroadcast VIFH" begin +@testset "FusedMultiBroadcast VIHF" begin FT = Float64 device = ClimaComms.device() # Add GPU test when https://github.com/CliMA/ClimaCore.jl/issues/1383 is fixed @@ -76,21 +76,21 @@ end end end -@testset "FusedMultiBroadcast IJFH" begin +@testset "FusedMultiBroadcast IJHF" begin FT = Float64 device = ClimaComms.device() sem_space = TU.SphereSpectralElementSpace(FT; context = ClimaComms.context(device)) - IJFH_data() = Fields.Field(FT, sem_space) + IJHF_data() = Fields.Field(FT, sem_space) X = Fields.FieldVector(; - x1 = IJFH_data(), - x2 = IJFH_data(), - x3 = IJFH_data(), + x1 = IJHF_data(), + x2 = IJHF_data(), + x3 = IJHF_data(), ) Y = Fields.FieldVector(; - y1 = IJFH_data(), - y2 = IJFH_data(), - y3 = IJFH_data(), + y1 = IJHF_data(), + y2 = IJHF_data(), + y3 = IJHF_data(), ) test_kernel!(; fused!, unfused!, X, Y) benchmark_kernel!(unfused!, X, Y, device) diff --git a/test/Fields/convergence_field_integrals.jl b/test/Fields/convergence_field_integrals.jl index 4dcf0c1842..3bfbee0551 100644 --- a/test/Fields/convergence_field_integrals.jl +++ b/test/Fields/convergence_field_integrals.jl @@ -12,7 +12,7 @@ using OrderedCollections using StaticArrays, IntervalSets import ClimaCore import ClimaCore.Utilities: PlusHalf -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, slab, diff --git a/test/Fields/field_opt.jl b/test/Fields/field_opt.jl index b57c4f3206..cc2726ae7c 100644 --- a/test/Fields/field_opt.jl +++ b/test/Fields/field_opt.jl @@ -8,7 +8,7 @@ using StaticArrays, IntervalSets import ClimaCore import ClimaComms import ClimaCore.Utilities: PlusHalf, half -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, slab, diff --git a/test/Fields/unit_field.jl b/test/Fields/unit_field.jl index 63a1f8f701..f760f8326a 100644 --- a/test/Fields/unit_field.jl +++ b/test/Fields/unit_field.jl @@ -12,7 +12,7 @@ using OrderedCollections using StaticArrays, IntervalSets import ClimaCore import ClimaCore.Utilities: PlusHalf -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, slab, @@ -57,9 +57,13 @@ end n1 = n2 = 1 Nh = n1 * n2 space = spectral_space_2D(n1 = n1, n2 = n2, Nij = Nij) + context = ClimaComms.context(space) + device = ClimaComms.device(context) + ArrayType = ClimaComms.array_type(device) + FT = Spaces.undertype(space) - field = - Fields.Field(IJFH{ComplexF64, Nij}(ones(Nij, Nij, 2, n1 * n2)), space) + data = IJHF{ComplexF64}(ArrayType{FT}, ones; Nij, Nh = n1 * n2) + field = Fields.Field(data, space) @test sum(field) ≈ Complex(1.0, 1.0) * 8.0 * 10.0 rtol = 10eps() @test sum(x -> 3.0, field) ≈ 3 * 8.0 * 10.0 rtol = 10eps() @@ -89,12 +93,12 @@ end # test broadcasting res = field .+ 1 @test parent(Fields.field_values(res)) == Float64[ - f == 1 ? 2 : 1 for i in 1:Nij, j in 1:Nij, f in 1:2, h in 1:(n1 * n2) + f == 1 ? 2 : 1 for i in 1:Nij, j in 1:Nij, h in 1:(n1 * n2), f in 1:2 ] res = field.re .+ 1 @test parent(Fields.field_values(res)) == - Float64[2 for i in 1:Nij, j in 1:Nij, f in 1:1, h in 1:(n1 * n2)] + Float64[2 for i in 1:Nij, j in 1:Nij, h in 1:(n1 * n2), f in 1:1] # test field slab broadcasting f1 = ones(space) @@ -248,13 +252,14 @@ end Nij = 4 Nh = n1 * n2 space = spectral_space_2D(n1 = n1, n2 = n2, Nij = Nij) - - nt_field = Fields.Field( - IJFH{NamedTuple{(:a, :b), Tuple{Float64, Float64}}, Nij}( - ones(Nij, Nij, 2, Nh), - ), - space, - ) + S = NamedTuple{(:a, :b), Tuple{Float64, Float64}} + context = ClimaComms.context(space) + device = ClimaComms.device(context) + ArrayType = ClimaComms.array_type(device) + FT = Spaces.undertype(space) + data = IJHF{S}(ArrayType{FT}, ones; Nij, Nh) + + nt_field = Fields.Field(data, space) nt_sum = sum(nt_field) @test nt_sum isa NamedTuple{(:a, :b), Tuple{Float64, Float64}} @test nt_sum.a ≈ 8.0 * 10.0 rtol = 10eps() @@ -416,7 +421,7 @@ end end @testset "FieldVector basetype replacement and deepcopy" begin - device = ClimaComms.CPUSingleThreaded() # constructing space_vijfh is broken + device = ClimaComms.CPUSingleThreaded() # constructing space_vijhf is broken context = ClimaComms.SingletonCommsContext(device) domain_z = Domains.IntervalDomain( Geometry.ZPoint(-1.0) .. Geometry.ZPoint(1.0), @@ -444,10 +449,10 @@ end quad = Quadratures.GLL{4}() space_vf = Spaces.CenterFiniteDifferenceSpace(topology_z) - space_ifh = Spaces.SpectralElementSpace1D(topology_x, quad) - space_ijfh = Spaces.SpectralElementSpace2D(topology_xy, quad) - space_vifh = Spaces.ExtrudedFiniteDifferenceSpace(space_ifh, space_vf) - space_vijfh = Spaces.ExtrudedFiniteDifferenceSpace(space_ijfh, space_vf) + space_ihf = Spaces.SpectralElementSpace1D(topology_x, quad) + space_ijhf = Spaces.SpectralElementSpace2D(topology_xy, quad) + space_vihf = Spaces.ExtrudedFiniteDifferenceSpace(space_ihf, space_vf) + space_vijhf = Spaces.ExtrudedFiniteDifferenceSpace(space_ijhf, space_vf) space2field(space) = map( coord -> (coord, Geometry.Covariant12Vector(1.0, 2.0)), @@ -456,12 +461,12 @@ end Y = Fields.FieldVector( field_vf = space2field(space_vf), - field_if = slab(space2field(space_ifh), 1), - field_ifh = space2field(space_ifh), - field_ijf = slab(space2field(space_ijfh), 1, 1), - field_ijfh = space2field(space_ijfh), - field_vifh = space2field(space_vifh), - field_vijfh = space2field(space_vijfh), + field_if = slab(space2field(space_ihf), 1), + field_ihf = space2field(space_ihf), + field_ijf = slab(space2field(space_ijhf), 1, 1), + field_ijhf = space2field(space_ijhf), + field_vihf = space2field(space_vihf), + field_vijhf = space2field(space_vijhf), array = [1.0, 2.0, 3.0], scalar = 1.0, ) @@ -756,7 +761,7 @@ end end @testset "scalar assignment" begin - device = ClimaComms.CPUSingleThreaded() # constructing space_vijfh is broken + device = ClimaComms.CPUSingleThreaded() # constructing space_vijhf is broken context = ClimaComms.SingletonCommsContext(device) domain_z = Domains.IntervalDomain( Geometry.ZPoint(-1.0) .. Geometry.ZPoint(1.0), @@ -784,12 +789,12 @@ end quad = Quadratures.GLL{4}() space_vf = Spaces.CenterFiniteDifferenceSpace(topology_z) - space_ifh = Spaces.SpectralElementSpace1D(topology_x, quad) - space_ijfh = Spaces.SpectralElementSpace2D(topology_xy, quad) - space_vifh = Spaces.ExtrudedFiniteDifferenceSpace(space_ifh, space_vf) - space_vijfh = Spaces.ExtrudedFiniteDifferenceSpace(space_ijfh, space_vf) + space_ihf = Spaces.SpectralElementSpace1D(topology_x, quad) + space_ijhf = Spaces.SpectralElementSpace2D(topology_xy, quad) + space_vihf = Spaces.ExtrudedFiniteDifferenceSpace(space_ihf, space_vf) + space_vijhf = Spaces.ExtrudedFiniteDifferenceSpace(space_ijhf, space_vf) - C = map(x -> Geometry.Covariant12Vector(1.0, 1.0), zeros(space_vifh)) + C = map(x -> Geometry.Covariant12Vector(1.0, 1.0), zeros(space_vihf)) @test all(==(1.0), parent(C)) C .= Ref(zero(eltype(C))) @test all(==(0.0), parent(C)) diff --git a/test/Fields/unit_field_multi_broadcast_fusion.jl b/test/Fields/unit_field_multi_broadcast_fusion.jl index f8d2fb30d4..8b3cae8c17 100644 --- a/test/Fields/unit_field_multi_broadcast_fusion.jl +++ b/test/Fields/unit_field_multi_broadcast_fusion.jl @@ -72,7 +72,7 @@ end nothing end -@testset "FusedMultiBroadcast VIJFH and VF" begin +@testset "FusedMultiBroadcast VIJHF and VF" begin FT = Float64 device = ClimaComms.device() space = TU.CenterExtrudedFiniteDifferenceSpace( @@ -97,7 +97,7 @@ end nothing end -@testset "FusedMultiBroadcast VIFH" begin +@testset "FusedMultiBroadcast VIHF" begin FT = Float64 device = ClimaComms.device() # Add GPU test when https://github.com/CliMA/ClimaCore.jl/issues/1383 is fixed @@ -130,21 +130,21 @@ end end end -@testset "FusedMultiBroadcast IJFH" begin +@testset "FusedMultiBroadcast IJHF" begin FT = Float64 device = ClimaComms.device() sem_space = TU.SphereSpectralElementSpace(FT; context = ClimaComms.context(device)) - IJFH_data() = Fields.Field(FT, sem_space) + IJHF_data() = Fields.Field(FT, sem_space) X = Fields.FieldVector(; - x1 = IJFH_data(), - x2 = IJFH_data(), - x3 = IJFH_data(), + x1 = IJHF_data(), + x2 = IJHF_data(), + x3 = IJHF_data(), ) Y = Fields.FieldVector(; - y1 = IJFH_data(), - y2 = IJFH_data(), - y3 = IJFH_data(), + y1 = IJHF_data(), + y2 = IJHF_data(), + y3 = IJHF_data(), ) test_kernel!(; fused!, unfused!, X, Y) nothing diff --git a/test/Fields/utils_field_multi_broadcast_fusion.jl b/test/Fields/utils_field_multi_broadcast_fusion.jl index 35abea33be..6ed28593c4 100644 --- a/test/Fields/utils_field_multi_broadcast_fusion.jl +++ b/test/Fields/utils_field_multi_broadcast_fusion.jl @@ -14,7 +14,7 @@ using OrderedCollections using StaticArrays, IntervalSets import ClimaCore import ClimaCore.Utilities: PlusHalf -import ClimaCore.DataLayouts: IJFH, VF, DataF +import ClimaCore.DataLayouts: IJHF, VF, DataF import ClimaCore.DataLayouts import ClimaCore: Fields, diff --git a/test/InputOutput/hybrid3dcubedsphere.jl b/test/InputOutput/hybrid3dcubedsphere.jl index 748870b699..a676731c55 100644 --- a/test/InputOutput/hybrid3dcubedsphere.jl +++ b/test/InputOutput/hybrid3dcubedsphere.jl @@ -55,7 +55,7 @@ end ᶜlocal_geometry = Fields.local_geometry_field(center_space) ᶠlocal_geometry = Fields.local_geometry_field(face_space) - Y = Fields.FieldVector(c = ᶜlocal_geometry, f = ᶠlocal_geometry) + Y = Fields.FieldVector(; c = ᶜlocal_geometry, f = ᶠlocal_geometry) # write field vector to hdf5 file writer = InputOutput.HDF5Writer(filename, comms_ctx) diff --git a/test/MatrixFields/field_matrix_solvers.jl b/test/MatrixFields/field_matrix_solvers.jl index 0c54a3651e..8fa77d2384 100644 --- a/test/MatrixFields/field_matrix_solvers.jl +++ b/test/MatrixFields/field_matrix_solvers.jl @@ -48,7 +48,7 @@ function test_field_matrix_solver(; test_name, alg, A, b, use_rel_error = false) if use_rel_error @test rel_error < 1e-5 else - @test max_eps_error <= 3 + @test max_eps_error <= 7 end # In addition to ignoring the type instabilities from CUDA, ignore those diff --git a/test/MatrixFields/matrix_fields_broadcasting/test_scalar_2.jl b/test/MatrixFields/matrix_fields_broadcasting/test_scalar_2.jl index ef579d3727..537200d6c4 100644 --- a/test/MatrixFields/matrix_fields_broadcasting/test_scalar_2.jl +++ b/test/MatrixFields/matrix_fields_broadcasting/test_scalar_2.jl @@ -17,7 +17,7 @@ test_opt = get(ENV, "BUILDKITE", "") == "true" bc; input_fields, using_cuda, - allowed_max_eps_error = 1, + allowed_max_eps_error = 2, ) test_opt && opt_test_field_broadcast_against_array_reference( result, diff --git a/test/MatrixFields/matrix_fields_broadcasting/test_scalar_9.jl b/test/MatrixFields/matrix_fields_broadcasting/test_scalar_9.jl index 0f71848f34..a4180469db 100644 --- a/test/MatrixFields/matrix_fields_broadcasting/test_scalar_9.jl +++ b/test/MatrixFields/matrix_fields_broadcasting/test_scalar_9.jl @@ -44,7 +44,7 @@ test_opt = get(ENV, "BUILDKITE", "") == "true" temp_value_fields, ref_set_result!, using_cuda, - allowed_max_eps_error = 10, + allowed_max_eps_error = 12, ) test_opt && opt_test_field_broadcast_against_array_reference( result, diff --git a/test/Operators/finitedifference/benchmark_stencils_utils.jl b/test/Operators/finitedifference/benchmark_stencils_utils.jl index 2013c037b2..7345f617e1 100644 --- a/test/Operators/finitedifference/benchmark_stencils_utils.jl +++ b/test/Operators/finitedifference/benchmark_stencils_utils.jl @@ -316,7 +316,7 @@ end function sphere_benchmark_arrays(device, z_elems, helem, Nq, ::Type{FT}; compile::Bool = false) where {FT} ArrayType = ClimaComms.array_type(device) - # VIJFH + # VIJHF Nh = helem * helem * 6 cdims = (z_elems , Nq, Nq, 1, Nh) fdims = (z_elems+1, Nq, Nq, 1, Nh) diff --git a/test/Operators/remapping.jl b/test/Operators/remapping.jl index 0301c377fa..f0a2f50bc3 100644 --- a/test/Operators/remapping.jl +++ b/test/Operators/remapping.jl @@ -12,7 +12,7 @@ using ClimaCore: using ClimaCore.Operators: local_weights, LinearRemap, remap, remap! using ClimaCore.Topologies: Topology2D using ClimaCore.Spaces: AbstractSpace -using ClimaCore.DataLayouts: IJFH +using ClimaCore.DataLayouts: IJHF using IntervalSets, LinearAlgebra, SparseArrays FT = Float64 diff --git a/test/Operators/spectralelement/plane.jl b/test/Operators/spectralelement/plane.jl index b5539004e5..05946a50b1 100644 --- a/test/Operators/spectralelement/plane.jl +++ b/test/Operators/spectralelement/plane.jl @@ -1,7 +1,7 @@ using Test using StaticArrays using ClimaComms -import ClimaCore.DataLayouts: IJFH, VF +import ClimaCore.DataLayouts: IJHF, VF import ClimaCore: Geometry, Fields, diff --git a/test/Operators/spectralelement/rectilinear.jl b/test/Operators/spectralelement/rectilinear.jl index 2fcfdb97e0..e3797c8a8e 100644 --- a/test/Operators/spectralelement/rectilinear.jl +++ b/test/Operators/spectralelement/rectilinear.jl @@ -2,7 +2,7 @@ using Test using StaticArrays using ClimaComms ClimaComms.@import_required_backends -import ClimaCore.DataLayouts: IJFH, VF +import ClimaCore.DataLayouts: IJHF, VF import ClimaCore: Geometry, Fields, diff --git a/test/Operators/spectralelement/sphere_curl.jl b/test/Operators/spectralelement/sphere_curl.jl index 0042c06c9a..932163e5bb 100644 --- a/test/Operators/spectralelement/sphere_curl.jl +++ b/test/Operators/spectralelement/sphere_curl.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/sphere_diffusion.jl b/test/Operators/spectralelement/sphere_diffusion.jl index e0ee785a42..ea947dffb8 100644 --- a/test/Operators/spectralelement/sphere_diffusion.jl +++ b/test/Operators/spectralelement/sphere_diffusion.jl @@ -1,7 +1,7 @@ using Test using StaticArrays, IntervalSets using ClimaComms -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/sphere_diffusion_vec.jl b/test/Operators/spectralelement/sphere_diffusion_vec.jl index 9941be97b8..6233d12618 100644 --- a/test/Operators/spectralelement/sphere_diffusion_vec.jl +++ b/test/Operators/spectralelement/sphere_diffusion_vec.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/sphere_divergence.jl b/test/Operators/spectralelement/sphere_divergence.jl index b20996e215..283165da25 100644 --- a/test/Operators/spectralelement/sphere_divergence.jl +++ b/test/Operators/spectralelement/sphere_divergence.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/sphere_gradient.jl b/test/Operators/spectralelement/sphere_gradient.jl index fbbc72ab93..540955aefc 100644 --- a/test/Operators/spectralelement/sphere_gradient.jl +++ b/test/Operators/spectralelement/sphere_gradient.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/unit_diffusion2d.jl b/test/Operators/spectralelement/unit_diffusion2d.jl index ebf1350b6c..fc8af29f36 100644 --- a/test/Operators/spectralelement/unit_diffusion2d.jl +++ b/test/Operators/spectralelement/unit_diffusion2d.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/unit_sphere_hyperdiffusion.jl b/test/Operators/spectralelement/unit_sphere_hyperdiffusion.jl index 93ebaeb994..e0eef7a8ef 100644 --- a/test/Operators/spectralelement/unit_sphere_hyperdiffusion.jl +++ b/test/Operators/spectralelement/unit_sphere_hyperdiffusion.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Operators/spectralelement/utils_sphere_hyperdiffusion_vec.jl b/test/Operators/spectralelement/utils_sphere_hyperdiffusion_vec.jl index 518c88cf22..611b1b0116 100644 --- a/test/Operators/spectralelement/utils_sphere_hyperdiffusion_vec.jl +++ b/test/Operators/spectralelement/utils_sphere_hyperdiffusion_vec.jl @@ -1,7 +1,7 @@ using Test using ClimaComms using StaticArrays, IntervalSets -import ClimaCore.DataLayouts: IJFH +import ClimaCore.DataLayouts: IJHF import ClimaCore: Fields, Domains, diff --git a/test/Spaces/ddss1.jl b/test/Spaces/ddss1.jl index 60cdde8cf9..d1e6057cb9 100644 --- a/test/Spaces/ddss1.jl +++ b/test/Spaces/ddss1.jl @@ -95,7 +95,7 @@ init_state_vector(local_geometry, p) = Geometry.Covariant12Vector(1.0, -1.0) y0 = init_state_scalar.(Fields.local_geometry_field(space), Ref(nothing)) nel = Topologies.nlocalelems(Spaces.topology(space)) yarr = parent(y0) - yarr .= reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) + yarr .= reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) dss_buffer = Spaces.create_dss_buffer(y0) Spaces.weighted_dss!(y0, dss_buffer) # DSS2 diff --git a/test/Spaces/distributed/ddss2.jl b/test/Spaces/distributed/ddss2.jl index 7254df22ad..2d6dc9d2d4 100644 --- a/test/Spaces/distributed/ddss2.jl +++ b/test/Spaces/distributed/ddss2.jl @@ -43,7 +43,7 @@ include("ddss_setup.jl") nel = Topologies.nlocalelems(Spaces.topology(space)) yarr = parent(y0) yarr .= - reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) .+ + reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) .+ (pid - 1) * Nq * Nq * nel dss2_buffer = Spaces.create_dss_buffer(y0) diff --git a/test/Spaces/distributed/ddss3.jl b/test/Spaces/distributed/ddss3.jl index f482abaabc..1cba108244 100644 --- a/test/Spaces/distributed/ddss3.jl +++ b/test/Spaces/distributed/ddss3.jl @@ -77,7 +77,7 @@ partition numbers nel = Topologies.nlocalelems(Spaces.topology(space)) yarr = parent(y0) yarr .= - reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) .+ + reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) .+ (pid - 1) * Nq * Nq * nel dss2_buffer = Spaces.create_dss_buffer(y0) diff --git a/test/Spaces/distributed/ddss4.jl b/test/Spaces/distributed/ddss4.jl index bbfacf4a3d..0374e4a3ca 100644 --- a/test/Spaces/distributed/ddss4.jl +++ b/test/Spaces/distributed/ddss4.jl @@ -14,7 +14,7 @@ include("ddss_setup.jl") nel = Topologies.nlocalelems(Spaces.topology(space)) yarr = parent(y0) yarr .= - reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) .+ + reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) .+ (pid - 1) * Nq * Nq * nel dss2_buffer = Spaces.create_dss_buffer(y0) diff --git a/test/Spaces/distributed_cuda/ddss2.jl b/test/Spaces/distributed_cuda/ddss2.jl index f780cfd317..8373dcf5a7 100644 --- a/test/Spaces/distributed_cuda/ddss2.jl +++ b/test/Spaces/distributed_cuda/ddss2.jl @@ -92,7 +92,7 @@ pid, nprocs = ClimaComms.init(context) nel = Topologies.nlocalelems(Spaces.topology(space)) yarr = parent(y0) yarr .= - reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) .+ + reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) .+ (pid - 1) * Nq * Nq * nel dss_buffer = Spaces.create_dss_buffer(y0) Spaces.weighted_dss!(y0, dss_buffer) # DSS2 diff --git a/test/Spaces/distributed_cuda/ddss3.jl b/test/Spaces/distributed_cuda/ddss3.jl index 695086a147..a453cfc4d1 100644 --- a/test/Spaces/distributed_cuda/ddss3.jl +++ b/test/Spaces/distributed_cuda/ddss3.jl @@ -124,7 +124,7 @@ partition numbers yarr = parent(y0) yarr .= - reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) .+ + reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) .+ (pid - 1) * Nq * Nq * nel dss_buffer = Spaces.create_dss_buffer(y0) diff --git a/test/Spaces/distributed_cuda/ddss4.jl b/test/Spaces/distributed_cuda/ddss4.jl index c46bf49242..a220eafec0 100644 --- a/test/Spaces/distributed_cuda/ddss4.jl +++ b/test/Spaces/distributed_cuda/ddss4.jl @@ -63,7 +63,7 @@ pid, nprocs = ClimaComms.init(context) nel = Topologies.nlocalelems(Spaces.topology(space)) yarr = parent(y0) yarr .= - reshape(1:(Nq * Nq * nel), (Nq, Nq, 1, nel)) .+ + reshape(1:(Nq * Nq * nel), (Nq, Nq, nel, 1)) .+ (pid - 1) * Nq * Nq * nel dss_buffer = Spaces.create_dss_buffer(y0) Spaces.weighted_dss!(y0, dss_buffer) # DSS2 diff --git a/test/Spaces/unit_spaces.jl b/test/Spaces/unit_spaces.jl index 6195da8c12..97c480f705 100644 --- a/test/Spaces/unit_spaces.jl +++ b/test/Spaces/unit_spaces.jl @@ -21,7 +21,7 @@ import ClimaCore: DeviceSideContext, DeviceSideDevice -import ClimaCore.DataLayouts: IJFH, VF, slab_index +import ClimaCore.DataLayouts: IJHF, VF, slab_index on_gpu = ClimaComms.device() isa ClimaComms.CUDADevice @@ -113,7 +113,7 @@ on_gpu || @testset "extruded (2d 1×3) finite difference space" begin c_space = Spaces.CenterExtrudedFiniteDifferenceSpace(f_space) s = DataLayouts.farray_size(Spaces.coordinates_data(c_space)) z = Fields.coordinate_field(c_space).z - @test s == (10, 4, 2, 5) # 10V, 4I, 2F(x,z), 5H + @test s == (10, 4, 5, 2) # 10V, 4I, 5H, 2F(x,z) @test Spaces.local_geometry_type(typeof(f_space)) <: Geometry.LocalGeometry @test Spaces.local_geometry_type(typeof(c_space)) <: Geometry.LocalGeometry @@ -220,7 +220,7 @@ end quadrature: 4-point Gauss-Legendre-Lobatto quadrature""" coord_data = Spaces.coordinates_data(space) - @test DataLayouts.farray_size(coord_data) == (4, 4, 2, 1) + @test DataLayouts.farray_size(coord_data) == (4, 4, 1, 2) coord_slab = slab(coord_data, 1) @test coord_slab[slab_index(1, 1)] ≈ Geometry.XYPoint{FT}(-3.0, -2.0) @test coord_slab[slab_index(4, 1)] ≈ Geometry.XYPoint{FT}(5.0, -2.0) @@ -256,7 +256,7 @@ end @test length(boundary_surface_geometries) == 2 @test keys(boundary_surface_geometries) == (:south, :north) @test sum(parent(boundary_surface_geometries.north.sWJ)) ≈ 8 - @test parent(boundary_surface_geometries.north.normal)[1, :, 1] ≈ [0.0, 1.0] + @test parent(boundary_surface_geometries.north.normal)[1, 1, :] ≈ [0.0, 1.0] point_space = Spaces.column(space, 1, 1, 1) @test point_space isa Spaces.PointSpace @@ -336,7 +336,7 @@ end @test size(array) == (4, 4, 2, 4) Nij = length(points) - field = Fields.Field(IJFH{FT, Nij, n1 * n2}(ones(Nij, Nij, 1, n1 * n2)), space) + field = Fields.Field(IJHF{FT, Nij, n1 * n2}(ones(Nij, Nij, 1, n1 * n2)), space) field_values = Fields.field_values(field) Spaces.horizontal_dss!(field) @@ -419,7 +419,7 @@ end data[:, :, 1, :] .= 1:Nij data[:, :, 2, :] .= (1:Nij)' data[:, :, 3, :] .= reshape(1:(n1 * n2), 1, 1, :) - field = Fields.Field(IJFH{Tuple{FT, FT, FT}, Nij, n1 * n2}(data), space) + field = Fields.Field(IJHF{Tuple{FT, FT, FT}, Nij, n1 * n2}(data), space) field_dss = Spaces.horizontal_dss!(copy(field)) data_dss = parent(field_dss) diff --git a/test/TestUtilities/TestUtilities.jl b/test/TestUtilities/TestUtilities.jl index 3fb60eab91..b3738f4c23 100644 --- a/test/TestUtilities/TestUtilities.jl +++ b/test/TestUtilities/TestUtilities.jl @@ -159,10 +159,10 @@ function all_spaces( FaceExtrudedFiniteDifferenceSpace(FT; zelem, context, helem), # TODO: incorporate this list of spaces somehow: # space_vf = Spaces.CenterFiniteDifferenceSpace(topology_z) - # space_ifh = Spaces.SpectralElementSpace1D(topology_x, quad) - # space_ijfh = Spaces.SpectralElementSpace2D(topology_xy, quad) - # space_vifh = Spaces.ExtrudedFiniteDifferenceSpace(space_ifh, space_vf) - # space_vijfh = Spaces.ExtrudedFiniteDifferenceSpace(space_ijfh, space_vf) + # space_ihf = Spaces.SpectralElementSpace1D(topology_x, quad) + # space_ijhf = Spaces.SpectralElementSpace2D(topology_xy, quad) + # space_vihf = Spaces.ExtrudedFiniteDifferenceSpace(space_ihf, space_vf) + # space_vijhf = Spaces.ExtrudedFiniteDifferenceSpace(space_ijhf, space_vf) ] end diff --git a/test/deprecations.jl b/test/deprecations.jl index 5f0fb4455a..79fb566c11 100644 --- a/test/deprecations.jl +++ b/test/deprecations.jl @@ -48,11 +48,11 @@ ClimaComms.@import_required_backends # For when Nh is in the type-domain # S = Float64 - # @test_deprecated DataLayouts.IJFH{S, 3}(zeros(3, 3, 1, 10)) - # @test_deprecated DataLayouts.IJFH{S, 3}(typeof(zeros(3, 3, 1, 10)), 10) - # @test_deprecated DataLayouts.IFH{S, 3}(zeros(3, 1, 10)) - # @test_deprecated DataLayouts.VIJFH{S, 10, 4}(zeros(10, 4, 4, 1, 20)) - # @test_deprecated DataLayouts.VIFH{S, 10, 4}(zeros(10, 4, 1, 20)) + # @test_deprecated DataLayouts.IJHF{S, 3}(zeros(3, 3, 1, 10)) + # @test_deprecated DataLayouts.IJHF{S, 3}(typeof(zeros(3, 3, 1, 10)), 10) + # @test_deprecated DataLayouts.IHF{S, 3}(zeros(3, 1, 10)) + # @test_deprecated DataLayouts.VIJHF{S, 10, 4}(zeros(10, 4, 4, 1, 20)) + # @test_deprecated DataLayouts.VIHF{S, 10, 4}(zeros(10, 4, 1, 20)) end nothing diff --git a/test/runtests.jl b/test/runtests.jl index a7af3ba5df..b978ce2003 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,7 +38,7 @@ UnitTest("dss" ,"Spaces/unit_dss.jl"), UnitTest("Spaces - serial CPU DSS" ,"Spaces/ddss1.jl"), UnitTest("Spaces - DSS cubed sphere" ,"Spaces/ddss1_cs.jl"), UnitTest("Sphere spaces" ,"Spaces/sphere.jl"), -# UnitTest("Terrain warp" ,"Spaces/terrain_warp.jl"), # appears to hang on GHA +UnitTest("Terrain warp" ,"Spaces/terrain_warp.jl"), # appears to hang on GHA UnitTest("Fields" ,"Fields/unit_field.jl"), # has benchmarks UnitTest("Spectral elem - rectilinear" ,"Operators/spectralelement/rectilinear.jl"), UnitTest("Spectral elem - opt" ,"Operators/spectralelement/opt.jl"),