Да, как показывает следующая программа:
#include <stdio.h>
struct my_struct
{
int x;
};
// foo receives its argument by pointer
__device__ void foo(my_struct *a)
{
a->x = 13;
}
__global__ void kernel()
{
my_struct a;
a.x = 7;
// expect 7 in the printed output
printf("a.x before foo: %d\n", a.x);
foo(&a);
// expect 13 in the printed output
printf("a.x after foo: %d\n", a.x);
}
int main()
{
kernel<<<1,1>>>();
cudaThreadSynchronize();
return 0;
}
Результат:
$ nvcc -arch=sm_20 test.cu -run
a.x before foo: 7
a.x after foo: 13