Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU Support in Field Calculations #222

Merged
merged 22 commits into from
Oct 15, 2021
Merged

GPU Support in Field Calculations #222

merged 22 commits into from
Oct 15, 2021

Conversation

lmh91
Copy link
Collaborator

@lmh91 lmh91 commented Oct 8, 2021

GPU Support for the SOR Field Calculation

In this PR I added GPU Support for the field calculations via KernelAbstractions.jl and it will close #60.

So far I just implemented it for cylindrical coordinates and depletion handling is not yet enabled for the GPU backend.

using CUDAKernels, SolidStateDetectors # CUDAKernels has to be loaded before SolidStateDetectors
using CUDA # -> CuArray
using Plots

T = Float32
sim = Simulation{T}(SSD_examples[:Coax])
calculate_electric_potential!( 
    sim, 
    device_array_type = CuArray, # CuArray for NVIDIA GPU / Array for CPU / ROCArray for AMD GPU
    convergence_limit = 0, # For this we have to probably add an addition kernel function 
    max_n_iterations = 10_000, # For now just perform always `max_n_iterations` iterations
    refinement_limits = [0.2, 0.1, 0.05, 0.02, 0.01]
)     

plot(sim.electric_potential)

ToDo for this PR:

  • Support cylindrical coordinates
  • Support Cartesian coordinates
  • Support Depletion handling
  • Add GPU documentation (Doc of this PR)
  • Add tests

Not necessarily in this PR

  • Test it on AMD GPUs
  • How to choose a specific GPU device (-> using multiple GPUs in parallel)
  • Add convergence check for GPU backend

Note:

  • There was also one change regarding the CPU implementation of the SOR:
    After each iteration all grid points values at r = 0 were averaged (since they are in principle the same points).
    Now, this is only done once at the very end.
    I don't think doing it after each iteration is not necessary (tests still pass) (they anyhow converge against the same value within numerical precision) and I now removed it since otherwise I would need to add an extra kernel function (GPU) for it.

  • It includes also a small bugfix in the depletion handling on the CPU backend.

@lmh91 lmh91 added enhancement Improvement of existing features performance Performance improvements labels Oct 9, 2021
@lmh91 lmh91 added this to the v0.7.0 milestone Oct 9, 2021
@lmh91 lmh91 force-pushed the gpu_sor branch 4 times, most recently from f772730 to e251056 Compare October 14, 2021 12:47
@lmh91 lmh91 changed the title [WIP] GPU Support in Field Calculations GPU Support in Field Calculations Oct 14, 2021
@lmh91 lmh91 marked this pull request as ready for review October 14, 2021 16:11
@lmh91 lmh91 merged commit 29be62e into v0.7 Oct 15, 2021
@lmh91 lmh91 deleted the gpu_sor branch November 4, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features performance Performance improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant