hello.
I am confusing about memcpy.
unsigned long long int ** dev_double;
unsigned long long int * dev_single;
err = cudaMalloc(&dev_double, sizeof(unsigned long long int *) * level);
if (err != cudaSuccess) {
fprintf(stderr, "Failed to allocate double (error code %s)!\n", cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
err = cudaMalloc(&dev_single, sizeof(unsigned long long int) * size);
if (err != cudaSuccess) {
fprintf(stderr, "Failed to allocate single (error code %s)!\n", cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
for (size_t i = 0; i < level; i++) {
err = cudaMemcpy(dev_double[level], &dev_single[_size_array], sizeof(unsigned long long int *), cudaMemcpyDeviceToDevice);
if (err != cudaSuccess) {
fprintf(stderr, "Failed to memcpy dev_single to dev_double (error code %s)!\n", cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
_size_array += jump_space;
}
dev_single is a flat array and dev_double is index of parts of single pointer
I want to memcpy single pointer’s location to double pointer.
Is my code right…?
I found the double pointer manual, but most of codes use host memcpy to device.
I don’t need host memcpy, because I will memcpy other data structure which updated using double pointer.