My question is regarding the effect of transferring more than one array in different async queues between host and device.
Assume we have four arrays:
double *a, *b, *c, *d;
And, each has been allocated with size of N.
a = (double*) malloc(N * sizeof(double));
b = (double*) malloc(N * sizeof(double));
c = (double*) malloc(N * sizeof(double));
d = (double*) malloc(N * sizeof(double));
Now, we can transfer them between device and host as following in one clause:
#pragma acc enter data copyin(a[0:N], b[0:N], c[0:N], d[0:N]) async
#pragma acc wait
Or, we can use many async clauses and transfer them on different queues:
#pragma acc enter data copyin(a[0:N]) async(1)
#pragma acc enter data copyin(b[0:N]) async(2)
#pragma acc enter data copyin(c[0:N]) async(3)
#pragma acc enter data copyin(d[0:N]) async(4)
#pragma acc wait
The outcome of both of above approaches is the same. However, performance-wise, the second one seems to be better in some cases.
I did some measurements and found that for copyouting and updating host seems that using more than one queue is better than one in terms of performance.
Let's call the first approach one, and the second approach more, and following approach more_nonumber (notice no number for async clause):
#pragma acc enter data copyin(a[0:N]) async
#pragma acc enter data copyin(b[0:N]) async
#pragma acc enter data copyin(c[0:N]) async
#pragma acc enter data copyin(d[0:N]) async
#pragma acc wait
Then, here is the measurements for 10,000 iterations (excluding 100 first and 100 last ones, leading to average of 9,800 iterations in between):
one
CopyIn: 64.273us
Update device: 60.928us
Update self: 69.502us
CopyOut: 70.929us
more
CopyIn: 65.944us
Update device: 62.271us
Update self: 60.592us
CopyOut: 59.565us
more_nonumber
CopyIn: 66.018us
Update device: 62.735us
Update self: 70.862us
CopyOut: 72.317us
Average of 9800 runs!
An speedup of 19% is observed for copyout (70.929/59.565) when using more method compared to one, or 14% for update self (69.502/60.592).
My question: Are these numbers legitimate? Can we rely on these numbers?
For your convenience, I have put my code on the github. You can take a look at it.