rpiswag
Posts: 804
Joined: Mon May 19, 2014 10:04 pm

Pi Only Uses 25% of CPU

Sun Mar 15, 2015 3:27 pm

When I calculate pi or any other cpu intensive task the pi 2's 4 core cpu only ever uses 25%. How can I calculate pi (pi 10000) to use all 4 cores at 100%.
A computer's power can't be just measured Gigahertz. It is the same thing with us humans.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 3:34 pm

Welcome to the vague world of multi core CPUs.

Getting 'em to run all 4 doing normal stuff is tricky. Its not difficult to load up all 4 cores for the sake of doing it at the command line, but doing it with real world useful work is something else. If you've got a quad core Windows PC, you'll rarely see it using more than 2, its the same with the Pi.

If you want to see it running at 100%, go into the command line
and do

Code: Select all

yes > /dev/null &
4 times

Code: Select all

killall yes
will stop them all.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

rpiswag
Posts: 804
Joined: Mon May 19, 2014 10:04 pm

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 3:43 pm

How can I calculate pi in the command line using all 4 cores?
A computer's power can't be just measured Gigahertz. It is the same thing with us humans.

Heater
Posts: 16092
Joined: Tue Jul 17, 2012 3:02 pm

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 3:55 pm

rpiswag,

Sounds like you need the parallel Chudnovsky algorithm for the Pi:
https://github.com/davidcarver/Parallel-Chudnovsky-PI

This is the algorithm used to gain the world record for calculating digits of Pi. All 10 billion of them!
Memory in C++ is a leaky abstraction .

rpiswag
Posts: 804
Joined: Mon May 19, 2014 10:04 pm

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 5:46 pm

How do I download that pi calculating software in terminal?
A computer's power can't be just measured Gigahertz. It is the same thing with us humans.

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 6:31 pm

rpiswag wrote:How do I download that pi calculating software in terminal?
Google how to use git. The basic format is:

Code: Select all

git clone url
There are 10 types of people: those who understand binary and those who don't.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 8:38 pm

rpiswag wrote:How do I download that pi calculating software in terminal?
Try this C program

Code: Select all

#include <stdio.h>
int a=10000,b,c=2800,d,e,f[2801],g;
main() {
      for(;b-c;) f[b++] = a/5;
            for( ; d=0,g=c*2; c-=14,printf( "%.4d", e+d/a ), e=d%a )
               for( b=c; d+=f[b]*a, f[b]=d%--g, d/=g--,--b; d*=b);
}
it's left as an exercise for you to work out how that mess gets the results.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Heater
Posts: 16092
Joined: Tue Jul 17, 2012 3:02 pm

Re: Pi Only Uses 25% of CPU

Sun Mar 15, 2015 8:44 pm

I don't know if raspbian has git installed out of the box but if not just do:

Code: Select all

$ sudo apt-get install git
Now clone a copy of the programs source code:

Code: Select all

$ git clone https://github.com/davidcarver/Parallel-Chudnovsky-PI.git
Now compile the program and run it:

Code: Select all

$ cd Parallel-Chudnovsky-PI
$ gcc -fopenmp -Wall -O2 -o raspberry-pi2-openmp raspberry-pi2-openmp.c -lgmp -lm
$ ./raspberry-pi2-openmp 10000 1 2
Memory in C++ is a leaky abstraction .

Return to “General discussion”