Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:37:05+00:00 2026-06-14T12:37:05+00:00

I recently found this implementation of Chudnovsky’s algorithm for calculating pi: Parallel GMP-Chudnovsky using

  • 0

I recently found this implementation of Chudnovsky’s algorithm for calculating pi: Parallel GMP-Chudnovsky using OpenMP with factorization

I have compiled it for various numbers from 1o^3 to 10^8 with the default 1 core option. However, I have noticed that as I increase the number of cores, the time it takes to calculate the result takes longer for both cpu and wall clock time. Why does the higher number of cores increase the time needed for computation? Shouldn’t it speed up the calculation and result in better performance?

here is a sample output:

~/Desktop$ ./pgmp-chudnovsky 7500000 0 1
#terms=528852, depth=21, cores=1
sieve   cputime =  0.120
...................................................
bs      cputime = 30.300  wallclock = 30.313
gcd     cputime =  6.380
div     cputime =  3.800
sqrt    cputime =  2.140
mul     cputime =  1.420
total   cputime = 37.800  wallclock = 37.838
   P size=10919784 digits (1.455971)
   Q size=10919777 digits (1.455970)


~/Desktop$ ./pgmp-chudnovsky 7500000 0 2
#terms=528852, depth=21, cores=2
sieve   cputime =  0.120
...................................................
bs      cputime = 30.890  wallclock = 17.661
gcd     cputime = 12.930
div     cputime =  3.790
sqrt    cputime =  2.130
mul     cputime =  1.420
total   cputime = 38.380  wallclock = 25.153
   P size=10919611 digits (1.455948)
   Q size=10919605 digits (1.455947)

~/Desktop$ ./pgmp-chudnovsky 7500000 0 3
#terms=528852, depth=21, cores=3
sieve   cputime =  0.120
...................................................
bs      cputime = 31.400  wallclock = 14.266
gcd     cputime = 21.640
div     cputime =  3.810
sqrt    cputime =  2.130
mul     cputime =  1.410
total   cputime = 38.900  wallclock = 21.784
   P size=10726889 digits (1.430252)
   Q size=10726883 digits (1.430251)

~/Desktop$ ./pgmp-chudnovsky 7500000 0 4
#terms=528852, depth=21, cores=4
sieve   cputime =  0.130
...................................................
bs      cputime = 32.480  wallclock = 11.771
gcd     cputime = 27.770
div     cputime =  3.800
sqrt    cputime =  2.130
mul     cputime =  1.410
total   cputime = 39.980  wallclock = 19.284
   P size=10920859 digits (1.456115)
   Q size=10920852 digits (1.456114)

~/Desktop$ ./pgmp-chudnovsky 7500000 0 5
#terms=528852, depth=21, cores=5
sieve   cputime =  0.130
...................................................
bs      cputime = 33.010  wallclock = 15.496
gcd     cputime = 28.500
div     cputime =  3.790
sqrt    cputime =  2.130
mul     cputime =  1.420
total   cputime = 40.510  wallclock = 23.000
   P size=10605102 digits (1.414014)
   Q size=10605096 digits (1.414013)

~/Desktop$ ./pgmp-chudnovsky 7500000 0 10
#terms=528852, depth=21, cores=10
sieve   cputime =  0.130
...................................................
bs      cputime = 33.210  wallclock = 14.311
gcd     cputime = 29.640
div     cputime =  3.780
sqrt    cputime =  2.140
mul     cputime =  1.420
total   cputime = 40.720  wallclock = 21.822
   P size=10607304 digits (1.414307)
   Q size=10607297 digits (1.414306)

~/Desktop$ ./pgmp-chudnovsky 7500000 0 100
#terms=528852, depth=21, cores=100
sieve   cputime =  0.120
...................................................
bs      cputime = 33.080  wallclock = 13.412
gcd     cputime = 17.630
div     cputime =  3.780
sqrt    cputime =  2.130
mul     cputime =  1.420
total   cputime = 40.570  wallclock = 20.912
   P size=12169347 digits (1.622580)
   Q size=12169341 digits (1.622579)

~/Desktop$ ./pgmp-chudnovsky 7500000 0 200
#terms=528852, depth=21, cores=200
sieve   cputime =  0.130
...................................................
bs      cputime = 34.080  wallclock = 13.942
gcd     cputime = 15.620
div     cputime =  3.760
sqrt    cputime =  2.110
mul     cputime =  1.420
total   cputime = 41.530  wallclock = 21.401
   P size=12642316 digits (1.685642)
   Q size=12642309 digits (1.685641)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:37:07+00:00Added an answer on June 14, 2026 at 12:37 pm

    From the looks of the results, you have a 4-core system. Increasing the number of threads used will hurt performance after this point, because you gain the overhead of thread context-switching, without any more simultaneous work being done.

    Cores    Total Time
    1        37.838
    2        25.153
    3        21.784
    4        19.284    *Best*
    5        23.000
    10       21.822
    100      20.912
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using cocos2d-iphone, latest non-beta version. Recently I found this: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:effects , and
I recently found this post . It basically says that Eclipse has a modified
I've recently found this blog entry on a tool that writes XSS attacks directly
So, i recently found this term related somehow to neural networks, but I don't
I'm a PHP novice, and I recently found this database-free pagination script on a
I just recently found myself writing this line of code, which i did not
I found this typo recently: if (name.find('/' != string::npos)) Obviously the dev meant to
I recently found an article online that told me about this: RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2
I recently found out about C# extension methods and wrote this one: /// <summary>
So I recently found myself writing a loop similar to this one: var headers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.