Comments (3)
I get a different error with a slightly different function:
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.3.1 (2019-12-30)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using LoopVectorization
julia> function myGramF!(A, B)
M,N = size(A);
@avx for i ∈ 1:M, j ∈ 1:N
B[i,j] = zero(eltype(B))
for k ∈ 1:N
B[i,j] += A[i,k] * A[k,j]
end
end
end
myGramF! (generic function with 1 method)
julia> N = 20;
julia> A = randn(N, N);
julia> B1 = Matrix{Float64}(undef, N, N);
julia> myGramF!(A, B1)
ERROR: UndefVarError: ####RHS#424_0_0 not defined
Stacktrace:
[1] myGramF!(::Array{Float64,2}, ::Array{Float64,2}) at ./gcutils.jl:91
[2] top-level scope at REPL[6]:1
Update: I am aware that the following function works; is it obvious why it works and the two above do not?
function myGramAVX!(A, B)
z = zero(eltype(B))
M,N = size(A);
@avx for i ∈ 1:M, j ∈ 1:N
Bᵢⱼ = z
for k ∈ 1:N
Bᵢⱼ += A[i,k] * A[k,j]
end
B[i,j] = Bᵢⱼ
end
end
from loopvectorization.jl.
Thanks for the bug report!
These are all really helping to make the software more robust.
The key difference between the two versions that did not work and the version that did is that in the former, dependencies go through memory locations, while in the latter they go through variable assignment.
I had been tracking dependencies through assignments (updating bindings), but not through modifying memory.
To be brief, it wasn't recognizing that this:
B[i,j] = zero(eltype(B))
effected the results of:
B[i,j] += A[i,k] * A[k,j]
through changing memory, rather than updating variables. This resulted in a variety of problems.
I now added some basic tracking based on indices, so that your examples work and appear to be optimized correctly, with the store->load also getting CSE-ed.
I'll add your gramF!
functions to the tests when I get back home. For now, I added similar matmul code and confirmed that tests pass.
from loopvectorization.jl.
Thanks!
from loopvectorization.jl.
Related Issues (20)
- How to cite? HOT 1
- @turbo can't find index when looping over sparse arrays HOT 3
- Error with accumulation in for loop HOT 4
- Performance issue with Zygote.jl-generated function within `@turbo` HOT 2
- Possible big TTFX regression HOT 1
- Julia 1.9 error: expected Static.StaticInt{1}, got a value of type Static.StaticInt{0} HOT 5
- Julia 1.9 error: @turbo for empty iterator HOT 3
- Trouble understanding @turbo and passing kwargs HOT 4
- `vtrunc(::Float64)` issue HOT 3
- Strange compile behavior for @turbo HOT 2
- is it possible to set @turbo thread = true/false at runtime? HOT 3
- LoopVectorization fail to compile on julia 32bit REPL
- AssertionError: M == 1 HOT 9
- Inconsistent results w/ and w/o @turbo HOT 6
- vfilter with multiple conditions HOT 2
- Memory corruption HOT 2
- Incorrect results using @turbo with linear array indexing HOT 1
- Weird/inconsistent behavior with constant lhs indexing inside @turbo loop HOT 2
- Suboptimal Choice of the Vecotrization Level for Image Convolution HOT 1
- Performance for stride 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loopvectorization.jl.