필터 지우기
필터 지우기

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 CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by