Skip to content

Commit

Permalink
Merge pull request #444 from JuliaHealth/fix-get-samples
Browse files Browse the repository at this point in the history
Change `reduce(vcat, itr)` to `reduce(vcat, [itr])`
  • Loading branch information
cncastillo authored Jul 12, 2024
2 parents a2837ae + 6cb5efa commit e7bfc1f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ steps:
- "KomaMRIBase/Project.toml"
- "benchmarks/**/*"
- ".buildkite/**/*"
- ".github/workflows/Benchmark.yml"
- "Project.toml"
config:
command: "buildkite-agent pipeline upload .buildkite/runbenchmarks.yml"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ on:

jobs:
benchmark:
if: "!contains(github.event.head_commit.message, '[skip benchmarks]')"
if: ${{ !contains(github.event.head_commit.message, '[skip benchmarks]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -58,7 +58,7 @@ jobs:
tool: 'julia'
output-file-path: ${{ steps.locate.outputs.path }}
benchmark-data-dir-path: "benchmarks"
summary-always: true
summary-always: true # I think this doesn't work on PRs
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
alert-threshold: "150%"
Expand Down
24 changes: 12 additions & 12 deletions KomaMRIBase/src/datatypes/Sequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,23 +314,23 @@ function get_samples(seq::Sequence, range; events=[:rf, :gr, :adc], freq_in_phas
fill_if_empty(x) = isempty(x.t) && length(range) == length(seq) ? merge(x, (t=[0.0; dur(seq)], A=zeros(eltype(x.A), 2))) : x
# RF
if :rf in events
t_rf = reduce(vcat, T0[i] .+ times(seq.RF[1,i], :A) for i in range)
t_Δf = reduce(vcat, T0[i] .+ times(seq.RF[1,i], :Δf) for i in range)
A_rf = reduce(vcat, ampls(seq.RF[1,i]; freq_in_phase) for i in range)
A_Δf = reduce(vcat, freqs(seq.RF[1,i]) for i in range)
t_rf = reduce(vcat, [T0[i] .+ times(seq.RF[1,i], :A) for i in range])
t_Δf = reduce(vcat, [T0[i] .+ times(seq.RF[1,i], :Δf) for i in range])
A_rf = reduce(vcat, [ampls(seq.RF[1,i]; freq_in_phase) for i in range])
A_Δf = reduce(vcat, [freqs(seq.RF[1,i]) for i in range])
rf_samples = (
rf = fill_if_empty((t = t_rf, A = A_rf)),
Δf = fill_if_empty((t = t_Δf, A = A_Δf))
)
end
# Gradients
if :gr in events
t_gx = reduce(vcat, T0[i] .+ times(seq.GR[1,i]) for i in range)
t_gy = reduce(vcat, T0[i] .+ times(seq.GR[2,i]) for i in range)
t_gz = reduce(vcat, T0[i] .+ times(seq.GR[3,i]) for i in range)
A_gx = reduce(vcat, ampls(seq.GR[1,i]) for i in range)
A_gy = reduce(vcat, ampls(seq.GR[2,i]) for i in range)
A_gz = reduce(vcat, ampls(seq.GR[3,i]) for i in range)
t_gx = reduce(vcat, [T0[i] .+ times(seq.GR[1,i]) for i in range])
t_gy = reduce(vcat, [T0[i] .+ times(seq.GR[2,i]) for i in range])
t_gz = reduce(vcat, [T0[i] .+ times(seq.GR[3,i]) for i in range])
A_gx = reduce(vcat, [ampls(seq.GR[1,i]) for i in range])
A_gy = reduce(vcat, [ampls(seq.GR[2,i]) for i in range])
A_gz = reduce(vcat, [ampls(seq.GR[3,i]) for i in range])
gr_samples = (
gx = fill_if_empty((t = t_gx, A = A_gx)),
gy = fill_if_empty((t = t_gy, A = A_gy)),
Expand All @@ -339,8 +339,8 @@ function get_samples(seq::Sequence, range; events=[:rf, :gr, :adc], freq_in_phas
end
# ADC
if :adc in events
t_aq = reduce(vcat, T0[i] .+ times(seq.ADC[i]) for i in range)
A_aq = reduce(vcat, ampls(seq.ADC[i]) for i in range)
t_aq = reduce(vcat, [T0[i] .+ times(seq.ADC[i]) for i in range])
A_aq = reduce(vcat, [ampls(seq.ADC[i]) for i in range])
adc_samples = (
adc = fill_if_empty((t = t_aq, A = A_aq)),
)
Expand Down

1 comment on commit e7bfc1f

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

KomaMRI Benchmarks

Benchmark suite Current: e7bfc1f Previous: a2837ae Ratio
MRI Lab/Bloch/CPU/2 thread(s) 1597348663.5 ns 1518177926 ns 1.05
MRI Lab/Bloch/CPU/4 thread(s) 920684554 ns 1264921787.5 ns 0.73
MRI Lab/Bloch/CPU/8 thread(s) 828881248 ns 586016460 ns 1.41
MRI Lab/Bloch/CPU/1 thread(s) 3226260318 ns 3944206835 ns 0.82
MRI Lab/Bloch/GPU/CUDA 154787415 ns 154008923.5 ns 1.01
MRI Lab/Bloch/GPU/oneAPI 26694868553 ns 44650285812.5 ns 0.60
MRI Lab/Bloch/GPU/Metal 3402176271 ns 3202722750 ns 1.06
MRI Lab/Bloch/GPU/AMDGPU 1790112478 ns 1785064601 ns 1.00
Slice Selection 3D/Bloch/CPU/2 thread(s) 3662737461 ns 3329807846 ns 1.10
Slice Selection 3D/Bloch/CPU/4 thread(s) 1725491180 ns 2645750395 ns 0.65
Slice Selection 3D/Bloch/CPU/8 thread(s) 1153779016 ns 1053370396 ns 1.10
Slice Selection 3D/Bloch/CPU/1 thread(s) 6320449643.5 ns 6503649361.5 ns 0.97
Slice Selection 3D/Bloch/GPU/CUDA 265782897 ns 267654789 ns 0.99
Slice Selection 3D/Bloch/GPU/oneAPI 2107401044 ns 2930224071 ns 0.72
Slice Selection 3D/Bloch/GPU/Metal 1410314000 ns 1120090167 ns 1.26
Slice Selection 3D/Bloch/GPU/AMDGPU 724434160 ns 791311651 ns 0.92

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.