Results 1 to 5 of 5

Thread: Chapter 2, example 1: Testing platform extensions

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735

    Chapter 2, example 1: Testing platform extensions

    The first strange new word from OpenCL world is "platform".

    Platform is set of OpenCL runtimes provided by each hardware vendor.

    For example, on my PC I have installed NVIDIA GeForce card and Intel Core 2 Duo CPU. Both NVIDIA and Intel support OpenCL, so after installing drivers for GPU and SDK for CPU I have two platforms on my PC.

    When doing calculation, you are free to choose which platform to use for your computations. The first step is to get to know, what is installed, and that is what the following example gives you info about.

    OpenCL has strictly defined functionality, but each hardware vendor can provide extensions to it. The example lists names of extensions as well, what they are good for you don't need to worry as of now, we will look into that later.

    Comparing to the book original, I added platform name retrieving routines to the example, to make it more clear "what is what"

    So what I learn?
    How to enumerate OpenCL platforms on your PC.

    So what I need to run it?
    You will need the latest ThinBASIC and OpenCL headers to run it + of course modern GPU or CPU.

    Code listing (full code in attachement!)
    ' -- NOTE: Enhanced to list the info for all installed platforms, which have name info added
    
    Uses "Console"
    
    #INCLUDE "%APP_INCLUDEPATH%/cl/cl.tBasicU"
    
    Function TBMain()
    
       /* Host data structures */  
       tcl_platform_id platforms() 
       tcl_uint num_platforms
       tcl_int i, ErrCL, platform_index = -1
       
       /* Extension data */
       String ext_data                            
       tSize ext_size
       String icd_ext = "cl_khr_icd"
    
       /* Find number of platforms */
       ErrCL = clGetPlatformIDs(1, ByVal NULL, num_platforms)
       If (ErrCL < 0) Then        
          pError("Couldn't find any platforms.")            
          APP_SetReturnCode(1) : WaitKey : Exit Function
       End If
      
       /* Access all installed platforms */
       ReDim platforms(num_platforms)
       clGetPlatformIDs(num_platforms, platforms, ByVal NULL)        
       
       /* Platform name */
       Dim szName As Asciiz * 512
       
       /* Find extensions of all platforms */
       For i = 1 To num_platforms 
       
          clGetPlatformInfo(platforms(i),             
             CL_PLATFORM_NAME, 512, ByVal VarPtr(szName), ByVal NULL)   
          PrintL "Platform #"+Format$(i) + ": " + szName
       
          /* Find size of extension data */
          ErrCL = clGetPlatformInfo(platforms(i),             
             CL_PLATFORM_EXTENSIONS, 0, ByVal NULL, ext_size)
          If (ErrCL < 0) Then
             pError("Couldn't read extension data.")        
             ''APP_SetReturnCode(1) : WaitKey : Exit Function
          Else                            
    
            /* Access extension data */   
            ext_data = Repeat$(ext_size, $NUL)
            clGetPlatformInfo(platforms(i), CL_PLATFORM_EXTENSIONS,     
                  ext_size, ByVal StrPtr(ext_data), ByVal NULL)                
            PrintL StrFormat$("Supported extensions: {1}", $CRLF+Replace$(ext_data, " ", $CRLF))
                           
            ext_data = ""
         End If   
       Next
                      
       PrintL 
       PrintL "Press any key to continue..."   
       WaitKey
       APP_SetReturnCode(0)                            
       
    End Function
    
    Function pError( sError As String )
    
      Console_SetTextAttribute(%CONSOLE_FOREGROUND_RED | %CONSOLE_FOREGROUND_INTENSITY)
      PrintL sError
      Console_SetTextAttribute(%CONSOLE_FOREGROUND_RED | %CONSOLE_FOREGROUND_GREEN | %CONSOLE_FOREGROUND_BLUE)
      
    End Function
    
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Petr Schreiber; 19-09-2012 at 08:49.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    404
    Thanks for program 2 Petr. As you know, in my notebook I have nVidia optimus. That is both an nVidia video card and intel video card. Optimus switches automatically when higher video power is needed. The CPU is Intel Core i7-2670QM.
    I expected to see something like your results but this is all I got.
    Attached Images Attached Images

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    Hi Kent,

    I think it is correct - that is what you get by default. To make Intel CPU operable, you need to install Intel OpenCL SDK (32 bit version) from here: http://software.intel.com/en-us/vcso...ols/opencl-sdk


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    404
    Thanks Petr, never thought about needing special drivers.

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    Yes, it is a bit strange Can you see the Intel platform now?


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. Chapter 1: Creating and distributing a matrix-vector multiplication kernel
    By Petr Schreiber in forum OpenCL in Action by Matthew Scarpino
    Replies: 7
    Last Post: 11-09-2013, 11:30
  2. Do you know: file extensions (thinBasic)
    By ErosOlmi in forum Do you know ...
    Replies: 1
    Last Post: 28-04-2011, 11:21
  3. OpenGL extensions macros
    By José Roca in forum Power Basic
    Replies: 1
    Last Post: 21-09-2008, 19:42
  4. openGL extensions
    By kryton9 in forum TBGL General
    Replies: 9
    Last Post: 07-06-2007, 01:20
  5. Top Down Platform Shooter Example
    By ErosOlmi in forum Game sources
    Replies: 0
    Last Post: 11-02-2007, 12:26

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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