JuliaSIMD / JuliaSIMD/LoopVectorization.jl

Some bugs

オープン
#16 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Julia
スター
789
フォーク
73
PR マージ指標
30日以内にマージされた PR はありません

説明

I was playing around a bit and noticed some bugs. The first two snippets are attempts at MWE of the final snippet which is the desired calculation
```julia
function simulate(x0::Float64; T = 10.0, dt = 0.0001, vt = 1.0)
times = 0.0:dt:T
positions = zeros(length(times))
v = 0.0
a = 0.0
x = x0
@avx for ii in eachindex(times)
x = x + v * dt
positions[ii] = x/x0
end
times, positions
end

simulate(10.0) # UndefVarError, but runs without @avx
```
```julia
function simulate(x0::Float64; T = 10.0, dt = 0.0001, vt = 1.0)
times = 0.0:dt:T
positions = zeros(length(times))
v = 0.0
a = 0.0
x = x0
@avx for ii in eachindex(times)
t = times[ii]
x = x + v * dt
positions[ii] = x/x0
end
times, positions
end

simulate(10.0) # StackOverflowError
```
The final and desired code is the following
```julia
@inline friction(v::Float64, vt::Float64) = v > vt ? -3v : -3vt*sign(v)
function simulate(x0::Float64; T = 10.0, dt = 0.0001, vt = 1.0)
times = 0.0:dt:T
positions = zeros(length(times))
v = 0.0
a = 0.0
x = x0
@avx for ii in eachindex(times)
t = times[ii]
a = friction(v, vt) - 100.0*x
a = - 100.0*x
v = v + a * dt
x = x + v * dt
positions[ii] = x/x0
end
times, positions
end

simulate(10.0)
```
Original code from [discourse thread](https://discourse.julialang.org/t/how-to-optimize-the-following-code/33209/7)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

issue にある 3 つの Julia スニペットを再現し、@avx ループマクロの有無による挙動を比較する。背景を把握するためにリンク先の Discourse の議論を読み、その後、各ループ形式を @avx がどのように処理するかを追跡する。報告された UndefVarError と StackOverflowError を理解し、目的の計算が正しく動作すれば完了とする。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
julia
領域
performance, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。