Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Update: Added before/after results for Pi(1e9) to emphasize the performance increase.

I did an experiment on an i7-Broadwell machine running CentOS 7.3. The system gmp-devel libraries were built to support the least common denominator. Thus, leaving out optimizations for newer CPU instructions.

# default package build MPN_PATH=" x86_64/k8 x86_64 generic" # manually on the broadwell machine, includes extra optimizations MPN_PATH=" x86_64/coreibwl x86_64/coreihwl x86_64/coreisbr x86_64/core +inhm x86_64/core2 x86_64 generic"

I have everything point to the /opt/perl-5.26.1 folder to not impact the system in any way. Then, re-installed GMP modules including Math::Prime::Util.

cd gmp-6.1.2 ./configure --prefix=/opt/perl-5.26.1 make -j 4 make check make install cd Math-GMP-2.15 /opt/perl-5.26.1/bin/perl Makefile.PL INC="-I/opt/perl-5.26.1/include" + LIBS="-L/opt/perl-5.26.1/lib -lgmp" make make test make install cd Math-BigInt-GMP-1.6004 /opt/perl-5.26.1/bin/perl Makefile.PL INC="-I/opt/perl-5.26.1/include" + LIBS="-L/opt/perl-5.26.1/lib -lgmp" make make test make install cd Math-Prime-Util-GMP-0.46 /opt/perl-5.26.1/bin/perl Makefile.PL INC="-I/opt/perl-5.26.1/include" + LIBS="-L/opt/perl-5.26.1/lib -lgmp" make make test make install cd Math-Prime-Util-master /opt/perl-5.26.1/bin/perl Makefile.PL INC="-I/opt/perl-5.26.1/include" + LIBS="-L/opt/perl-5.26.1/lib -lgmp" make make test make install

Beyond 20% gain is possible by simply building GMP manually. That will set MPN_PATH to utilize the full capabilities of the processor.

time /opt/perl-5.26.1/bin/perl -Mntheory=:all -E 'say Pi(1e6)' | wc -c 1000002 0m 1.524s using system gmp libraries 0m 1.168s using gmp libraries from /opt/perl-5.26.1/lib time /opt/perl-5.26.1/bin/perl -Mntheory=:all -E 'say Pi(1e9)' | wc -c 1000000002 91m 7.581s using system gmp libraries 67m 40.951s using gmp libraries from /opt/perl-5.26.1/lib

Regards, Mario


In reply to Re^3: porting C code to Perl by marioroy
in thread porting C code to Perl by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-29 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found