From a1261e90b263d3c9b97e07c56e09a65e544c94a4 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Sun, 22 Dec 2024 23:16:08 -0500 Subject: [PATCH] Fix adapt for new limiters, test on gpu --- .buildkite/pipeline.yml | 15 +++++++++++++-- src/Operators/finitedifference.jl | 31 ++++++++++++++++++------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index ba77571e45..19b389e059 100755 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1454,14 +1454,14 @@ steps: - "julia --color=yes --project=.buildkite examples/column/fct_advection.jl" artifact_paths: - "examples/column/output/fct_advection/*" - + - label: ":computer: Column TVD Slope-limited Advection Eq" key: "cpu_tvd_column_advect" command: - "julia --color=yes --project=.buildkite examples/column/tvd_advection.jl" artifact_paths: - "examples/column/output/tvd_advection/*" - + - label: ":computer: Column Lin vanLeer Limiter Advection Eq" key: "cpu_lvl_column_advect" command: @@ -1469,6 +1469,17 @@ steps: artifact_paths: - "examples/column/output/vanleer_advection/*" + - label: ":computer: Column Lin vanLeer Limiter Advection Eq cuda" + key: "cpu_lvl_column_advect" + command: + - "julia --color=yes --project=.buildkite examples/column/vanleer_advection.jl" + artifact_paths: + - "examples/column/output/vanleer_advection/*" + env: + CLIMACOMMS_DEVICE: "CUDA" + agents: + slurm_gpus: 1 + - label: ":computer: Column BB FCT Advection Eq" key: "cpu_bb_fct_column_advect" command: diff --git a/src/Operators/finitedifference.jl b/src/Operators/finitedifference.jl index f9c8e38018..1ed79f430a 100644 --- a/src/Operators/finitedifference.jl +++ b/src/Operators/finitedifference.jl @@ -3061,19 +3061,24 @@ function Adapt.adapt_structure(to, bc::AbstractBoundaryCondition) end # Extend `adapt_structure` for all operator types with boundary conditions. -function Adapt.adapt_structure(to, op::FiniteDifferenceOperator) - if hasfield(typeof(op), :bcs) - bcs_adapted = NamedTuple{keys(op.bcs)}( - UnrolledFunctions.unrolled_map( - bc -> Adapt.adapt_structure(to, bc), - values(op.bcs), - ), - ) - return unionall_type(typeof(op))(bcs_adapted) - else - return op - end -end +Adapt.adapt_structure(to, op::FiniteDifferenceOperator) = + hasfield(typeof(op), :bcs) ? adapt_fd_operator(to, op, op.bcs) : op + +@inline adapt_fd_operator(to, op::LinVanLeerC2F, bcs) = + LinVanLeerC2F(adapt_bcs(to, bcs), Adapt.adapt_structure(to, op.constraint)) + +@inline adapt_fd_operator(to, op::TVDLimitedFluxC2F, bcs) = + TVDLimitedFluxC2F(adapt_bcs(to, bcs), Adapt.adapt_structure(to, op.method)) + +@inline adapt_fd_operator(to, op, bcs) = + unionall_type(typeof(op))(adapt_bcs(to, bcs)) + +@inline adapt_bcs(to, bcs) = NamedTuple{keys(bcs)}( + UnrolledFunctions.unrolled_map( + bc -> Adapt.adapt_structure(to, bc), + values(bcs), + ), +) """ D = DivergenceC2F(;boundaryname=boundarycondition...)