![]() |
| | #1 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| Prime Number Generator 1. You cannot load any values from external files. 2. Your entire program must be contained in a single cpp file of less than 64K named PrimeFunc.cpp with a function named PrimeFunc(__int64*) which will be called by the test program. 3. You may use no more than 10 'seed' values none of which may be greater than 2^32-1 4. All code must compile under visual studio 2008 express as a win32 console program. Default optimzation settings will be used. 5. All results must be placed into the __int64* array supplied by the test program. 6. You may not use any file or network access functions. 7. You may use inline assembly, OpenMP, threads, even the GPU as long as you limit GPU code to HLSL. 8. There can be no composite numbers returned 9. You must return exactly 100 thousand primes, no more no less. 10. Programs that crash are disqualified. 11. Programs that take more than 5 minutes to complete are disqualified. 12. Entries should be made public. 13. This contest is open ended so further optimizations should be submitted as a new entry. 14. (Optional)The solution should be general enough so that it could in theory be applied to build a comprehensive list of all primes. 15. You may not include any header files other than <math.h>, some exceptions may be made to this ask first. The test system is a Pentium 4HT 3.2 GHz with 2GB of 800MHz dual channel memory. The GPU is an 8600 with 1GB of ram. A non-optimized test program was run and completed within the alloted time.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 11-26-2008 at 03:36 PM. |
| abachler is offline | |
| | #2 |
| Registered User Join Date: Jan 2005
Posts: 7,137
| How will you be verifying the correctness of the returned values? |
| Daved is offline | |
| | #3 |
| Registered User Join Date: Apr 2006 Location: United States
Posts: 3,201
| >> 3. You may use no more than 10 'seed' values none of which may be greater than 2^32-1 Does it not make sense to start from the first number in the range you require?
__________________ Os iusti meditabitur sapientiam Et lingua eius loquetur indicium "There is nothing either good or bad, but thinking makes it so." (Shakespeare, Hamlet, Act II scene ii) http://www.myspace.com/whiteflags99 |
| whiteflags is offline | |
| | #4 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| the test program will verify the values in the array after the PrimeFunc() returns.. It will test every value both for uniqueness and for primality. The testing phase of the program is not counted against the runtime of the function. Starting from 2^32+1 is fine, since it is not prime. By seed value I mean specifically prime numbers or precalculated values used to circumvent doign the actual calculations. Some algorithms require seedign with known primes to operate efficiently, so I allow the use of 10. The rule is to prevent someone from just writing a huge array with all the values and returnign it.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 11-26-2008 at 04:23 PM. |
| abachler is offline | |
| | #6 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| as stated, you can also use inline assembly or HLSL. No C# python or java if thats what you mean. here is an example of one possible solution.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 11-26-2008 at 05:35 PM. |
| abachler is offline | |
| | #7 | |
| The wheel reinvent0^r Join Date: Aug 2008 Location: Србија
Posts: 115
| I think he wanted to ask can we do it in plain C. 2. - Can't we use unsigned long long instead of int64? I'm somehow safer with it. 4. - Why not use mingw? And what's with the optimizations?
__________________ I reinvent the wheel to understand how it works. Platform: Windows XP SP2 Professional Edition Compiler: GCC 4.3.0 Editor: Notepad++ 5.4.2 Notes: Successfully using MSYS, loving my Windows makefiles. Never, ever use Cygwin. --Quotes-- Quote:
| |
| hauzer is offline | |
| | #8 |
| ‡ †hë Ö†hÈr sîÐè ‡ Join Date: Nov 2001
Posts: 274
| RSA Encryption Your Going Down baby
__________________ Try to help all less knowledgeable than yourself, within the limits provided by time, complexity and tolerance. - Nor |
| Nor is offline | |
| | #9 | |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| Quote:
you can recast the function call internally if you want, but the test program is already written and the test procedure will just invovle drag drop compile and run. Code: void YourFunc(long long*);
void PrimeFunc(__int64* blah){
YourFunc((long long*) blah);
return;
}
void YourFunc(long long* blah){
return;
}
and im not using mingw because I use VS. I stated what compiler so that you know what compiler specific extensions you can and cant use. The default optimizations on my compiler are compile for speed and it uses the static multithreaded runtimes if thats important, it shouldnt be.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet | |
| abachler is offline | |
| | #10 |
| ‡ †hë Ö†hÈr sîÐè ‡ Join Date: Nov 2001
Posts: 274
| Where do we need to send our entrys?
__________________ Try to help all less knowledgeable than yourself, within the limits provided by time, complexity and tolerance. - Nor |
| Nor is offline | |
| | #11 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| just post them here, its an open ended contest, so no need to keep secrets
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet |
| abachler is offline | |
| | #13 | |
| The wheel reinvent0^r Join Date: Aug 2008 Location: Србија
Posts: 115
| @abachler: Ok, all good.
__________________ I reinvent the wheel to understand how it works. Platform: Windows XP SP2 Professional Edition Compiler: GCC 4.3.0 Editor: Notepad++ 5.4.2 Notes: Successfully using MSYS, loving my Windows makefiles. Never, ever use Cygwin. --Quotes-- Quote:
| |
| hauzer is offline | |
| | #14 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| Sure as long as you follow rule #1 and #6, by all means use teh PIC on the NIC to crunch numbers ![]() and good luck accessign it without breakign rule #15 or #2 part b oh as far as teh earlier statement that plain C is ok, its OK as long as it will compile as C++ code. So make sure you use explicit recasts. Im not going to edit your code to get it to compile.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 11-26-2008 at 10:14 PM. |
| abachler is offline | |
| | #15 | ||
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Quote:
Quote:
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way | ||
| laserlight is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| xor linked list | adramalech | C Programming | 23 | 10-14-2008 10:13 AM |
| prime number program with function | mackieinva | C Programming | 17 | 09-20-2007 08:36 AM |
| Prime Number stops after 29, but why? | Daveo | C Programming | 22 | 09-17-2004 10:55 AM |
| Somewhat new to c++, adding Prime number and Sqrt featre to program... | thynksheraze | C++ Programming | 3 | 01-14-2003 10:34 PM |
| Random number generator | Caze | C++ Programming | 6 | 12-03-2002 08:10 AM |