Prime Number Generator

This is a discussion on Prime Number Generator within the Contests Board forums, part of the Community Boards category; Its __int64 and thats final. If you want to recast it inside your function go ahead, but the interface is ...

  1. #16
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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 06:41 AM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

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

  3. #18
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    gpgpu.org
    thats why.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #19
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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,189
    There is also RapidMind, which I also have installed along with CUDA.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  7. #22
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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,189
    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 09:10 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  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.
    Attached Files Attached Files
    I hate real numbers.

  11. #26
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  12. #27
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,409
    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.
    Attached Files Attached Files
    Last edited by laserlight; 11-29-2008 at 02:57 PM.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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,189
    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



    Attached Images Attached Images  
    Last edited by abachler; 11-29-2008 at 03:35 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  14. #29
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,409
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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.

Page 2 of 6 FirstFirst 123456 LastLast
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, 09:34 PM
  5. Random number generator
    By Caze in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2002, 07:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21