From 6e3bd49015bac3a0f615b38a578344adf35044e1 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Wed, 11 Jan 2023 10:39:03 -0800 Subject: [PATCH 1/2] Add gpu env back in --- .buildkite/pipeline.yml | 53 ++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2525bdd9..26040094 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -35,32 +35,33 @@ steps: queue: central slurm_ntasks: 1 - # - label: "init gpu env" - # key: "init_gpu_env" - # command: - # - echo "--- Configure MPI" - # - julia -e 'using Pkg; Pkg.add("MPIPreferences"); using MPIPreferences; use_system_binary()' + - label: "init gpu env" + key: "init_gpu_env" + command: + - "echo $$JULIA_DEPOT_PATH" + - echo "--- Configure MPI" + - julia -e 'using Pkg; Pkg.add("MPIPreferences"); using MPIPreferences; use_system_binary()' - # - echo "--- Instantiate project" - # - "julia --project -e 'using Pkg; Pkg.instantiate(;verbose=true)'" - # - "julia --project -e 'using Pkg; Pkg.precompile(;strict=true)'" + - echo "--- Instantiate project" + - "julia --project -e 'using Pkg; Pkg.instantiate(;verbose=true)'" + - "julia --project -e 'using Pkg; Pkg.precompile(;strict=true)'" - # - echo "--- Instantiate test" - # - "julia --project=test -e 'using Pkg; Pkg.develop(path=\".\")'" - # - "julia --project=test -e 'using Pkg; Pkg.instantiate(;verbose=true)'" - # - "julia --project=test -e 'using Pkg; Pkg.precompile()'" + - echo "--- Instantiate test" + - "julia --project=test -e 'using Pkg; Pkg.develop(path=\".\")'" + - "julia --project=test -e 'using Pkg; Pkg.instantiate(;verbose=true)'" + - "julia --project=test -e 'using Pkg; Pkg.precompile(;strict=true)'" - # - echo "--- Initialize CUDA runtime" - # - "julia --project -e 'using CUDA; CUDA.precompile_runtime()'" - # - "julia --project -e 'using CUDA; CUDA.versioninfo()'" + - echo "--- Initialize CUDA runtime" + - "julia --project -e 'using CUDA; CUDA.precompile_runtime()'" + - "julia --project -e 'using CUDA; CUDA.versioninfo()'" - # - echo "--- Package status" - # - "julia --project -e 'using Pkg; Pkg.status()'" - # agents: - # config: gpu - # queue: central - # slurm_ntasks: 1 - # slurm_gres: "gpu:1" + - echo "--- Package status" + - "julia --project -e 'using Pkg; Pkg.status()'" + agents: + config: gpu + queue: central + slurm_ntasks: 1 + slurm_gres: "gpu:1" - wait @@ -115,3 +116,11 @@ steps: config: cpu queue: central slurm_ntasks: 1 + + - label: "GPU" + command: + - "julia --project=test test/runtests.jl CuArray" + agents: + slurm_gres: "gpu:1" + queue: central + slurm_ntasks: 1 From 15990ea8b5908947257a125cfee353b240313a96 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Wed, 11 Jan 2023 15:59:44 -0800 Subject: [PATCH 2/2] Add simple GPU test to test suite --- .buildkite/pipeline.yml | 12 ++++++++++-- test/problems.jl | 18 +++++++++++++++--- test/simple_gpu.jl | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 test/simple_gpu.jl diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 26040094..f40f7872 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -117,9 +117,17 @@ steps: queue: central slurm_ntasks: 1 - - label: "GPU" + # - label: "GPU" + # command: + # - "julia --project=test test/runtests.jl CuArray" + # agents: + # slurm_gres: "gpu:1" + # queue: central + # slurm_ntasks: 1 + + - label: "Simple GPU" command: - - "julia --project=test test/runtests.jl CuArray" + - "julia --project=test test/simple_gpu.jl" agents: slurm_gres: "gpu:1" queue: central diff --git a/test/problems.jl b/test/problems.jl index a0affdd7..387916ec 100644 --- a/test/problems.jl +++ b/test/problems.jl @@ -1,5 +1,6 @@ using DiffEqBase, ClimaTimeSteppers, LinearAlgebra, StaticArrays using ClimaCore +import ClimaCore.Device as Device import ClimaCore.Domains as Domains import ClimaCore.Geometry as Geometry import ClimaCore.Meshes as Meshes @@ -428,9 +429,16 @@ end 2D diffusion test problem. See [`2D diffusion problem`](@ref) for more details. """ -function climacore_2Dheat_test_cts(::Type{FT}) where {FT} +function climacore_2Dheat_test_cts(::Type{FT}; print_arr_type = false) where {FT} dss_tendency = true + device = Device.device() + context = ClimaComms.SingletonCommsContext(device) + + if print_arr_type + @info "Array type: $(Device.device_array_type(device))" + end + n_elem_x = 2 n_elem_y = 2 n_poly = 2 @@ -445,13 +453,17 @@ function climacore_2Dheat_test_cts(::Type{FT}) where {FT} Domains.IntervalDomain(Geometry.YPoint(FT(0)), Geometry.YPoint(FT(1)), periodic = true), ) mesh = Meshes.RectilinearMesh(domain, n_elem_x, n_elem_y) - topology = Topologies.Topology2D(mesh) + topology = Topologies.Topology2D(context, mesh) quadrature = Spaces.Quadratures.GLL{n_poly + 1}() space = Spaces.SpectralElementSpace2D(topology, quadrature) (; x, y) = Fields.coordinate_field(space) λ = (2 * FT(π))^2 * (n_x^2 + n_y^2) - φ_sin_sin = @. sin(2 * FT(π) * n_x * x) * sin(2 * FT(π) * n_y * y) + + # Revert once https://github.com/CliMA/ClimaCore.jl/issues/1097 + # is fixed + # φ_sin_sin = @. sin(2 * FT(π) * n_x * x) * sin(2 * FT(π) * n_y * y) + φ_sin_sin = @. sin(2 * π * n_x * x) * sin(2 * π * n_y * y) init_state = Fields.FieldVector(; u = φ_sin_sin) diff --git a/test/simple_gpu.jl b/test/simple_gpu.jl new file mode 100644 index 00000000..c414dc93 --- /dev/null +++ b/test/simple_gpu.jl @@ -0,0 +1,19 @@ +using ClimaTimeSteppers +import ClimaTimeSteppers as CTS +import OrdinaryDiffEq as ODE + +include(joinpath(@__DIR__, "problems.jl")) + +function main(::Type{FT}) where {FT} + alg_name = ARS343() + test_case = climacore_2Dheat_test_cts(FT; print_arr_type = true) + prob = test_case.split_prob + alg = CTS.IMEXAlgorithm(alg_name, NewtonsMethod(; max_iters = 2)) + integrator = ODE.init(prob, alg; dt = FT(0.01)) + sol = ODE.solve!(integrator) + @info "Done!" + return integrator +end + +integrator = main(Float64) +nothing