Results 1 to 4 of 4

Thread: Data sharing among various kernels

  1. #1
    Join Date
    May 2018
    Posts
    12
    Rep Power
    1

    Question Data sharing among various kernels

    Hello,

    I have tried working with read and write channels to pass data from one kernel to other. I wanted to know, whether a global variable can be shared by various kernels to pass the data. I have written a small program below indicating channel transfer. But is possible to transfer using shared global variables?

    #pragma OPENCL EXTENSION cl_intel_channels : enable

    channel float data_ch __attribute__((depth(0)));

    __kernel void Pipe_in(__global float *restrict x, __global float *restrict check) {
    // Get index of the work item


    uint count;

    for (count = 0; count<10; count++){

    write_channel_intel(data_ch, x[count]);

    check[count] = x[count];
    }

    }

    __kernel void Pipe_out(__global float *restrict y) {
    // Get index of the work item


    uint count;

    for (count = 0; count<10; count++)

    y[count] = read_channel_intel(data_ch);

    }

  2. #2
    Join Date
    Jan 2017
    Posts
    692
    Rep Power
    1

    Default Re: Data sharing among various kernels

    You can share data between two kernels using global buffers; however, this is only possible if the kernels run sequentially, and one finishes before the other one starts. If the kernels are supposed to run in parallel, this is not possible since OpenCL guarantees global memory consistency only AFTER kernel execution.

  3. #3
    Join Date
    May 2018
    Posts
    12
    Rep Power
    1

    Default Re: Data sharing among various kernels

    Should the global buffer be defined as the argument in one of the kernel? Because when I define __global float share[10] in Pipe_in kernel (below program), i end up with errors.

    #pragma OPENCL EXTENSION cl_intel_channels : enable

    channel float data_ch __attribute__((depth(0)));

    __kernel void Pipe_in(__global float *restrict x, __global float *restrict check) {
    // Get index of the work item

    __global float share[10];
    uint count;

    for (count = 0; count<10; count++){

    write_channel_intel(data_ch, x[count]);

    share[count] = x[count];
    }

    }

    __kernel void Pipe_out(__global float *restrict y) {
    // Get index of the work item


    uint count;

    for (count = 0; count<10; count++)

    y[count] = share[count];

    }

  4. #4
    Join Date
    Jan 2017
    Posts
    692
    Rep Power
    1

    Default Re: Data sharing among various kernels

    That is not how you share global buffers. You cannot define global buffers inside the kernel code. They must be defined and allocated in the host code. You can just add one extra global argument to each kernel and after allocating the shared buffer in the host code, pass the pointer to the shared buffer to both kernels.

Similar Threads

  1. Replies: 3
    Last Post: December 12th, 2017, 07:14 AM
  2. Sharing setting data between parallel modules?
    By elmood in forum General Altera Discussion
    Replies: 1
    Last Post: October 15th, 2016, 08:55 AM
  3. FPGA and nios II data sharing
    By Gaz250587 in forum General Discussion Forum
    Replies: 0
    Last Post: July 27th, 2009, 07:27 AM
  4. functional unit sharing in the data path
    By AxelD in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 1
    Last Post: January 11th, 2008, 07:12 AM
  5. Sharing data and address between SDRAM and Flash
    By niosIIuser in forum General Discussion Forum
    Replies: 5
    Last Post: February 16th, 2006, 10:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

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