Skip to content

Commit

Permalink
trying to make the ci happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdelrahman912 committed Nov 19, 2024
1 parent d4d5967 commit 3b2196b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
11 changes: 2 additions & 9 deletions src/GPU/KernelLauncher.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ Launches a GPU kernel using the specified backend. This interface provides a gen
mechanism for running GPU-accelerated computations across different GPU backends.
# Arguments
- `kernel::AbstractGPUKernel`: The GPU kernel to be launched.
- `::AbstractGPUKernel`: The GPU kernel to be launched.
# Notes
This function must be implemented for specific GPU kernels. If not implemented,
an error will be thrown.
"""
function launch!(kernel::AbstractKernel)
function launch!(::AbstractKernel)
throw(ErrorException("A concrete implementation of launch! is required"))
end

Expand Down Expand Up @@ -94,12 +94,5 @@ getbackend(kernel::LazyKernel) = kernel.backend


### GPU Backend ###

"""
BackendCUDA <: AbstractGPUBackend
Represents the CUDA backend for GPU acceleration. This type serves as a concrete
implementation of `AbstractGPUBackend` for executing GPU computations using CUDA.
"""
struct BackendCUDA <: AbstractBackend end
struct BackendCPU <: AbstractBackend end
2 changes: 1 addition & 1 deletion test/GPU/test_adapt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function nodes_gpu_kernel(nodes, dh, cv)
end

@testset "Adapt" begin
dh, cv = generate_problem()
dh, cv = generate_Bilinear_problem()
cpudofs = dofs_cpu(dh, cv) |> cu
ncells = dh |> get_grid |> getncells
nbasefunctions = cv |> getnbasefunctions
Expand Down
26 changes: 23 additions & 3 deletions test/GPU/test_iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ function get_cpu_kefe(dh, cellvalues)
return kes |> cu, fes |> cu
end

@testset "Test iterators" begin
dh, cellvalues = generate_problem()
@testset "Test shared memory iterators" begin
dh, cellvalues = generate_Bilinear_problem()
n_basefuncs = getnbasefunctions(cellvalues)
# 1. Test that dofs for each cell in the grid are correctly computed
# 1 Test that dofs for each cell in the grid are correctly computed
ncells = dh |> get_grid |> getncells
dofs = CUDA.fill(Int32(0), n_basefuncs, ncells)
correct_dofs = getalldofs(dh)
Expand All @@ -109,3 +109,23 @@ end
@test all(abs.(kes_gpu .- kes_cpu) .< 1.0e-3) #TODO: This needs further investigation
@test all(fes_gpu .≈ fes_cpu)
end


@testset "Test global memory iterators" begin
dh, cellvalues = generate_Biquadratic_problem()
n_basefuncs = getnbasefunctions(cellvalues)
# 1 Test that dofs for each cell in the grid are correctly computed
ncells = dh |> get_grid |> getncells
dofs = CUDA.fill(Int32(0), n_basefuncs, ncells)
correct_dofs = getalldofs(dh)
init_kernel(BackendCUDA, ncells, n_basefuncs, dof_kernel_kernel!, (dofs, dh, n_basefuncs)) |> launch!
@test all(dofs .≈ correct_dofs)

# 2. Test that local ke and fe are correctly computed
kes_gpu = CUDA.fill(0.0f0, ncells, n_basefuncs, n_basefuncs)
fes_gpu = CUDA.fill(0.0f0, ncells, n_basefuncs)
init_kernel(BackendCUDA, ncells, n_basefuncs, localkefe_kernel!, (kes_gpu, fes_gpu, cellvalues, dh)) |> launch!
kes_cpu, fes_cpu = get_cpu_kefe(dh, cellvalues)
@test all(abs.(kes_gpu .- kes_cpu) .< 1.0e-1) #TODO: This needs further investigation
@test all(fes_gpu .≈ fes_cpu)
end
26 changes: 25 additions & 1 deletion test/GPU/test_utils.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function generate_problem()
function generate_Bilinear_problem()
left = Tensor{1, 2, Float32}((0, -0))

right = Tensor{1, 2, Float32}((rand(10.0:100000.0), rand(10.0:100000.0)))
Expand All @@ -21,3 +21,27 @@ function generate_problem()

return dh, cellvalues
end

function generate_Biquadratic_problem()
left = Tensor{1, 2, Float32}((0, -0))

right = Tensor{1, 2, Float32}((rand(10.0:100000.0), rand(10.0:100000.0)))

grid_dims = (rand(100:1000), rand(100:1000)) # to make sure the problem is big enough to use `CUDAGlobalCellIterator`

grid = generate_grid(Quadrilateral, grid_dims, left, right)

ip = Lagrange{RefQuadrilateral, 2}() # define the interpolation function (i.e. Biquadratic lagrange)

qr = QuadratureRule{RefQuadrilateral}(Float32, 3) # 3x3 quadrature rule

cellvalues = CellValues(Float32, qr, ip)

dh = DofHandler(grid)

add!(dh, :u, ip)

close!(dh)

return dh, cellvalues
end

0 comments on commit 3b2196b

Please sign in to comment.