Primality test benchmark

A forum for documenting the Parallella and Epiphany . (Not Q&A!)

Primality test benchmark

Postby fuzz » Sun Jul 06, 2014 3:11 am

Hi,

I put my first Parallella test project up at https://github.com/wtfuzz/eprime It's a simple naive primality test counter.

Cheers
fuzz
 
Posts: 11
Joined: Fri Jul 04, 2014 2:19 am

Re: Primality test benchmark

Postby aolofsson » Fri Jul 11, 2014 9:45 pm

Nice!!
Another native esdk example showing how to parallelize for the Epiphany! Would you consider adding it to the http://github.com/parallella/parallella-examples with a pull request?

Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: Primality test benchmark

Postby fuzz » Sat Jul 12, 2014 6:34 pm

I've submitted a PR.

Cheers!
fuzz
 
Posts: 11
Joined: Fri Jul 04, 2014 2:19 am

Re: Primality test benchmark

Postby aolofsson » Sat Jul 12, 2014 7:25 pm

Thanks!! Just noticed that you did the PR to epiphany-examples. Can you submit it here instead (community repo):

http://github.com/parallella/parallella-examples

Thanks!
Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: Primality test benchmark

Postby aihaike » Wed Aug 13, 2014 1:41 am

@fuzz Thank you so much!

That;s the first real useful example I got.
I know some doc are available but I found none of them clear and easy to read.
Are you aware of a useful tutorial or even a presentation ?
I'll use your code and the Epiphany doc from now on.
Thanks again.
User avatar
aihaike
 
Posts: 31
Joined: Wed Aug 06, 2014 5:41 am
Location: Shanghai, China

Re: Primality test benchmark

Postby capnrob97 » Sun Jun 07, 2015 4:42 pm

Old thread, I know, but just got a parallella to play with.

I unrolled the for loop a bit in the e_prime.c code, and seems to show a good bit of speed improvement.

while(*count < *max_tests)
{
if(is_prime(number))
(*primes)++;
if(is_prime(number += (2*16)))
(*primes)++;
if(is_prime(number += (2*16)))
(*primes)++;
if(is_prime(number += (2*16))
(*primes)++;
if(is_prime(number += (2*16))
(*primes)++;

// Skip to the next odd number for this core to test, assuming total of 16 cores
// Core (0,0) started with 3 on the first iteration, and next test 35
// Core (0,1) started with 5 on the first iteration, and next test 37
// etc
number += (2*16);

*sq = sqrt(number);

*num = number;

(*count) += 5;
}
capnrob97
 
Posts: 74
Joined: Fri Feb 01, 2013 1:11 pm

Re: Primality test benchmark

Postby capnrob97 » Sun Jun 07, 2015 4:49 pm

With PRIMES_PER_CORE set to 1000000

0:47.29 seconds with original loop
0:42.85 seconds with unrolling

I modified prime.c to stop when total tests = max_tests * 16 was reached and ran it as 'time ./run.sh' to get the times.
capnrob97
 
Posts: 74
Joined: Fri Feb 01, 2013 1:11 pm

Re: Primality test benchmark

Postby piotr5 » Sun Jun 07, 2015 11:46 pm

yes, loop unrolling is all good and nice (it's a gcc-option though), but have you tried using a hardware-loop somewhere inside is_prime? would make a great demo...

as far as I remember, hardware-loop wont work for the loop you actually unrolled here. but if I'm wrong, do it for both...
piotr5
 
Posts: 230
Joined: Sun Dec 23, 2012 2:48 pm


Return to Quick Start Guides , Documentation, Examples (Start Here!)

Who is online

Users browsing this forum: No registered users and 8 guests

cron