# Regarding the kernel function

• 01-27-2013, 10:59 PM
shahsaurabh1990
Regarding the kernel function
In my kernel function i have given arguments as three vectors A,B and C respectively.
A and B are input vector ; C is the output vector
kernel function is as follows
{
int i=get_global_id(0);
int j;
for(j=0;j<6;j++)
{
B[j]=B[j]+1;
}
}

there was no change in the B vector

but when i wrote C[j] in place of B[j] inside the for loop, i got the changes in C vector
C[j]=C[j]+1;
Can anyone explain why??
• 01-28-2013, 05:11 AM
clint3112
Re: Regarding the kernel function
how do you define your buffer B and C? is buffer B defined as read only and C as write only? or is B defined as
Quote:

__global const float* B
• 01-28-2013, 05:33 AM
shahsaurabh1990
Re: Regarding the kernel function
i have written a kernel for union function between 2 vectors

kernel(a,b,c,k)
{
int i=get_global_id(0);
int j;
int v;
v=0;
for(j=0;j<k;j++)
{
if(A[i] == B[j])
{
v=1;
}
}
if(v==0)
C[i]=A[i];
}
before the kernel function i initialized the values of vector C with 99999
and i have two vectors A and B which have some common values =, but still the values of vector C remain the same.
Can you tell why??
• 01-28-2013, 08:26 AM
clint3112
Re: Regarding the kernel function
how are a,b and c defined?
Quote:

__kernel foo(__global const a, __global const b, __global const c, int k)
or
Quote:

__kernel foo(__global const a, __global const b, __global c, int k)
and is c defined as a read/write buffer on host side??
• 01-29-2013, 02:51 AM
shahsaurabh1990
Re: Regarding the kernel function
Now the code is running; it was not accessing the GPU through a virtual instance therefore i ran the code on the machine where the Gpu card was installed, now it is running correctly