JuliaSIMD / JuliaSIMD/LoopVectorization.jl

Incorrect result in accumulator expression

Ouverte
#147 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Julia
Étoiles
789
Forks
73
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Something is causing this third case to be unhappy:

julia> using LoopVectorization

julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
           @avx for i in eachindex(v)
               h = a * v[i] + h
           end
       end
5.877242734755752

julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
           @avx for i in eachindex(v)
               h = v[i] + b * h
           end
       end
5.35890841491465

julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
           @avx for i in eachindex(v)
               h = a * v[i] + b * h
           end
       end
ERROR: UndefVarError: ##op#602_0 not defined
Stacktrace:
 [1] macro expansion at /home/mason/.julia/packages/LoopVectorization/OZUlx/src/reconstruct_loopset.jl:503 [inlined]
 [2] _avx_! at /home/mason/.julia/packages/LoopVectorization/OZUlx/src/reconstruct_loopset.jl:503 [inlined]
 [3] top-level scope at ./REPL[16]:2

Furthermore, if I try to fix it by changing around the syntax, it actually runs and gets an incorrect result:

julia> let a = 1.5, b = 2.0, h = 3.0, v = rand(10)
           @avx for i in eachindex(v)
               h_old = h
               h = a * v[i] + b * h_old
           end
           h
       end
3.0

julia> let a = 1.5, b = 2.0, h = 3.0, v = rand(10)
           for i in eachindex(v)
               h_old = h
               h = a * v[i] + b * h_old
           end
           h
       end
3979.1681593580383

(@v1.5) pkg> st LoopVectorization
Status `~/.julia/environments/v1.5/Project.toml`
  [bdcacae8] LoopVectorization v0.8.24

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc* (2020-08-01 23:44 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 5 2600 Six-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, znver1)
Environment:
  JULIA_NUM_THREADS = 6

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Reproduisez les trois exemples d’accumulateurs avec Julia 1.5 et LoopVectorization v0.8.24. Commencez à src/reconstruct_loopset.jl:503, identifié dans la stack trace, et suivez la manière dont la boucle @avx traite l’expression combinée a * v[i] + b * h. Le travail est terminé lorsque l’expression ne déclenche plus UndefVarError et que la boucle transformée produit le même résultat que la boucle ordinaire.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
julia
Domaine
performance
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.