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

Extend GPU support to Metal, ROCm, and oneAPI backends #405

Merged
merged 21 commits into from
Jun 12, 2024
Merged

Conversation

rkierulf
Copy link
Collaborator

@rkierulf rkierulf commented Jun 12, 2024

This pull request adds support for GPU backends Metal, ROCm, and oneAPI with the corresponding Julia packages (Metal.jl, AMDGPU.jl, oneAPI.jl). CUDA is still supported but is no longer an explicit dependency, so users will now need to add 'using CUDA' to their code or they will see a message informing them that no GPU backends are loaded. I've run the KomaMRICore tests with CUDA and Metal and ensured that they pass, but for AMD and oneAPI we will need to wait until
#147 to confirm that this works as expected.

I haven't made any documentation updates yet, so let me know if that needs to be done before merging. The last thing to note is with the ArbitraryMotion struct, there was a custom adapt_storage function for adapting to a CUDA device that I wasn't sure whether it was necessary, since I think Adapt.jl and Functors.jl should be able to adapt the fields correctly and the ArbitraryMotion GPU test still passed with my changes in place. Nevertheless, it's possible I will need to add that function back, and define adapt_storage functions for converting ArbitraryMotion to the other backends.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 53.75000% with 37 lines in your changes missing coverage. Please review.

Project coverage is 89.32%. Comparing base (27ae34f) to head (64897c8).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #405      +/-   ##
==========================================
- Coverage   89.47%   89.32%   -0.16%     
==========================================
  Files          43       44       +1     
  Lines        2728     2736       +8     
==========================================
+ Hits         2441     2444       +3     
- Misses        287      292       +5     
Flag Coverage Δ
base 86.42% <ø> (ø)
core 85.79% <52.56%> (-1.14%) ⬇️
files 93.70% <ø> (ø)
komamri 93.98% <100.00%> (+0.01%) ⬆️
plots 89.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
KomaMRICore/src/KomaMRICore.jl 100.00% <ø> (ø)
src/KomaUI.jl 99.27% <100.00%> (+<0.01%) ⬆️
KomaMRICore/src/simulation/Functors.jl 77.27% <77.27%> (ø)
KomaMRICore/src/simulation/SimulatorCore.jl 90.54% <60.00%> (+0.60%) ⬆️
KomaMRICore/src/simulation/GPUFunctions.jl 32.43% <33.33%> (-20.51%) ⬇️

Copy link
Member

@cncastillo cncastillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! add print_devices in docs/src/reference/3-koma-core.md so the documentation doesn't fail.

Maybe something like this (I renamed the subsection)

## GPU helper functions

```@docs
print_devices
gpu
cpu
f32
f64```

Should we add a warning to KomaMetalExt.__init__ saying that performance could be affected by JuliaGPU/Metal.jl#348?

@rkierulf rkierulf requested a review from cncastillo June 12, 2024 20:13
Copy link
Member

@cncastillo cncastillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing 😃 !! well done!

@cncastillo cncastillo merged commit 931fec8 into master Jun 12, 2024
18 checks passed
@cncastillo cncastillo deleted the multigpu branch June 12, 2024 20:22
@rkierulf rkierulf mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend GPU support to include Apple (Metal.jl), AMD (AMDGPU.jl), and Intel (OneAPI.jl)
2 participants