Skip to content

Commit

Permalink
Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyuxie committed Dec 21, 2024
1 parent 34b86b7 commit 0a454c9
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 330 deletions.
38 changes: 20 additions & 18 deletions benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ using Trixi, TrixiCUDA
using CUDA
using BenchmarkTools

equations = CompressibleEulerEquations3D(1.4)
equations = IdealGlmMhdEquations3D(5 / 3)

initial_condition = initial_condition_convergence_test
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)

coordinates_min = (0.0, 0.0, 0.0)
coordinates_max = (2.0, 2.0, 2.0)
refinement_patches = ((type = "box", coordinates_min = (0.5, 0.5, 0.5),
coordinates_max = (1.5, 1.5, 1.5)),)
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
solver = DGSEM(polydeg = 3,
surface_flux = (flux_hlle,
flux_nonconservative_powell),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (-1.0, -1.0, -1.0)
coordinates_max = (1.0, 1.0, 1.0)
refinement_patches = ((type = "box", coordinates_min = (-0.5, -0.5, -0.5),
coordinates_max = (0.5, 0.5, 0.5)),)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 2,
refinement_patches = refinement_patches,
n_cells_max = 10_000)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_convergence_test)
semi_gpu = SemidiscretizationHyperbolicGPU(mesh, equations, initial_condition, solver,
source_terms = source_terms_convergence_test)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
semi_gpu = SemidiscretizationHyperbolicGPU(mesh, equations, initial_condition, solver)

tspan = tspan_gpu = (0.0, 1.0)
t = t_gpu = 0.0
Expand Down Expand Up @@ -73,11 +76,10 @@ TrixiCUDA.cuda_boundary_flux!(t_gpu, mesh_gpu, boundary_conditions_gpu,
equations_gpu, solver_gpu, cache_gpu)

# Prolong to mortars test
@benchmark CUDA.@sync TrixiCUDA.cuda_prolong2mortars!(u_gpu, mesh_gpu,
TrixiCUDA.check_cache_mortars(cache_gpu),
solver_gpu, cache_gpu)

# # Mortar flux test
# @benchmark CUDA.@sync TrixiCUDA.cuda_mortar_flux!(mesh_gpu, TrixiCUDA.check_cache_mortars(cache_gpu),
# Trixi.have_nonconservative_terms(equations_gpu),
# equations_gpu, solver_gpu, cache_gpu)
TrixiCUDA.cuda_prolong2mortars!(u_gpu, mesh_gpu,
TrixiCUDA.check_cache_mortars(cache_gpu),
solver_gpu, cache_gpu)

@benchmark CUDA.@sync TrixiCUDA.cuda_mortar_flux!(mesh_gpu, TrixiCUDA.check_cache_mortars(cache_gpu),
Trixi.have_nonconservative_terms(equations_gpu),
equations_gpu, solver_gpu, cache_gpu)
12 changes: 5 additions & 7 deletions src/solvers/dg_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ function mortar_flux_copy_to_kernel!(surface_flux_values, tmp_surface_flux_value
fstar_primary_upper, fstar_primary_lower,
fstar_secondary_upper, fstar_secondary_lower,
reverse_upper, reverse_lower, neighbor_ids, large_sides,
orientations, equations::AbstractEquations{2})
orientations)
i = (blockIdx().x - 1) * blockDim().x + threadIdx().x
j = (blockIdx().y - 1) * blockDim().y + threadIdx().y
k = (blockIdx().z - 1) * blockDim().z + threadIdx().z
Expand Down Expand Up @@ -1619,12 +1619,11 @@ function cuda_mortar_flux!(mesh::TreeMesh{2}, cache_mortars::True, nonconservati
reverse_lower,
neighbor_ids,
large_sides,
orientations,
equations)
orientations)
mortar_flux_copy_to_kernel(surface_flux_values, tmp_surface_flux_values, fstar_primary_upper,
fstar_primary_lower, fstar_secondary_upper, fstar_secondary_lower,
reverse_upper, reverse_lower, neighbor_ids, large_sides,
orientations, equations;
orientations;
kernel_configurator_3d(mortar_flux_copy_to_kernel,
size(surface_flux_values, 1),
size(surface_flux_values, 2),
Expand Down Expand Up @@ -1679,12 +1678,11 @@ function cuda_mortar_flux!(mesh::TreeMesh{2}, cache_mortars::True, nonconservati
reverse_lower,
neighbor_ids,
large_sides,
orientations,
equations)
orientations)
mortar_flux_copy_to_kernel(surface_flux_values, tmp_surface_flux_values, fstar_primary_upper,
fstar_primary_lower, fstar_secondary_upper, fstar_secondary_lower,
reverse_upper, reverse_lower, neighbor_ids, large_sides,
orientations, equations;
orientations;
kernel_configurator_3d(mortar_flux_copy_to_kernel,
size(surface_flux_values, 1),
size(surface_flux_values, 2),
Expand Down
Loading

0 comments on commit 0a454c9

Please sign in to comment.