# Performance of a transpose compared to c and cache friendliness

**URL:** https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883
**Category:** Performance
**Created:** [March 10, 2023, 7:00pm UTC](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883 "2023-03-10T19:00:20Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [March 10, 2023, 7:31pm UTC](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883/4 "2023-03-10T19:31:40Z")

</div>

> [@sneakyturtle](#):
>
> ```julia
> @inbounds for i = 1:MAX
> for j = 1:MAX
> 
> ```

Your loops are in the [wrong order](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-column-major).

~~Also, there is not much point in blocking loops like this that make only a single pass over the array, in order, e.g. to fill it.~~ You only want to block in order to increase temporal locality (e.g. in matrix multiplication, see e.g. [this Julia notebook](https://github.com/mitmath/18335/blob/spring20/notes/Memory-and-Matrices.ipynb)) and/or spatial locality (e.g. for [matrix transposition](https://discourse.julialang.org/t/function-on-matrix-transpose-and-performance/20068/4)). _Update_: sorry, I missed that you are computing A+B^T, see below.

---

_[View the full topic](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883)._
