Results 1 to 7 of 7

Thread: OpenCL on a cpu

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    7

    OpenCL on a cpu

    I have a fairly simple sample which works perfect on my NVIDIA 8800 GT, however I am kind of wondering why the following piece of code only allows me pick one platform (the NV8800 GT)

    Code :
    cl_int status = CL_SUCCESS;
    cl_uint numPlatforms;
    status |= clGetPlatformIDs (0, NULL, &numPlatforms);

    I have an Intel QuadCore2 (Q6600); Isnt there some way where I can get my code to run on the CPU ?

  2. #2
    Senior Member
    Join Date
    Nov 2009
    Posts
    118

    Re: OpenCL on a cpu

    What is your operating system?

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    7

    Re: OpenCL on a cpu

    Windows Vista

  4. #4
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: OpenCL on a cpu

    The only CPU driver for OpenCL that I'm aware of on windows/linux is AMD's. Nvidia does not support CPU devices. If you want Nvidia+CPU you have to use Mac OS X or figure out how to get the platform layer working. (I'm not sure if it's working yet, so I can't advise you there.)

  5. #5
    Senior Member
    Join Date
    Nov 2009
    Posts
    118

    Re: OpenCL on a cpu

    For the moment, nVidia and AMD implementation don't "speak" together ...

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4

    Re: OpenCL on a cpu

    I do my first steps with OpenCL i translated the include files to FreeBASIC.
    Now i can run OpenCL code on a installed NVIDIA GPU (GT240)
    or i select the AMD platform and select the CPU emulation on the fly.

    First i installed my NVIDIA driver with CUDA and OpenCL support
    than i installed the AMD OpenCL runtime.

    This should work for you too.

    happy number crunching

    Joshy
    (Sorry about my bad English)

  7. #7
    Junior Member
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4

    Re: OpenCL on a cpu

    (why i can't modify my own last posting here ?)

    here are how i select NVIDIA or AMD with CPU emulation
    Code :
    ...
    if (numPlatforms > 0) then
        dim as cl_platform_id_t ptr platforms = callocate(numPlatforms*sizeof(cl_platform_id_t))
        status = clGetPlatformIDs(numPlatforms, platforms, NULL)
        if (status<>CL_SUCCESS) then
          print "Error: Getting Platform Ids. (clGetPlatformsIDs)"
          return
        end if
        dim as zstring ptr pbuff = callocate(255)
        for i as uinteger = 0  to numPlatforms-1
          status = clGetPlatformInfo(platforms[i], _
                                     CL_PLATFORM_VENDOR, _
                                     255, _
                                     pbuff, _
                                     NULL)
          if (status<>CL_SUCCESS) then
            print "Error: Getting Platform Info. (clGetPlatformInfo)"
            return
          end if
          print "platform[" & i & "] = " & *pbuff
     
          platform = platforms[i]
    #ifdef USE_ATI
          if instr(*pbuff, "Advanced Micro Devices, Inc.") then
    #else
          if instr(*pbuff, "NVIDIA") then
    #endif
            exit for
          end if 
        next
        deallocate platforms
      end if ' if (numPlatforms > 0) then
     
      ' If we could find our platform, use it. 
      ' Otherwise pass a NULL and get whatever 
      ' the implementation thinks we should be using.
      dim as cl_context_properties_t cps(2)
      cps(0) = CL_CONTEXT_PLATFORM
      cps(1) = cast(cl_context_properties_t,platform)
      cps(2) = 0
     
      dim as cl_context_properties_t ptr cprops
      if (NULL=platform) then
        cprops = NULL
      else
        cprops = @cps(0)
      end if
    #ifdef USE_ATI
      ' Create an OpenCL context with CPU emulation
      g_context = clCreateContextFromType(cprops, _
                                          CL_DEVICE_TYPE_CPU, _
                                          NULL, _
                                          NULL, _
                                          @status)
    #else
      ' Create an OpenCL context with real GPU
      g_context = clCreateContextFromType(cprops, _
                                          CL_DEVICE_TYPE_GPU, _
                                          NULL, _
                                          NULL, _
                                          @status)
    #endif
    ...
    (Sorry about my bad English)

Similar Threads

  1. Running openCL on CPU
    By yebethinks in forum OpenCL
    Replies: 1
    Last Post: 10-04-2012, 03:24 PM
  2. OpenCL on CPU
    By opencl_JEDI in forum OpenCL
    Replies: 2
    Last Post: 03-22-2010, 08:11 AM

Posting Permissions

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