Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


#Actual_Flame1_

Posted 31 January 2013 - 09:02 AM

Hello. I've created my first program with opencl.

__kernel void vector_add_gpu (__global const float* a, __global const float* b, __global float* c, int iNumElements){ // get index into global data array int iGID = get_global_id(0); // bound check (equivalent to the limit on a 'for' loop for standard/serial C code if (iGID < iNumElements) { // add the vector elements c[iGID] = a[iGID] + b[iGID]; }}
I have a quite big buffer with numbers(about 240 mbyte). Opencl spends in 5 time more then a cpu loop. Is it ok or something is wrong? If i have more complicated function(c[iGID] = a[iGID] + sqrt(b[iGID] * b[iGID]);) than difference is much bigger(in 150 times) :)Thank you.

 

P.S. sorry my previous case was wrong i forget to put opencl file to the folder. :)


#1_Flame1_

Posted 31 January 2013 - 08:48 AM

Hello. I've created my first program with opencl.

 

__kernel void vector_add_gpu (__global const float* a, __global const float* b, __global float* c, int iNumElements)
{
  // get index into global data array
  int iGID = get_global_id(0);

  // bound check (equivalent to the limit on a 'for' loop for standard/serial C code
  if (iGID < iNumElements)
  { 
    // add the vector elements
	c[iGID] = a[iGID] + b[iGID];
  }
}

I have a quite big buffer with numbers(about 240 mbyte). Opencl spends almost the same time as a cpu loop. Opencl is faster but it's very little. Is it ok or something is wrong? Thank you.


PARTNERS