title: Achieve maximum bandwidth on arm64
body: <p>I am trying to achieve near maximum memory bandwidth on my system where theoretical maximum bandwidth is
  25.5GB/s running with one DDR channel and 4 cores.</p>
  <p>I tried running following strees-ng benchmark:</p>
  <pre><code>./stress-ng --taskset 0xf --memrate 1 --memrate-wr-mbs 50000 --memrate-rd-mbs 30000 -t 60
  </code></pre>
  <p>But I see maximum bandwidth is around 11000MB/s that is less than 50% of total maximum bandwidth.</p>
  <p>Also, I see this blog about achieving maximum bandwidth:</p>
  <p><a href="https://codearcana.com/posts/2013/05/18/achieving-maximum-memory-bandwidth.html" rel="nofollow noreferrer">https://codearcana.com/posts/2013/05/18/achieving-maximum-memory-bandwidth.html</a>:</p>
  <pre><code>    void write_memory_rep_stosq(void* buffer, size_t size) {
         // size in bytes, assumed to be a multiple of 8
         asm(&quot;cld\n&quot;          // usually unnecessary, compilers keep DF=0
         &quot;rep stosq&quot;
          : : &quot;D&quot; (buffer), &quot;c&quot; (size / 8), &quot;a&quot; (0) );
          // dangerously buggy: missing &quot;memory&quot; clobber
          // and telling the compiler RDI and RCX are pure inputs, not &quot;+D&quot; / &quot;+c&quot;
      }
  </code></pre>
  <p>And when I run, I get results that are really close to the peak bandwidth, thanks to <a href="https://stackoverflow.com/questions/43343231/enhanced-rep-movsb-for-memcpy">modern x86 features like ERMSB</a> handling this with optimized microcode.</p>
  <pre><code>          $ ./memory_profiler
            write_memory_rep_stosq: 20.60 GiB/s
  </code></pre>
  <p>But this is for x86_64, is there any such equivalent instruction for ARM64 ?</p>