Page 1 of 1
Primality test benchmark
Posted:
Sun Jul 06, 2014 3:11 am
by fuzz
Hi,
I put my first Parallella test project up at
https://github.com/wtfuzz/eprime It's a simple naive primality test counter.
Cheers
Re: Primality test benchmark
Posted:
Fri Jul 11, 2014 9:45 pm
by aolofsson
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
Re: Primality test benchmark
Posted:
Sat Jul 12, 2014 6:34 pm
by fuzz
I've submitted a PR.
Cheers!
Re: Primality test benchmark
Posted:
Sat Jul 12, 2014 7:25 pm
by aolofsson
Thanks!! Just noticed that you did the PR to epiphany-examples. Can you submit it here instead (community repo):
http://github.com/parallella/parallella-examplesThanks!
Andreas
Re: Primality test benchmark
Posted:
Wed Aug 13, 2014 1:41 am
by aihaike
@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.
Re: Primality test benchmark
Posted:
Sun Jun 07, 2015 4:42 pm
by capnrob97
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;
}
Re: Primality test benchmark
Posted:
Sun Jun 07, 2015 4:49 pm
by capnrob97
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.
Re: Primality test benchmark
Posted:
Sun Jun 07, 2015 11:46 pm
by piotr5
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...