フィルターのクリア

how to create streams in CUDA?

15 ビュー (過去 30 日間)
shir rabi
shir rabi 2017 年 12 月 28 日
回答済み: Francisco Ramírez Gil 2019 年 12 月 13 日
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!

回答 (1 件)

Francisco Ramírez Gil
Francisco Ramírez Gil 2019 年 12 月 13 日
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!

カテゴリ

Help Center および File ExchangeGPU Computing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by