how to create streams in CUDA?

13 visualizaciones (últimos 30 días)
shir rabi
shir rabi el 28 de Dic. de 2017
Respondida: Francisco Ramírez Gil el 13 de Dic. de 2019
hello, so I'm using CUDA for a project. my code is simple- many blocks that have the same amount of threads each and calculate the same equation. I want to create a few streams of blocks, each stream runs a few blocks. how can I create streams in Matlab? in all the examples I see people use C. from what I read I concluded that the streams should be created outside my kernel. I'll note that my kernel is written in C, and the rest of my code in Matlab. thank you!

Respuestas (1)

Francisco Ramírez Gil
Francisco Ramírez Gil el 13 de Dic. de 2019
Hi, I have the same question.
I know that running a mex-function it is possible to setup the kernel launch using a code similar to the following:
cudaStream_t stream; // CUDA streams are of type `cudaStream_t`.
cudaStreamCreate(&stream); // Note that a pointer must be passed to `cudaCreateStream`.
someKernel<<<number_of_blocks, threads_per_block, 0, stream>>>(); // `stream` is passed as 4th EC argument.
cudaStreamDestroy(stream); // Note that a value, not a pointer, is passed to `cudaDestroyStream`.
However, is there any way to create a non-default CUDA stream while constructing the CUDAKernel Objec? For instance, is there a command in which the "stream" can be specified? e.g.
k = parallel.gpu.CUDAKernel('myfun.ptx','myfun.cu','stream');
Or maybe during CUDAKernel Object Properties? e.g.
k.ThreadBlockSize = [1024,1,1];
k.GridSize = [500,1,1];
k.Stream = 'stream1'
If someone knows something... Please, help me!

Categorías

Más información sobre GPU Computing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by