You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say I want to add two vectors as in example two. In the example, memory space is allocated and host data is created inside the code:
float* h_a = (float*) calloc(LENGTH, sizeof(float)); // a vector
float* h_b = (float*) calloc(LENGTH, sizeof(float)); // a vector
int i = 0;
int count = LENGTH;
for(i = 0; i < count; i++){
h_a[i] = rand() / (float)RAND_MAX;
h_b[i] = rand() / (float)RAND_MAX;
}
I'm trying to pass vectors a and b from R. They are passed as arguments to the main function as: vadd(double *a, double *b, int *n) (in RI have to change mainfor some other name like vadd). I allocate memory and I dereference the arguments as:
int i = 0;
int count = LENGTH;
for(i = 0; i < count; i++){
h_a[i] = a[i];
h_b[i] = b[i];
}
This dereferencing procedure is taking too much time. Is there a way so that these pointers passed as arguments to the function are set as host data directly without the loop? Something like:
h_a = *a; h_b = *b;
The text was updated successfully, but these errors were encountered:
Say I want to add two vectors as in example two. In the example, memory space is allocated and host data is created inside the code:
I'm trying to pass vectors
a
andb
fromR
. They are passed as arguments to themain
function as:vadd(double *a, double *b, int *n)
(inR
I have to changemain
for some other name likevadd
). I allocate memory and I dereference the arguments as:This dereferencing procedure is taking too much time. Is there a way so that these pointers passed as arguments to the function are set as host data directly without the loop? Something like:
h_a = *a; h_b = *b;
The text was updated successfully, but these errors were encountered: