Results 1 to 1 of 1

Thread: Chapter 2, example 5: Searching for a kernel by name

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

    Chapter 2, example 5: Searching for a kernel by name

    As mentioned in previous example, the calculation in OpenCL is performed by executing functions named kernels in OpenCL.
    We also learned that kernels are collected in a program (OpenCL name for library of functions), typically stored as separate CL file.

    Before we jump on the execution of kernels, we will have a look at one useful feature - detecting kernel names in a program.
    In my older OpenCL examples, I did this by parsing CL file using ThinBASIC string functions, but there is more automatic way directly in OpenCL.

    After building the program, you can use clGetKernelInfo to retrieve various kinds of information about each kernel, including the name.
    The attached example examines this simple file:
    __kernel void add(__global float *a,
                      __global float *b,
                      __global float *c) {
       
       *c = *a + *b;
    }
    
    __kernel void sub(__global float *a,
                      __global float *b,
                      __global float *c) {
       
       *c = *a - *b;
    }
    
    __kernel void mult(__global float *a,
                       __global float *b,
                       __global float *c) {
       
       *c = *a * *b;
    }
    
    __kernel void div(__global float *a,
                      __global float *b,
                      __global float *c) {
       
       *c = *a / *b;
    }
    
    You will need the latest ThinBASIC and OpenCL headers to run it + of course modern GPU or CPU.
    Attached Images Attached Images
    Attached Files Attached Files
    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. Chapter 2, example 4: Creating a program from file
    By Petr Schreiber in forum OpenCL in Action by Matthew Scarpino
    Replies: 3
    Last Post: 02-10-2012, 02:08
  3. Chapter 2, example 2: Testing device extensions
    By Petr Schreiber in forum OpenCL in Action by Matthew Scarpino
    Replies: 3
    Last Post: 23-09-2012, 00:46
  4. OpenCL Kernel Code Decorator [Updated Sep 04 2011]
    By Petr Schreiber in forum OpenCL
    Replies: 2
    Last Post: 02-05-2010, 06:31
  5. Collaborative development of the Linux Kernel
    By Charles Pegge in forum General
    Replies: 3
    Last Post: 27-11-2009, 21:58

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
  •