MPIR slow on macOS?

71 views
Skip to first unread message

Ronald Mak

unread,
Jan 14, 2019, 11:05:06 PM1/14/19
to mpir-devel
I wrote a C++ program that uses MPIR 3.0.0 to compute the first million digits of pi. On a native Linux laptop with a Core i7 1.8 GHz CPU, my pi program executed in under 8 seconds.

I installed MPIR 3.0.0 on my MacBook Pro laptop with a Core i7 2.3 GHz CPU and macOS Mojave 10.14.2. The same pi program took over 135 seconds to execute.

Then I used VirtualBox to install Ubuntu 18.10 in a virtual machine on my MacBook Pro laptop. I installed MPIR 3.0.0 on the Ubuntu VM, and the same pi program ran in about 7 seconds.

What is going on with MPIR on macOS to cause my pi program to run so much more slowly? It's apparently not a hardware issue, since the latter two runs of my pi program were on the same laptop, but on different operating systems. Does MPIR cause macOS to generate interrupts? Interpret certain instructions? Paging?

Bill Hart

unread,
Jan 14, 2019, 11:11:38 PM1/14/19
to mpir-devel
What does ./config.guess say your machine is? It's probably just too new to be detected correctly.

Bill.

Ronald Mak/SJSU

unread,
Jan 14, 2019, 11:19:06 PM1/14/19
to mpir-...@googlegroups.com

Hi, Bill.

 

On my Mac laptop:

 

~/mpir-3.0.0: ./config.guess

ivybridge-apple-darwin18.2.0

This is accurate, as far as I can tell.

I’ve attached my pi program, which I assign to my C++ classes to give my students practice downloading, configuring, building, and deploying a software library.

 

– Ron
http://www.cs.sjsu.edu/~mak/

--
You received this message because you are subscribed to the Google Groups "mpir-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+...@googlegroups.com.
To post to this group, send email to mpir-...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpir-devel.
For more options, visit https://groups.google.com/d/optout.

BigPi.cpp

Bill Hart

unread,
Jan 15, 2019, 5:16:05 AM1/15/19
to mpir-devel
That looks correct.

So your idea that it might be swapping sounds pretty likely.

I did find someone else reporting a slowdown the other day, and it turned out their program was linked to a very old GMP instead of the MPIR they built.

I'm not a Mac expert, so I don't know how to check this, but I imagine you can find out online somewhere.

Otherwise, I can't think of anything which would cause this to happen.

Bill.

Ronald Mak/SJSU

unread,
Jan 15, 2019, 2:07:57 PM1/15/19
to mpir-...@googlegroups.com

Hi, Bill.

 

This will take some detective work to see what are the differences, if any, between how MPIR is built on macOS and Linux. It could be a configuration issue. Maybe I’ll get a student to look into this.

 

– Ron
http://www.cs.sjsu.edu/~mak/

 

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.”
-- Charles Babbage, 1791-1871, world’s first computer scientist

Bill Hart

unread,
Jan 15, 2019, 2:30:44 PM1/15/19
to mpir-devel
One difference is in how jump tables are implemented. But I really don't see how that would be related to this issue.

Are you sure you are not just running out of memory under OSX? Or perhaps OSX is just pushing stuff out to disk earlier than Linux?

Bill.

Dima Pasechnik

unread,
Jan 15, 2019, 2:40:46 PM1/15/19
to mpir-...@googlegroups.com
Perhaps we can put up this code on MPIR's Travis CI and see how it
goes on OSX available there.

Dima

Ronald Mak

unread,
Mar 5, 2019, 1:30:43 AM3/5/19
to mpir-devel
Did anyone figure this out? I'm giving my class their assignment to use MPIR. Many of the students use Mac laptops.  http://www.cs.sjsu.edu/~mak/CS144/assignments/6/Assignment6.pdf 

Dima Pasechnik

unread,
Mar 5, 2019, 5:01:22 AM3/5/19
to mpir-...@googlegroups.com
On Tue, Mar 5, 2019 at 6:30 AM Ronald Mak <ron...@sjsu.edu> wrote:
>
> Did anyone figure this out? I'm giving my class their assignment to use MPIR. Many of the students use Mac laptops. http://www.cs.sjsu.edu/~mak/CS144/assignments/6/Assignment6.pdf

Did you try comparing MPIR to GMP in such a setting?
(GMP is easy to install e.g. via Homebrew, or building from source
just like with MPIR)
Reply all
Reply to author
Forward
0 new messages