Reputation: 751
I'm new to opencL and this question might look silly.
I have a kernel which takes two structures A and C. I want to copy contents of structure A to structure C.
Structure looks like below:
struct Block {
bool used;
int size;
intptr_t data[1];
};
__kernel void function(__global struct Block *A, __global struct Block *C) {
//Do something on A
//COPY A to C by memcpy alternative
}
Is there any function like memcpy which I can use inside kernel?. I'm using opencl in integrated GPU with zero copy.
Or Do I have to copy block by block to structure C?.
Upvotes: 2
Views: 721
Reputation: 3708
In your case you can simply assign the structures:
__kernel void function(__global struct Block *A, __global struct Block *C) {
//Do something on A
*C = *A;
}
It's same as in plain C, yet many programmers don't know they can assign structures and resort to memcpy
.
Upvotes: 1