MMM
Results 1 to 16 of 16

Thread: Multi Prime - A multi-threaded prime number benchmark

Threaded View

  1. #8
    Registered User
    Join Date
    Aug 2005
    Posts
    67
    close enough, but try checking only odd number against odd numbers.

    try this instead:
    Code:
    for( int x = 3; x < 32000000; x+= 2)
    {
    	for(int y = 3; y * y <= x;  y+= 2)
    	{
    		if( x &#37; y == 0)
    		{
    			//number x isnt prime
    			break;
    		}
    	}
    }
    you'll find this to be MUCH faster - and i found a few glitches in your code...

    and to thread that code, i just made a few tweaks and used a library called pthreads
    Last edited by Alpha; 04-03-2008 at 08:37 PM.
    Try my multi-threaded prime benchmark!
    If you like it and want to see more - bitcoin me!!
    1MrPonziaM4QT2S7SdPEKQH88BGa4LRHJU
    1HaxXoRZhMLxMJwJ52VfAqanSuLuh8CCki
    1ZomGoxrBqyVdBvHwPLEERsGGQAtc3jHp
    1L33thAxKo1GqRWRYP5ZCK4EjTMUTHFsc8

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •