[R-SIG-Mac] Large number calculations causing system crash (Carl Witthoft)
Prof Brian Ripley
r|p|ey @end|ng |rom @t@t@@ox@@c@uk
Thu Feb 10 12:51:07 CET 2022
On 10/02/2022 11:20, Jake Hosen wrote:
> I just got a macbook with M1 Pro and 16gb of ram and have been getting slow R performance running R 4.1.2 GUI 1.77 Big Sur ARM build (8007). I ran this benchmark and got the following, which obviously should be a lot faster:
>
> matrix multiplication 37.913 0.499 38.288
> tcrossprod 38.028 0.548 38.518
> transposition and reuse 6.14 0.834 6.912
> elementwise after reshape 4.84 0.554 5.388
> columnwise sapply 4.879 1.45 6.236
> for loop over columns 4.557 1.813 6.374
You missed 'for vecLib' (that is, the Accelerate framework which can use
multiple cores). That is not a standard build of R, and that
'benchmark' is highly specific to certain matrix operations using the
BLAS. In other words, it tests the BLAS, not R.
If you are getting 'slow R performance' on real-world tasks, please let
us know what they are.
I have had an M1 Pro MBP for over 3 months now, and ran complete CRAN
checks a few times. I've not seen anything that is not significantly
faster than my late-2016 Intel MBP: that benchmark being ca 2.5x faster
(for reference BLAS in both cases). But the real gain is the multi-core
performance -- more cores, less contention between cores, no
high-temperature throttling.
>
>
>> On Feb 10, 2022, at 1:33 AM, Matt Denwood <md using sund.ku.dk> wrote:
>>
>> Hi both
>>
>> Just to corroborate Simon's numbers, my M1 Max (MBP 14" with 64GB ram) gets the following for vecLib:
>>
>>> source("CuriousResult.R")
>> matrix multiplication 2.07 0.527 1.571
>> tcrossprod 2.328 0.55 1.688
>> transposition and reuse 5.898 0.844 6.743
>> elementwise after reshape 4.894 0.523 5.421
>> columnwise sapply 4.767 1.445 6.212
>> for loop over columns 4.489 1.908 6.398
>>
>> Which compares to the following for R reference BLAS:
>>
>>> source("CuriousResult.R")
>> matrix multiplication 37.511 0.762 38.282
>> tcrossprod 37.519 0.737 38.254
>> transposition and reuse 5.858 0.909 6.767
>> elementwise after reshape 4.841 0.471 5.311
>> columnwise sapply 4.778 1.646 6.432
>> for loop over columns 4.485 1.948 6.434
>>
>> Both on the arm64 version of R.
>>
>> As an aside - I am extremely happy with this machine (albeit after only a few days of ownership) and would happily recommend it over the 2017 MBP that it has replaced.
>>
>> Best,
>>
>> Matt
>>
>>
>>
>>
>> On 10/02/2022, 04:22, "R-SIG-Mac on behalf of Simon Urbanek" <r-sig-mac-bounces using r-project.org <mailto:r-sig-mac-bounces using r-project.org> on behalf of simon.urbanek using R-project.org <mailto:simon.urbanek using R-project.org>> wrote:
>>
>> Joe,
>>
>> are you sure you are using the native arm64 version of R with the Accelerate bindings (formerly vecLib)? The one really cool thing about M1 is that it is very much faster than any Intel Macs (in some examples more than 10x) so what you report doesn't look right. With your script on a first-generation M1 mac mini (so the slower one) I get:
>>
>>> source("CuriousResult.R")
>> matrix multiplication 2.084 0.401 2.488
>> tcrossprod 2.284 0.396 2.68
>> transposition and reuse 5.771 0.786 6.557
>> elementwise after reshape 4.974 0.586 5.56
>> columnwise sapply 5.675 1.451 7.127
>> for loop over columns 4.565 1.633 6.199
>>
>> so I would suspect that you may be running Intel R emulated and without vecLib?
>>
>> Cheers,
>> Simon
>>
>>
>>> On Feb 10, 2022, at 12:44 PM, Joseph Kunkel <joe using bio.umass.edu> wrote:
>>>
>>> Carl, I would not buy a Mac M1Mag with 64 GB of memory. I just bought one and it is not as good as my 2013 MacBook Pro with 32 GB and 4 cores.
>>>
>>> With my 2013 MacBook Pro I could configure R to do is matrix multiplication with the fast vecLib library and it would use core doubling so that I was using up to 800% of my resources to do my big math.
>>>
>>> With my 2013 I could run the following benchmark and it would execute in 1/4 the time.
>>>
>>>> source("https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.bio.umass.edu%2Fbiology%2Fkunkel%2Fpub%2FR%2FCuriousResult.R&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=pgiqgJBJ5KY%2BTSIm43aZQWnyaMEwTvDua3y%2Fj6ThGt4%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.bio.umass.edu%2Fbiology%2Fkunkel%2Fpub%2FR%2FCuriousResult.R&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=pgiqgJBJ5KY%2BTSIm43aZQWnyaMEwTvDua3y%2Fj6ThGt4%3D&reserved=0>")
>>>
>>> matrix multiplication 21.248 1.608 5.891
>>> tcrossprod 20.346 1.454 5.39
>>> transposition and reuse 15.881 2.887 18.657
>>> elementwise after reshape 9.637 2.144 11.717
>>> columnwise sapply 13.447 11.982 25.241
>>> for loop over columns 12.435 10.14 22.44
>>>
>>> Now with R on the MacBook Pro with M1Max it takes longer to do the base multiplication and there is no accelerated option although it does the simpler non sectoral approaches faster …
>>>
>>>> source("https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.bio.umass.edu%2Fbiology%2Fkunkel%2Fpub%2FR%2FCuriousResult.R&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=pgiqgJBJ5KY%2BTSIm43aZQWnyaMEwTvDua3y%2Fj6ThGt4%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.bio.umass.edu%2Fbiology%2Fkunkel%2Fpub%2FR%2FCuriousResult.R&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=pgiqgJBJ5KY%2BTSIm43aZQWnyaMEwTvDua3y%2Fj6ThGt4%3D&reserved=0>")
>>> matrix multiplication 40.476 0.127 40.322
>>> tcrossprod 40.347 0.056 40.282
>>> transposition and reuse 6.776 0.005 6.78
>>> elementwise after reshape 7.849 0.016 7.868
>>> columnwise sapply 4.481 0.114 4.592
>>> for loop over columns 4.282 0.271 4.55
>>>
>>> I am searching for why.
>>>
>>> Joe Kunkel
>>> -·. .· ·. .><((((º>·. .· ·. .><((((º>·. .· ·. .><((((º> .··.· >=- =º}}}}}><
>>> Joseph G. Kunkel, Emeritus Professor
>>> Biology Department
>>> UMass Amherst
>>> Amherst MA 01003
>>> joe using bio.umass.edu <mailto:joe using bio.umass.edu>
>>>
>>> _______________________________________________
>>> R-SIG-Mac mailing list
>>> R-SIG-Mac using r-project.org <mailto:R-SIG-Mac using r-project.org>
>>> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-mac&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KyIiMHlCxgI5DddZnABl1RWfHoxhV3VyILj5UbMn3JQ%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-mac&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KyIiMHlCxgI5DddZnABl1RWfHoxhV3VyILj5UbMn3JQ%3D&reserved=0>
>>>
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac using r-project.org <mailto:R-SIG-Mac using r-project.org>
>> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-mac&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KyIiMHlCxgI5DddZnABl1RWfHoxhV3VyILj5UbMn3JQ%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-mac&data=04%7C01%7Cmd%40sund.ku.dk%7C0e47fdeeaf4849cfff8b08d9ec446514%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637800601372950867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KyIiMHlCxgI5DddZnABl1RWfHoxhV3VyILj5UbMn3JQ%3D&reserved=0>
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac using r-project.org <mailto:R-SIG-Mac using r-project.org>
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac <https://stat.ethz.ch/mailman/listinfo/r-sig-mac>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
--
Brian D. Ripley, ripley using stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
More information about the R-SIG-Mac
mailing list