Thread: Prime Number Generator

  1. #16
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Its __int64 and thats final. If you want to recast it inside your function go ahead, but the interface is set in stone. Sorry if thats a bit blunt but there has to be one set interface or Ill end up rewriting the test program for every entry. If I do it for one person ill end up doing it for everyone.

    If you have need of a specific header file state what you need, don't ask me to open it up for no reason. The only exception that comes to mind are the headers for OpenMP or for DirectX(HLSL). I see no reason that any other headers shodul be needed, but liek I said, if you need a specific header file, ask first.
    Last edited by abachler; 11-27-2008 at 07:41 AM.

  2. #17
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Why you would use HLSL for this is beyond me.

  3. #18
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    gpgpu.org
    thats why.

  4. #19
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    That will only work on DX10+ or possibly even DX11 when compute shaders are introduced. As of right now there would not be a way to transfer the 100 thousand prime numbers back to the software. That would require a ton of floating point textures and a ton of surface locks to read the values. NVidia Cuda is only available in 9+ series cards and is going to be used with their acquired PhysX chips on the video card.

  5. #20
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Bubba View Post
    NVidia Cuda is only available in 9+ series cards and is going to be used with their acquired PhysX chips on the video card.
    Wrong, all 8XXX Geforce cards support both PhysX and CUDA, including Abachlers 8600GT. PhysX requires 256MB of dedicated VRAM though so integrated cards won't do PhysX, only CUDA...
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  6. #21
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    There is also RapidMind, which I also have installed along with CUDA.

  7. #22
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'd be interested to see how you are going to get 100 thousand primes off of the video card and back into software. Shaders are not meant to communicate back down to the software level - at least not until DX11 and even then I'm a bit fuzzy on the compute shaders functionality.
    You could render the primes to a floating point texture but that would be completely inefficient. In the current architecture this does not sound like a good idea. I'm not saying it's not possible but it goes against the design of the shader paradigm...for now.

    I would think using SSE2/3/4? would be a better choice than HLSL.

  8. #23
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    I would think using SSE2/3/4? would be a better choice than HLSL.
    Depending on exactly which CPU he has, SSE3 might not even be available (SSE4 was introduced in Penryn, so we can forget about it, but I don't think it would have been useful anyway).

    abachler, are you running a 32 or 64 bit OS ? Some Pentium 4 support the x86-64 ISA, some don't.

    Oh and I tought CUDA wasn't supported by Visual Studio 2008 express edition. Well.

    Oh, and what are we winning ?
    I hate real numbers.

  9. #24
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Its a matter of the number of shaders available, operating in parallel, which amortize the innefficiency of the actual operation to produce superior absolute throughput.

    SSE3 is available, but VS2008 only supports SSE2.

    Well, CUDA is installed, but it is limited to the low level API, I havent fulyl explored what those limits are, so I will have to get back to you on that. I believe the full API requires 2005 or 2003, neither of which I have.

    The versions I run are 4.0 for 80 bit long double access, 6.0 , and 2008 because its free.

    I have CUDA 2.0 Final installed, and RapidMind 3.1 ( ineed to check for a new versin fo that).
    Last edited by abachler; 11-28-2008 at 10:10 PM.

  10. #25
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Here's my entry. It follows the contest rules. I'm targeting the best user-time possible.

    Oh man, what a waste of time.
    I hate real numbers.

  11. #26
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Violates rules 1 and 6 (no external files, no file access functions).

    It also takes longer than the original code it was based on. Probably due to setting up the file mapping.

  12. #27
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Ah well, I decided to give it a try with an obvious brute force implementation. Note that as this is in C++, I have included <cmath> instead of <math.h>.

    Interestingly, switching from std::sqrt() to the method that abachler advocated in this Prime numbers thread made no difference (it was only very marginally worse, and that could have just been due to timing inaccuracy). Therefore, it would have been better (according to my timings) to just not include any headers at all and use that method, but I decided to go with my original method anyway.

    EDIT:
    hmm... I think that 3 is not actually a seed value in my case since I am testing it for primality, hence I am uploading a modified version that has just one seed value, namely, 2.
    Last edited by laserlight; 11-29-2008 at 03:57 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #28
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    well, the actual contest is to generate primes greater than 2^32. I changed one line of your code (the typedef) so it woudl compile. Other than failign the magnitude test it looks like it woudl work.

    Code:
    // typedef unsigned __int64  PrimeType;
     
    #define PrimeType unsigned __int64



    Last edited by abachler; 11-29-2008 at 04:35 PM.

  14. #29
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by abachler
    well, the actual contest is to generate primes greater than 2^32.
    Right, I misread the rubric. Looks like you still have zero valid entries, heh.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #30
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Quote Originally Posted by laserlight View Post
    Looks like you still have zero valid entries, heh.


    Right.
    I hate real numbers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. prime number program with function
    By mackieinva in forum C Programming
    Replies: 17
    Last Post: 09-20-2007, 08:36 AM
  3. Prime Number stops after 29, but why?
    By Daveo in forum C Programming
    Replies: 22
    Last Post: 09-17-2004, 10:55 AM
  4. Replies: 3
    Last Post: 01-14-2003, 10:34 PM
  5. Random number generator
    By Caze in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2002, 08:10 AM