Skip to content

Add backend-keyed to_backend; make cuda/rocm aliases#302

Open
lxmota wants to merge 1 commit into
mainfrom
add-to-backend
Open

Add backend-keyed to_backend; make cuda/rocm aliases#302
lxmota wants to merge 1 commit into
mainfrom
add-to-backend

Conversation

@lxmota
Copy link
Copy Markdown
Contributor

@lxmota lxmota commented May 22, 2026

Introduce to_backend(backend::KA.Backend, x) — moves x onto a given
KernelAbstractions backend. CPU is identity (CPU-built data already lives
on the CPU backend); CUDABackend/ROCBackend are provided by the CUDA and
AMDGPU package extensions. An unknown backend errors with a hint to load
the corresponding GPU package.

This lets downstream packages select a device by passing a KA.Backend
object, instead of depending on CUDA.jl/AMDGPU.jl directly and calling
the named cuda()/rocm() functions.

cuda(x) and rocm(x) are kept as back-compat aliases that delegate to
to_backend. FEC test suite passes.

Introduce `to_backend(backend::KA.Backend, x)` — moves `x` onto a given
KernelAbstractions backend. CPU is identity (CPU-built data already lives
on the CPU backend); CUDABackend/ROCBackend are provided by the CUDA and
AMDGPU package extensions. An unknown backend errors with a hint to load
the corresponding GPU package.

This lets downstream packages select a device by passing a KA.Backend
object, instead of depending on CUDA.jl/AMDGPU.jl directly and calling
the named cuda()/rocm() functions.

cuda(x) and rocm(x) are kept as back-compat aliases that delegate to
to_backend. FEC test suite passes.
@lxmota lxmota requested a review from cmhamel May 22, 2026 02:53
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.96%. Comparing base (d1fec2d) to head (9788820).

Files with missing lines Patch % Lines
ext/AMDGPUExt.jl 0.00% 2 Missing ⚠️
ext/CUDAExt.jl 0.00% 2 Missing ⚠️
src/FiniteElementContainers.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #302      +/-   ##
==========================================
- Coverage   55.00%   54.96%   -0.05%     
==========================================
  Files          55       55              
  Lines        4801     4805       +4     
==========================================
  Hits         2641     2641              
- Misses       2160     2164       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant