CUDA tutorial: Difference between revisions

No edit summary
Line 88: Line 88:


= Few Basic CUDA Operations =
= Few Basic CUDA Operations =
== CUDA Memory Allocation
== CUDA Memory Allocation ==
* cudaMalloc((void**)&array, size)
* cudaMalloc((void**)&array, size)
** Allocates object in the device memory. Requires address of a pointer of allocated array and size.
** Allocates object in the device memory. Requires address of a pointer of allocated array and size.
Line 97: Line 97:
* cudaMemcpy(array_dest, array_orig, size, direction)
* cudaMemcpy(array_dest, array_orig, size, direction)
** Copy the data from either device to host or host to device . Requires pointers to the arrays, size and the direction type (cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, etc)
** Copy the data from either device to host or host to device . Requires pointers to the arrays, size and the direction type (cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, etc)
* cudaMemcpyAsync
** Same as cudaMemcpy, but transfers the data asynchronously which means it's not blocking execution of other processes.


= First CUDA C Program=
= First CUDA C Program=
Bureaucrats, cc_docs_admin, cc_staff
337

edits