// ============================================================
int main( const int nArg, const char *aArg[] )
{
    prime_t max = (nArg > 1)
        ? (prime_t) atou( aArg[ 1 ] )
//      :        6; // Test for 6i+1 > max
//      :    65536; // [  6,541] =    65,521 // Release:  0.006 secs
//      :   100000; // [  9,592] =    99,991 // Release:  0.010 secs
//      :   611953; // [ 49,999] =   611,953 // Release:  0.121 secs First 50,000 primes
//      :  1000000; // [ 78,497] =   999,983 // Release:  0.241 secs
        : 10000000; // [664,578] = 9,999,991 // Release:  6.21  secs
//      : 15485863; // one millionth prime   // Release: 11.57  secs One millionth prime

    AllocArray ( max );
    TimerStart ( max );
    BuildPrimes( max );
    TimerStop  ( max );
    getchar();
    PrintPrimes();
    DeleteArray();

    return 0;
}
// ============================================================
int main( const int nArg, const char *aArg[] )
{
// BEGIN OMP
    gnThreadsMaximum = omp_get_num_procs();
// END OMP

    int iArg = 1;
    for( iArg = 1; iArg < nArg; iArg++ )
    {
        if (aArg[ iArg ][0] == '-' )
        {
            if (aArg[iArg][1] == 'j')
            {
                iArg++;
                if (iArg > nArg)
                    return printf( "Invalid # of threads to use.\n" );
                gnThreadsActive = atoi( aArg[ iArg ] );
                if (gnThreadsActive < 0)
                    gnThreadsActive = 0;
                if (gnThreadsActive > gnThreadsMaximum)
                    gnThreadsActive = gnThreadsMaximum;
            }
        }
        else
            break;
    }

    prime_t max = (nArg > iArg)
        ? (prime_t) atou( aArg[ iArg ] )
//      :          6; // Test 6i+1>max && isprime(6i+1)==true
//      :         32; // Test 8 core
//      :         64; // Test 8 core
//      :        255; // 2^8 Test 8 core
//      :        256; //10^3 Test 8 core [54] = 251 // Largest 8-bit prime

//      :        100; //10^2    [             25] =            97 // 25 primes between 1 and 100
//      :       1000; //10^3    [            168] =           997
//             10000; //10^4    [          1,229] =         9,973 //
//      :      65536; // 2^16   [          6,542] =        65,521 // x86: 00:00:00.001, x64: 00:00:00.000  Primes/Sec: 64,000,000 K#/s Largest 16-bit prime
//      :     100000; //10^5    [          9,592] =        99,991 // x86: 00:00:00.001, x64: 00:00:00.000  Primes/Sec: 97,000,000 K#/s
//      :     611953; //        [         50,000] =       611,953 // x86: 00:00:00.002, x64: 00:00:00.002  Primes/Sec: 298,500 K#/s    First 50,000 primes
//      :    1000000; //10^6    [         78,498] =       999,983 // x86: 00:00:00.003, x64: 00:00:00.002  Primes/Sec: 488,000 K#/s
        :   10000000; //10^7    [        664,579] =     9,999,991 // x86: 00:00:00.031, x64: 00:00:00.034  Primes/Sec: 264 M#/s
//      :   15485863; //        [      1,000,000] =    15,485,863 // x86: 00:00:00.057, x64: 00:00:00.055  Primes/Sec: 254 M#/s        First 1,000,000 primes
//      :  100000000; //10^8    [      5,761,455] =    99,999,989 // x86: 00:00:00.490, x64: 00:00:00.484  Primes/Sec: 196 M#/s
//      : 1000000000; //10^9    [     50,847,534] =   999,999,937 // x86: crash         x64: 00:00:10.590  Primes/Sec: 89 M#/s
//      : 2038074743; //        [    100,000,000] = 2,038,074,743 //                    x64: 00:00:23.130  Primes/Sec: 84 M#/s First 100,000,000 primes
//      : 2147483644; // 2^31-4 [    105,097,564] = 2,147,483,629 //                    x64: 00:00:24.502  Primes/Sec: 83 M#/s
//      : 2147483647; // 2^31-1 [               ]
//      : 2147483648; // 2^31   [    105,097,565] = 2,147,483,647 //                    x64: 00:00:43.818  Primes/Sec: 46 M#/s
//      : 4294967292; // 2^32-4 [               ]
//      : 4294967295; // 2^32-1 [               ]
//      : 4294967296; // 2^32   [    203,280,221] =
//      :10000000000; //10^10   [    455,052,511] =
//      :       1e11; //10^11   [  4,118,054,813] =
//      :       1e12; //10^12   [ 37,607,912,018] =
//      :       1e13; //10^13   [346,065,536,839] =

    AllocArray ( max );
    TimerStart ( max );
    BuildPrimes( max );
    TimerStop  ( max );
    getchar();
    PrintPrimes();
    DeleteArray();

    return 0;
}
Example #3
0
int main()
{
	PrintPrimes();
	return 0;
}