# \#loopvectorization

**URL:** https://discourse.julialang.org/tag/loopvectorization/648.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Vectorizing an awkward computation: any Julia magic?](https://discourse.julialang.org/t/vectorizing-an-awkward-computation-any-julia-magic/133212)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 6\
**Last updated:** [October 19, 2025, 4:19am UTC](https://discourse.julialang.org/t/vectorizing-an-awkward-computation-any-julia-magic/133212 "2025-10-19T04:19:06Z")

</div>

I’m computing a matrix of values (specifically, a Wigner D matrix for a given ℓ value) via recurrence for a given input value R. The nature of this recurrence makes the memory-access patterns pretty ugly, and there’s re…

---

## [Can I try updating LoopVectorization?](https://discourse.julialang.org/t/can-i-try-updating-loopvectorization/125064)

<div class="topic-metadata">

**Author:** [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)\
**Replies:** 5\
**Last updated:** [July 26, 2025, 6:45am UTC](https://discourse.julialang.org/t/can-i-try-updating-loopvectorization/125064 "2025-07-26T06:45:27Z")

</div>

After contributing to Stockfish (and failing, though having good runs), I’m back to Julia. LoopVectorization seems to be deprecated for Julia 1.12. There is a bounty to fix it. I’m probing whether or not I can do the…

---

## [Why is LoopVectorization deprecated?](https://discourse.julialang.org/t/why-is-loopvectorization-deprecated/109547)

<div class="topic-metadata">

**Author:** [@wujinq](https://discourse.julialang.org/u/wujinq)\
**Replies:** 141\
**Last updated:** [July 13, 2025, 3:58pm UTC](https://discourse.julialang.org/t/why-is-loopvectorization-deprecated/109547 "2025-07-13T15:58:02Z")

</div>

In the README file of JuliaSIMD/LoopVectorization.jl: Macro(s) for vectorizing loops. (github.com) it is clearly stated that the package is deprecated for Julia 1.11 and newer versions, without any explanation. Anyone kn…

---

## [@tturbo on function call](https://discourse.julialang.org/t/tturbo-on-function-call/126224)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 4\
**Last updated:** [February 24, 2025, 3:15pm UTC](https://discourse.julialang.org/t/tturbo-on-function-call/126224 "2025-02-24T15:15:28Z")

</div>

a=randn(5\*10^7) b=randn(5\*10^7) f(a::Float64,b::Float64)::Float64 = sin(a) + cos(b) @time @tturbo @. sin(a) + cos(b) # .05 seconds @time @tturbo @. f(a,b) # 1 second Is it possible to get the @tturbo speedu…

---

## [UndefVarError when using @turbo on nested for loop whose inner loop depends on value in outer loop](https://discourse.julialang.org/t/undefvarerror-when-using-turbo-on-nested-for-loop-whose-inner-loop-depends-on-value-in-outer-loop/125477)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 2\
**Last updated:** [February 2, 2025, 8:57pm UTC](https://discourse.julialang.org/t/undefvarerror-when-using-turbo-on-nested-for-loop-whose-inner-loop-depends-on-value-in-outer-loop/125477 "2025-02-02T20:57:54Z")

</div>

I am trying to optimize some for-loops in a package I am working on, so I decided to check out LoopVectorization. I ran into some errors, and constructed the following MWE: using LoopVectorization function f(jmax,kmax)…

---

## [Autovectorization in Julia 101](https://discourse.julialang.org/t/autovectorization-in-julia-101/123472)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 2\
**Last updated:** [December 5, 2024, 11:43am UTC](https://discourse.julialang.org/t/autovectorization-in-julia-101/123472 "2024-12-05T11:43:22Z")

</div>

I’m trying to read up on autovectorization but I might be looking in the wrong place: Auto-Vectorization in LLVM — LLVM 20.0.0git documentation For one, the whole thing talks about Clang and C code, so I have doubts it…

---

## [Experiments with LoopVectorization and convolutions](https://discourse.julialang.org/t/experiments-with-loopvectorization-and-convolutions/123188)

<div class="topic-metadata">

**Author:** [@Marco\_Lombardi](https://discourse.julialang.org/u/Marco_Lombardi)\
**Replies:** 24\
**Last updated:** [December 3, 2024, 8:35pm UTC](https://discourse.julialang.org/t/experiments-with-loopvectorization-and-convolutions/123188 "2024-12-03T20:35:27Z")

</div>

I have been doing some experiments with the great LoopVectorization for convolution, and I must admit that in spite of my efforts to manually refactor my code, I have been unable to even approach the speed that this pack…

---

## [Most efficient way of adding elements within matrices in loops](https://discourse.julialang.org/t/most-efficient-way-of-adding-elements-within-matrices-in-loops/122789)

<div class="topic-metadata">

**Author:** [@BMI\_OR](https://discourse.julialang.org/u/BMI_OR)\
**Replies:** 4\
**Last updated:** [November 18, 2024, 11:31pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-adding-elements-within-matrices-in-loops/122789 "2024-11-18T23:31:41Z")

</div>

I have a vector A and I need to update its values with the ones of matrix B. Each element of B needs to be added to some values in A. The mapping of indeces from matrix to vector is given by a matrix of vectors C. I have…

---

## [Vectorise summation over index in nested for loop](https://discourse.julialang.org/t/vectorise-summation-over-index-in-nested-for-loop/121158)

<div class="topic-metadata">

**Author:** [@eveningsilverfox](https://discourse.julialang.org/u/eveningsilverfox)\
**Replies:** 7\
**Last updated:** [October 10, 2024, 11:33pm UTC](https://discourse.julialang.org/t/vectorise-summation-over-index-in-nested-for-loop/121158 "2024-10-10T23:33:32Z")

</div>

Given a function using LinearAlgebra function test(arr1, arr2, arr3, g) return 1 ./ (arr1 .+ arr2 .+ arr3 .+ im\*g) end N1 = 100000; arr1 = range(0,10,N1); N2 = 5000; arr2 = range(0,10,N2); N3 = 5000; arr3 = range…

---

## [LoopVectorization.vsum : invalid index: 4 x VectorizationBase.Vec](https://discourse.julialang.org/t/loopvectorization-vsum-invalid-index-4-x-vectorizationbase-vec/118297)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 1\
**Last updated:** [August 17, 2024, 2:06pm UTC](https://discourse.julialang.org/t/loopvectorization-vsum-invalid-index-4-x-vectorizationbase-vec/118297 "2024-08-17T14:06:15Z")

</div>

What’s wrong here? using LoopVectorization let n = 10000, k = 3, A = rand(n, k) sum(1:n) do i A\[i,1\] end # ok vsum(1:n) do i A\[i,1\] end #= ERROR: ArgumentError: invalid index: 4 …

---

## [Problems with sequential update with @turbo](https://discourse.julialang.org/t/problems-with-sequential-update-with-turbo/118397)

<div class="topic-metadata">

**Author:** [@2xu2](https://discourse.julialang.org/u/2xu2)\
**Replies:** 0\
**Last updated:** [August 20, 2024, 12:42am UTC](https://discourse.julialang.org/t/problems-with-sequential-update-with-turbo/118397 "2024-08-20T00:42:53Z")

</div>

I have the following minimal working example that contains two weird behaviors of @turbo with sequential update: using LoopVectorization # Incorrect usage of @turbo function wrong\_example(n) x = 0.0 y = zeros(…

---

## [Multithreaded broadcast on a grouped DimensionalData array](https://discourse.julialang.org/t/multithreaded-broadcast-on-a-grouped-dimensionaldata-array/117607)

<div class="topic-metadata">

**Author:** [@aasdelat](https://discourse.julialang.org/u/aasdelat)\
**Replies:** 33\
**Last updated:** [August 6, 2024, 4:04pm UTC](https://discourse.julialang.org/t/multithreaded-broadcast-on-a-grouped-dimensionaldata-array/117607 "2024-08-06T16:04:30Z")

</div>

Hello: I am using the Rasters.jl package to read and work with data on a spatial and a time dimension (two dimensions). So it is a Raster with two dimensions. I have gropued the raster by means of the groupby() functio…

---

## [Help understanding JET.jl output](https://discourse.julialang.org/t/help-understanding-jet-jl-output/116788)

<div class="topic-metadata">

**Author:** [@james3](https://discourse.julialang.org/u/james3)\
**Replies:** 1\
**Last updated:** [July 9, 2024, 2:47pm UTC](https://discourse.julialang.org/t/help-understanding-jet-jl-output/116788 "2024-07-09T14:47:57Z")

</div>

I’m using JET.jl with my code. It is giving me an error with a function, but I don’t really understand why. For a vector x (e.g. x = -.3 .+ rand(10)), I have a simple one-liner, vmapreduce(abs, max, x), which calculates …

---

## [Has anyone used Enzyme with LoopVectorization's @turbo macro?](https://discourse.julialang.org/t/has-anyone-used-enzyme-with-loopvectorizations-turbo-macro/115872)

<div class="topic-metadata">

**Author:** [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Replies:** 4\
**Last updated:** [June 19, 2024, 7:11pm UTC](https://discourse.julialang.org/t/has-anyone-used-enzyme-with-loopvectorizations-turbo-macro/115872 "2024-06-19T19:11:59Z")

</div>

I’m attempting to use it but facing difficulty

---

## [Compute pairwise distances (Distances.jl)](https://discourse.julialang.org/t/compute-pairwise-distances-distances-jl/54297)

<div class="topic-metadata">

**Author:** [@bhaveshshrimali](https://discourse.julialang.org/u/bhaveshshrimali)\
**Replies:** 9\
**Last updated:** [February 1, 2024, 2:38pm UTC](https://discourse.julialang.org/t/compute-pairwise-distances-distances-jl/54297 "2024-02-01T14:38:22Z")

</div>

While trying to port some of my code from Python (NumPy + Numba) to Julia, I noticed that the pairwise distance evaluation is at times slightly slower when using Distances.jl. It is a pretty trivial piece of code that I …

---

## [Trivial port from C++/Rust to Julia](https://discourse.julialang.org/t/trivial-port-from-c-rust-to-julia/105787)

<div class="topic-metadata">

**Author:** [@feribg](https://discourse.julialang.org/u/feribg)\
**Replies:** 51\
**Last updated:** [December 28, 2023, 5:21am UTC](https://discourse.julialang.org/t/trivial-port-from-c-rust-to-julia/105787 "2023-12-28T05:21:30Z")

</div>

I’m trying to port a very trivial MC simulation from C++ / Rust to Julia. Here are the 3 implementations: C++: (clang OSX) https://pastebin.com/HWEUxa6W Rust: https://pastebin.com/7d31ynJE Julia: https://pastebin.com…

---

## [Array Contraction, LoopVectorization & AD](https://discourse.julialang.org/t/array-contraction-loopvectorization-ad/107721)

<div class="topic-metadata">

**Author:** [@marcobonici](https://discourse.julialang.org/u/marcobonici)\
**Replies:** 7\
**Last updated:** [December 18, 2023, 9:16pm UTC](https://discourse.julialang.org/t/array-contraction-loopvectorization-ad/107721 "2023-12-18T21:16:16Z")

</div>

Hi everyone, I have been using LoopVectorization.jl with very satisfactory results to speedup some calculations. Now, I have been hitting a problem: combining it with AD! Although my use case is not super complicated …

---

## [Optimizing Direct 2D Convolution Code](https://discourse.julialang.org/t/optimizing-direct-2d-convolution-code/106598)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 14\
**Last updated:** [November 23, 2023, 8:48pm UTC](https://discourse.julialang.org/t/optimizing-direct-2d-convolution-code/106598 "2023-11-23T20:48:40Z")

</div>

I have implemented 2D convolution using direct calculation: using BenchmarkTools; function \_Conv2D!( mO :: Matrix{T}, mI :: Matrix{T}, mK :: Matrix{T} ) where {T \<: AbstractFloat} numRowsI, numColsI = size(mI); …

---

## [What is idiomatic way of vectorizing longer operations in Julia?](https://discourse.julialang.org/t/what-is-idiomatic-way-of-vectorizing-longer-operations-in-julia/104117)

<div class="topic-metadata">

**Author:** [@Devetak](https://discourse.julialang.org/u/Devetak)\
**Replies:** 5\
**Last updated:** [September 21, 2023, 6:22pm UTC](https://discourse.julialang.org/t/what-is-idiomatic-way-of-vectorizing-longer-operations-in-julia/104117 "2023-09-21T18:22:06Z")

</div>

Hello. I have recently tried writing some code and need help with vectorization. I like that Julia’s loops are efficient, but sometimes I want to write less verbose code. How to do it in this case? What are the best pra…

---

## [How to use LoopVectorization.jl?](https://discourse.julialang.org/t/how-to-use-loopvectorization-jl/103858)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 7\
**Last updated:** [September 15, 2023, 3:34pm UTC](https://discourse.julialang.org/t/how-to-use-loopvectorization-jl/103858 "2023-09-15T15:34:05Z")

</div>

I have a question regarding LoopVectorization.jl. I’ve been trying to integrate it into my project but am stuck with some errors. Here is a MWE that reproduces it: function F!(xllp ::Vector{Vector{Int}}, xllw ::Vector{V…

---

## [Optimizing nested loops with conditional inside](https://discourse.julialang.org/t/optimizing-nested-loops-with-conditional-inside/101724)

<div class="topic-metadata">

**Author:** [@Luis\_Alberto\_R](https://discourse.julialang.org/u/Luis_Alberto_R)\
**Replies:** 10\
**Last updated:** [July 19, 2023, 3:30am UTC](https://discourse.julialang.org/t/optimizing-nested-loops-with-conditional-inside/101724 "2023-07-19T03:30:34Z")

</div>

Hello, I’m trying to build hydrodynamic codes in 1D, 2D and 3D in Julia. So far I have the codes working with first order solvers, and I’ve managed to make the 1D and 2D faster than Python and C++, now I’m trying to impl…

---

## [Faster isapprox()](https://discourse.julialang.org/t/faster-isapprox/101202)

<div class="topic-metadata">

**Author:** [@user\_231578](https://discourse.julialang.org/u/user_231578)\
**Replies:** 14\
**Last updated:** [July 5, 2023, 2:51pm UTC](https://discourse.julialang.org/t/faster-isapprox/101202 "2023-07-05T14:51:14Z")

</div>

I have to run (possibly) millions of times the function isapprox(A, A\_, rtol=1e-4), where A and A\_ are two matrices. To improve efficiency, I defined a custom isapprox() function using a more efficient norm: using LoopV…

---

## [Unsure why I'm getting errors with LoopVectorization](https://discourse.julialang.org/t/unsure-why-im-getting-errors-with-loopvectorization/98766)

<div class="topic-metadata">

**Author:** [@Dominic\_Pazzula](https://discourse.julialang.org/u/Dominic_Pazzula)\
**Replies:** 3\
**Last updated:** [May 15, 2023, 7:58am UTC](https://discourse.julialang.org/t/unsure-why-im-getting-errors-with-loopvectorization/98766 "2023-05-15T07:58:37Z")

</div>

Julia v1.8.5 LoopVectorization v0.12.159 Working on trying to maximize performance of some functions and I’m getting errors. Here is a minimum code example of one: function test(a,n) rows = size(a,1) cols = s…

---

## [Method Error in simple LoopVectorization call](https://discourse.julialang.org/t/method-error-in-simple-loopvectorization-call/98444)

<div class="topic-metadata">

**Author:** [@Alec\_Loudenback](https://discourse.julialang.org/u/Alec_Loudenback)\
**Replies:** 2\
**Last updated:** [May 7, 2023, 7:29pm UTC](https://discourse.julialang.org/t/method-error-in-simple-loopvectorization-call/98444 "2023-05-07T19:29:43Z")

</div>

With this simple example, I get an error where I do not expect it when looping over a Vector{Int} with length 2. using LoopVectorization function f(v) x = zero(eltype(v)) @turbo for i ∈ eachindex(v) amt …

---

## [Using LoopVectorization with StructArrays](https://discourse.julialang.org/t/using-loopvectorization-with-structarrays/98154)

<div class="topic-metadata">

**Author:** [@DylanMMarques](https://discourse.julialang.org/u/DylanMMarques)\
**Replies:** 3\
**Last updated:** [May 6, 2023, 11:47am UTC](https://discourse.julialang.org/t/using-loopvectorization-with-structarrays/98154 "2023-05-06T11:47:21Z")

</div>

Hello, I am using LoopVectorization combined with StructArrays to vectorize some code that used structures. I have created a simple example of what I am trying to achive using the struct Point2D. using StructArrays, Lo…

---

## [\`\`\`@turbo\`\`\` producing different (and wrong) results compared to \`\`\`@inbounds @simd\`\`\`](https://discourse.julialang.org/t/turbo-producing-different-and-wrong-results-compared-to-inbounds-simd/96851)

<div class="topic-metadata">

**Author:** [@bremez](https://discourse.julialang.org/u/bremez)\
**Replies:** 3\
**Last updated:** [March 30, 2023, 5:34pm UTC](https://discourse.julialang.org/t/turbo-producing-different-and-wrong-results-compared-to-inbounds-simd/96851 "2023-03-30T17:34:30Z")

</div>

I have a use case where an integer array contains only values between 1 and some maxValue, and I would like the histogram of the array values. I found that counts(array, maxValue) was too slow, and as best as I could und…

---

## [IfElse doesn't work properly when using @turbo](https://discourse.julialang.org/t/ifelse-doesnt-work-properly-when-using-turbo/94639)

<div class="topic-metadata">

**Author:** [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Replies:** 3\
**Last updated:** [February 14, 2023, 11:08pm UTC](https://discourse.julialang.org/t/ifelse-doesnt-work-properly-when-using-turbo/94639 "2023-02-14T23:08:53Z")

</div>

function iftest(x) bestIndex = 0 minValue = Inf @turbo for i in eachindex(x) bestIndex = ifelse(x\[i\] \< minValue, i, bestIndex) minValue = min(x\[i\], minValue) end return minValue, bestI…

---

## [@turbo macro giving slightly different results](https://discourse.julialang.org/t/turbo-macro-giving-slightly-different-results/93529)

<div class="topic-metadata">

**Author:** [@Shashank](https://discourse.julialang.org/u/Shashank)\
**Replies:** 6\
**Last updated:** [January 28, 2023, 10:37am UTC](https://discourse.julialang.org/t/turbo-macro-giving-slightly-different-results/93529 "2023-01-28T10:37:03Z")

</div>

I am trying to vectorize a loop, and adding the turbo gives slightly different results. The code does not rely on specific execution order as is the case with the example in the post below: I have pasted a MWE below. …

---

## [Matrix product \`M \* transpose(M)\`](https://discourse.julialang.org/t/matrix-product-m-transpose-m/61212)

<div class="topic-metadata">

**Author:** [@stla](https://discourse.julialang.org/u/stla)\
**Replies:** 10\
**Last updated:** [December 8, 2022, 6:02pm UTC](https://discourse.julialang.org/t/matrix-product-m-transpose-m/61212 "2022-12-08T18:02:45Z")

</div>

Hello, Is there a function in Julia to efficiently compute the matrix product M \* transpose(M)? This matrix is symmetric, so there should be a more efficient way than doing M \* transpose(M). In R one can use the tcross…

---

## [@turbo macro gives incorrect results](https://discourse.julialang.org/t/turbo-macro-gives-incorrect-results/89280)

<div class="topic-metadata">

**Author:** [@sidelkin](https://discourse.julialang.org/u/sidelkin)\
**Replies:** 4\
**Last updated:** [October 26, 2022, 3:53pm UTC](https://discourse.julialang.org/t/turbo-macro-gives-incorrect-results/89280 "2022-10-26T15:53:47Z")

</div>

I often use the @turbo macro for calculations. But I recently discovered that using it sometimes gives incorrect results. Below are minimal working examples where different options are compared. using LoopVectorization …

[Next page](https://discourse.julialang.org/tag/loopvectorization/648.md?match_all_tags=true&page=1&tags%5B%5D=loopvectorization)
