Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rkierulf committed Jan 23, 2025
1 parent 64efca0 commit 7eb2902
Show file tree
Hide file tree
Showing 14 changed files with 371 additions and 292 deletions.
2 changes: 2 additions & 0 deletions KomaMRICore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Carlos Castillo Passi <[email protected]>"]
version = "0.9.0"

[deps]
AcceleratedKernels = "6a4ca0a5-0e36-4168-a932-d9be78d558f1"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Expand All @@ -26,6 +27,7 @@ KomaoneAPIExt = "oneAPI"

[compat]
AMDGPU = "0.9, 1"
AcceleratedKernels = "0.2.2"
Adapt = "3, 4"
CUDA = "3, 4, 5"
Functors = "0.4, 0.5"
Expand Down
1 change: 1 addition & 0 deletions KomaMRICore/src/KomaMRICore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module KomaMRICore
# General
import Base.*, Base.abs
import KernelAbstractions as KA
import AcceleratedKernels as AK
using Reexport
using ThreadsX
# Printing
Expand Down
11 changes: 8 additions & 3 deletions KomaMRICore/src/simulation/GPUFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const LOADED_BACKENDS = Ref{Vector{KA.GPU}}([])
const BACKEND = Ref{Union{KA.Backend,Nothing}}(nothing)
const DEFAULT_PRECESSION_GROUPSIZE = 32
const DEFAULT_EXCITATION_GROUPSIZE = 256

device_name(backend) = @error "device_name called with invalid backend type $(typeof(backend))"
isfunctional(::KA.CPU) = true
Expand All @@ -10,9 +12,12 @@ name(::KA.CPU) = "CPU"
set_device!(backend, val) = @error "set_device! called with invalid parameter types: '$(typeof(backend))', '$(typeof(val))'"
set_device!(val) = set_device!(get_backend(true), val)

#oneAPI.jl doesn't support cis (https://github.com/JuliaGPU/oneAPI.jl/pull/443), so
#for now we use a custom function for each backend to implement
function _cis end
#Copied from AcceleratedKernels.jl: https://github.com/JuliaGPU/AcceleratedKernels.jl/blob/00a9c0e7a36d6e02a51dbd13032a9165caab7909/src/utils.jl#L34
struct TypeWrap{T} end
TypeWrap(T) = TypeWrap{T}()
Base.:*(x::Number, ::TypeWrap{T}) where T = T(x)

const u16 = TypeWrap(UInt16)

"""
get_backend(use_gpu)
Expand Down
206 changes: 0 additions & 206 deletions KomaMRICore/src/simulation/SimMethods/Bloch/BlochGPU.jl

This file was deleted.

60 changes: 0 additions & 60 deletions KomaMRICore/src/simulation/SimMethods/Bloch/KernelFunctions.jl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Base.view(p::BlochCPUPrealloc, i::UnitRange) = begin
end

"""Preallocates arrays for use in run_spin_precession! and run_spin_excitation!."""
function prealloc(sim_method::Bloch, backend::KA.CPU, obj::Phantom{T}, M::Mag{T}, max_block_length::Integer, precalc) where {T<:Real}
function prealloc(sim_method::Bloch, backend::KA.CPU, obj::Phantom{T}, M::Mag{T}, max_block_length::Integer, groupsize) where {T<:Real}
return BlochCPUPrealloc(
Mag(
similar(M.xy),
Expand Down Expand Up @@ -51,6 +51,7 @@ function run_spin_precession!(
sig::AbstractArray{Complex{T}},
M::Mag{T},
sim_method::Bloch,
groupsize,
backend::KA.CPU,
prealloc::BlochCPUPrealloc
) where {T<:Real}
Expand Down Expand Up @@ -121,6 +122,7 @@ function run_spin_excitation!(
sig::AbstractArray{Complex{T}},
M::Mag{T},
sim_method::Bloch,
groupsize,
backend::KA.CPU,
prealloc::BlochCPUPrealloc
) where {T<:Real}
Expand Down
Loading

0 comments on commit 7eb2902

Please sign in to comment.