Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata MP on Apple M1 Chip

    Hi all,

    I'm running Stata 17 MP8 on my Apple MacBook Pro with the M1 chip. When I do something that I typically associate with parallelisation (e.g. bootstrapping) activity monitor suggests that only core (well 1.25 cores) is in use. Stata's website makes it clear that it runs natively on 'Apple silicon' but I didn't know if this extended to using all available cores. My suspicion is that it doesn't, and if so my question is why not? Does anyone have some experience to contrary which would suggest it's something I'm doing wrong!

    Cheers,

    Stu


  • #2
    Please run the following do-file and report back the output:

    Code:
    cscript 
    
    local var 50
    local obs 5000000
    
    set obs `obs'
    set seed 12345
    
    gen y = 0
    qui {
        forval i = 1/`var' {
            gen x`i' = runiform()
            replace y = y + `i'*x`i'
        }
    }
    
    
    timer clear
    set processors 1
    timer on 1
    qui regress y x*
    timer off 1
    
    set processors 2
    timer on 2
    qui regress y x*
    timer off 2
    
    set processors 4
    timer on 4
    qui regress y x*
    timer off 4
    
    cap set processors 8
    timer list

    Comment


    • #3
      Thanks Hua

      The results were as follows:

      1: 8.03 / 1 = 8.0310
      2: 4.78 / 1 = 4.7800
      4: 2.50 / 1 = 2.5050


      Suggesting that there was a very good speedup. But, interestingly at no point did activity monitor seem to reflect that (it never suggested it was using 400% cpu, like it does routinely on my intel Mac). Also interesting was that when I ran the timer for processors=8, it was slightly slower. Does this imply that most of the time I'd be better off with set processors 4?

      Comment


      • #4
        The M1 has four high-performance "Firestorm" and four energy-efficient "Icestorm" cores (https://en.wikipedia.org/wiki/Apple_M1). I assume when all 8 cores are used, the 4 slow cores are slowing things down. But I do not know if the size of the problem is big enough, the smaller size for each core (even the extra 4 cores are slower) will be able to make up the difference.

        Comment


        • #5
          Thanks Hua. That makes sense. Perhaps for a very big problem it's worth trying 8 but perhaps day to day, I will leave processors set at 4.

          Comment


          • #6
            interestingly at no point did activity monitor seem to reflect that (it never suggested it was using 400% cpu, like it does routinely on my intel Mac)
            Perhaps that's because the M1 Macs are more powerful, so the CPU-driven processes were in part waiting on something else?

            There's a deeply technical discussion at

            https://eclecticlight.co/2022/02/24/...ng-on-m1-macs/

            that I haven't dug into because I'm waiting for the next-generation MacBook Air to make the move. :-)

            Comment


            • #7
              Originally posted by Hua Peng (StataCorp) View Post
              The M1 has four high-performance "Firestorm" and four energy-efficient "Icestorm" cores (https://en.wikipedia.org/wiki/Apple_M1). I assume when all 8 cores are used, the 4 slow cores are slowing things down. But I do not know if the size of the problem is big enough, the smaller size for each core (even the extra 4 cores are slower) will be able to make up the difference.
              Hua, is there a way to coerce macOS to run Stata MP processes on the performance cores?

              I'm running Stata MP 2 core on a 2021 M1 MacBook pro and, taking a tip from the above link from Bill Lisowski, I checked the CPU history window within Activity Monitor and it shows that Stata is running on the 2 efficiency cores even when I'm running very computationally intensive tasks, like processing a huge data set (almost 20 GB).

              Thanks!

              Comment

              Working...
              X