# How to match performance of sum(A, dims=1)?

**URL:** https://discourse.julialang.org/t/how-to-match-performance-of-sum-a-dims-1/87543
**Category:** Performance
**Created:** [September 21, 2022, 4:32am UTC](https://discourse.julialang.org/t/how-to-match-performance-of-sum-a-dims-1/87543 "2022-09-21T04:32:02Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [September 21, 2022, 6:25am UTC](https://discourse.julialang.org/t/how-to-match-performance-of-sum-a-dims-1/87543/15 "2022-09-21T06:25:50Z")

</div>

I don’t think race conditions are an issue, since IIUC, we’re not accessing the same memory location from multiple tasks. What `@simd` does is [reorder associative operations](https://discourse.julialang.org/t/when-shouldnt-we-use-simd/18276/11), so it may evaluate `a + (b+c)` instead of `(a+b) + c`. This means that if we use `@simd` in reductions, it will likely change the result due to floating-point rounding errors. We may check that `mysum(arr)` differs from `vec(sum(arr, dims=1))`, although they’re approximately equal.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-match-performance-of-sum-a-dims-1/87543)._
