JuliaSIMD / JuliaSIMD/LoopVectorization.jl
Use with ForwardDiff
- 主要言語
- Julia
- スター
- 789
- フォーク
- 73
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I was trying to use this with ForwardDiff, but not an array of structs like #19, just using dual numbers within a loop and then extracting ordinary numbers. Something like this:
```julia
dA = ForwardDiff.Dual(0.0, (1.0, 0.0))
dB = ForwardDiff.Dual(0.0, (0.0, 1.0))
for i in axes(A,1)
tmp = (A[i] + dA) * log(B[i] + dB)
C[i] = ForwardDiff.partials(tmp, 1)
...
```
I got this to run with `@avx` on the loop, by filling in whatever methods were missing, such as:
```julia
function Base.:+(x::Dual{Z,T,D}, sv::SVec{N}) where {Z,T<:Number,D,N}
duals = ntuple(n -> +(x, sv[n]), N)
Dual(svec(val.(duals)), ntuple(d -> svec(partials.(duals, d)), D))
end
@inline val(d::Dual) = d.value
@inline svec(tup::NTuple{N,T}) where {N,T} = SVec{N,T}(tup...)
```
However the result is slower than without, and has many more allocations.
I wonder whether this is expected to work, and whether adding methods like this is right thing to do? I can tidy up an example if there isn't an obvious fatal flaw here.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Issue にある ForwardDiff と @avx のループ例から始め、ベクトル化されていないバージョンと比較し、アロケーションを測定します。この使い方がサポートされているか、また、示されているようなメソッドが適切かどうかを、再現可能な例または明確な制限とともに判断できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- julia
- 領域
- performance
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100