News for hackers. Stuff that matters.
Re:Memory access on the Apple M1 processor by gameswithgo on Wednesday January 06, 2021 @02:01PM (#25660922)
What other laptop ships with LPDDR4X clocked at 4267? I agree though that being closer to the cpu isn't having any appreciable effect on latency, but being soldered close to the cpu probably does make it easier for them to hit that high clock rate.
Re:Memory access on the Apple M1 processor by jeffbee on Wednesday January 06, 2021 @02:59PM (#25661515)
As WMF mentions, Tiger Lake laptops like my Razer Book have the same memory. It is not appreciably closer to the CPU in the Apple design. In Intel's Tiger Lake reference designs the memory is also in two chips that are mounted right next to the CPU.
Re:Memory access on the Apple M1 processor by celrod on Thursday January 07, 2021 @02:49AM (#25668403)
I have a Dell XPS 13 with a Tiger Lake CPU. Out of curiosity, running the script:

  > ./two_or_three
  N = 1000000000, 953.7 MB
  starting experiments.
  two  : 30.6 ns
  two+  : 39.6 ns
  three: 45.1 ns
  bogus 1422321000
This is much slower than the times Lemire reported for the M1. `two+` is 62% of the way between `two` and and `three`, vs 88% for the M1.

EDIT: Adding `-march=native` didn't really change the results, which makes sense given that it's a memory benchmark.

Re:Memory access on the Apple M1 processor by gspr on Thursday January 07, 2021 @04:41AM (#25669155)
Strange on my XPS 15 7590 (i7-9750H), I get

   N = 1000000000, 953.7 MB
   starting experiments.
   two  : 12.8 ns
   two+  : 13.7 ns
   three: 19.5 ns
   bogus 1422321000
Re:Memory access on the Apple M1 processor by celrod on Thursday January 07, 2021 @05:45AM (#25669553)
I just ran it again, and got more or less the same results:

  N = 1000000000, 953.7 MB
  starting experiments.
  two  : 29.7 ns
  two+  : 36.5 ns
  three: 43.8 ns
This surprises me. Normally, it does very well in most benchmarks I run.

Looking a little closer at the script, it loads numbers from "random", a vector of 3 million `Int` (this is hard coded, separate from `N`). This vector is about 11.4 MiB.

The Tiger Lake CPU has 12 MiB of L3 cache (same as your i7-9750H), so it barely fits. Meanwhile, the L1 cache is 48 KiB and the L2 cache is 1.5 MiB -- huge compared to most recent CPUS, and a lot of benefit in most benchmarks, but at the cost of higher latency. https://www.anandtech.com/show/16084/intel-tiger-lake-review...

Skylake's L3 latency was 26-37 cycles, and in Willow Cove's (Tiger Lake), it is 39-45 cycles. That difference by itself isn't big enough to account for the difference we're seeing, so something else must be going on.

Re:Memory access on the Apple M1 processor by nkurz on Thursday January 07, 2021 @09:18AM (#25671254)
The caching of the random[] array (almost) shouldn't matter, as the access is sequential.

I'm wondering if the difference is the the number of active memory channels. How many channels does your respective computers support? Do you have enough RAM installed so all channels are in use? Are you able to do a RAM bandwidth test by some other means to verify?

Another possibility is that for some reason the base latency is just different between your machines. A commenter added a pointer-chasing variation of Daniel's test on his blog. Maybe run this to find the full latency and see how the times differ?

Finally, there was one more commenter on the blog who reported anomalously fast times on a Windows laptop. It's possible there is a bug with Daniel's time measurements on windows.

Re:Memory access on the Apple M1 processor by gspr on Friday January 08, 2021 @02:40AM (#25682517)
I'll run the pointer-chasing version later. Thanks

Re timing issues: I am on Linux.

Re:Memory access on the Apple M1 processor by celrod on Thursday January 07, 2021 @05:20AM (#25669396)
Yeah, that is strange. Why was it so slow? Trying on a desktop with a 7900X, I get

  N = 1000000000, 953.7 MB
  starting experiments.
  two  : 17.7 ns
  two+  : 19.1 ns
  three: 26.4 ns
  bogus 1422321000
This is again close to 50% slower than your time, but nearly twice as fast. I'll try again on the laptop and make sure I don't have other processes running.
Re:Memory access on the Apple M1 processor by gspr on Thursday January 07, 2021 @06:55AM (#25670012)
Strange. I suppose the compiler shouldn't matter much here, right? At any rate, I'm using GCC 10.2.1.
Re:Memory access on the Apple M1 processor by celrod on Thursday January 07, 2021 @07:33AM (#25670291)
I'm using gcc 10.2.0. I tried clang 11 and got more or less the same thing, so it doesn't seem to make much of a difference.

Neither did messing with flags, like (I tried -fno-semantic-interposition -march=native and a few others).

Re:Memory access on the Apple M1 processor by danaris on Wednesday January 06, 2021 @04:29PM (#25662776)
And (genuine question) how do the Tiger Lake laptops compare with the M1 MacBooks thus far?
Re:Memory access on the Apple M1 processor by skavi on Wednesday January 06, 2021 @04:52PM (#25663094)
Re:Memory access on the Apple M1 processor by jeffbee on Wednesday January 06, 2021 @05:01PM (#25663221)
The outcome seems to depend greatly on the physical design of the laptops. The elsewhere-mentioned Dell XPS 13 has a particularly poor cooling design, which is why I chose the Razer Book instead. Despite being marketed in a very silly way to gamers only, it seems to have competent mechanical design.
Re:Memory access on the Apple M1 processor by SAI_Peregrinus on Wednesday January 06, 2021 @05:52PM (#25663809)
Gamers are likely to run their systems with demanding workloads, for hours, with a color-coded performance counter (FPS stat). They'll notice if it throttles. They're particularly demanding customers, and there's quite a bit of competition for their money.
Re:Memory access on the Apple M1 processor by wil421 on Wednesday January 06, 2021 @09:27PM (#25666538)
How common are laptops for gamers? I always build my windows boxes but I’m a casual gamer.
Re:Memory access on the Apple M1 processor by SAI_Peregrinus on Thursday January 07, 2021 @03:55PM (#25677337)
I'm not sure. I know they've been getting more popular with the increased power of laptops and the ability to use external GPUs (via Thunderbolt 3). I'd guess desktops are more common, but some people will have both.
Re:Memory access on the Apple M1 processor by valuearb on Wednesday January 06, 2021 @08:32PM (#25666053)
The raw CPU performance of the M1 is about 15% faster single core, and 50% faster multicore, while using nearly half as much power.
Re:Memory access on the Apple M1 processor by sliken on Wednesday January 06, 2021 @06:28PM (#25664243)
Mind running a memory latency benchmark on your Razer Book? Does it run linux by chance?
Re:Memory access on the Apple M1 processor by wmf on Wednesday January 06, 2021 @07:37PM (#25665327)
Re:Memory access on the Apple M1 processor by wmf on Wednesday January 06, 2021 @02:27PM (#25661205)
Tiger Lake laptops such as the XPS 13.