Results 1 to 2 of 2

Thread: help with work-group

  1. #1
    Junior Member
    Join Date
    Apr 2010

    help with work-group

    hi, I'm working on a neural networking program using OpenCl.
    I'm really new to OpenCl and couldn't understand its concepts and usage of work-groups.
    this is some sample code :
    Code :
    __kernel void calcu_h(__global float* sum_h, __global float* w_hi, __global int* unit_i, __global float* unit_h)
       int i,h,p;
        for(p=0; p<26;p++){
        			sum_h[(p*100)+h]+=w_hi[(h*100)+i]* (float)unit_i[(p*100)+i];
        		unit_h[(p*100)+h] = 1.0/(1.0+(float)exp(-(float)(sum_h[(p*100)+h])));
    as you can see that I'm using too many loops.
    Can anybody tell me how to fix these loops to work-groups or work-item ?

  2. #2
    Junior Member
    Join Date
    Jun 2010

    Re: help with work-group

    Data parallelism, SPMD - you definitelly should google for those.

    Just quick hint:

    1.Sequential code:
    Code :
    float * in = new float(100);
    float * out = new float(100);
    for(int i=0; i<100; ++i)
        out[i] = doSomething(in[i]);

    2.Parallel code:
    Code :
    _kernel (__global float* g_in, __global float* g_out)
        int i = get_local_id(0);
        g_out[i] = doSomethin(g_in[i]);
    // assuming single 1D work-group of 100 work-items

Similar Threads

  1. Work Group and Work Item sizes
    By howard in forum OpenCL
    Replies: 1
    Last Post: 03-08-2013, 10:08 PM
  2. Replies: 5
    Last Post: 03-16-2011, 11:33 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
Proudly hosted by Digital Ocean