JuliaSIMD / JuliaSIMD/LoopVectorization.jl
Problem/error in execution order
- Vorherrschende Sprache
- Julia
- Sterne
- 789
- Forks
- 73
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I observe that the following MWE code works differently with vs without the tturbo.
```
using LoopVectorization, Random
function weird_update(a, c, d)
@tturbo for j in axes(a, 2)
tmp = 0.0
for i in axes(a, 1)
a_ij = a[i, j]
b_ij = a_ij + 1.0
tmp += b_ij^2
end
c[j] = tmp
d[j] = exp(2.0*tmp)
end
return nothing
end
m = 100
n = 5
rng = MersenneTwister(0)
a = zeros(n, m)
randn!(rng, a)
c = zeros(m)
d = zeros(m)
weird_update(a, c, d)
println(c)
println(d)
```
In fact, with tturbo, `d` is always 1, as if the code for updating `d` is written after `tmp=0.0`. On the other hand, the update for `c` works well.
Could you help me figure out a way to do this correctly with tturbo?
UPDATE1: it is weird that if I change `d[j] = exp(2.0*tmp)` to `d[j]=exp(2.0*(0.0+tmp))`, then it works correctly.
UPDATE2: The following code works even more weirdly
```
function weird_update(a, c, d)
@tturbo for j in axes(a, 2)
tmp = 0.0
for i in axes(a, 1)
a_ij = a[i, j]
b_ij = a_ij + 1.0
tmp += b_ij^2
end
c[j] = tmp
d[j] = exp(2.0*c[j])
end
return nothing
end
m = 100
n = 5
rng = MersenneTwister(0)
a = zeros(n, m)
randn!(rng, a)
c = ones(m)
d = zeros(m)
weird_update(a, c, d)
println(c)
println(d)
```
The output of `d` is all one's -- not even `exp(2)`. I am totally confused.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne damit, die minimalen Beispiele mit und ohne @tturbo auszuführen, und vergleiche die Zuweisungen an c und d, einschließlich der aktualisierten Varianten. Untersuche, wie @tturbo das schleifentragende Temporary und abhängige Stores behandelt; abgeschlossen ist die Aufgabe, wenn die Ausführungsreihenfolge verstanden ist und das Verhalten behoben oder eindeutig dokumentiert wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- julia
- Bereich
- compilers, performance
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100