Dynamic input to the gpu cuda kernel generated from gpu coder application

Hi all
Is it possible to change the parameter in the gpu cuda kernal generated from the gpu coder matlab application during execution?
I need to chaange the input parameter for the calcualtion during the run time with the same code.
If yes, can you elloborate on the steps to give dynamic input control to the kernel function.
is command line argument for controlling some parameters in ELF is possible?
Thanks in advance

4 comentarios

Hi Gayathri,
It sounds like you are interested in passing inputs to CUDA kernels in the generated code at runtime. Would this be the same as passing new inputs to the main (entry-point) function that you are generating CUDA code for?
Can you share an example of what you would like to change, perhaps with a code snippet?
Thanks,
Jack
Hi Jack
I have attached the part of matlab funtion to explain in detail.
  1. The follwing code contains two operations. CLAHE and color conversion. It was like enabling two different operation in the input video stream. So, i need one varible to enable clahe alone, color conversion alone and both can be enabled at the same time. In normal QT application this was controlled by button click operation. So if i didnt enable the clahe the output stream should be original image or bnb enabled image.
  2. The parameter in the adapthist 'clip limit' and 'tile size' change during the run time.
% Main loop
for k = 1:10000
% Capture the image from the camera on hardware.
img = snapshot(camObj);
%img = imcrop(img,[0 0 400 400]);
img = imcrop(img,[0 0 400 400]);
////////// Need to select CLAHE MODE ///////////////////
% Convert rgb to lab
lab = rgb2lab(img);
L = lab(:,:,1);
L = L/100;
CLAHE = adapthisteq(L,'NumTiles',[8 8],'ClipLimit',0.001);
lab(:,:,1) = CLAHE*100;
rgb_result = lab2rgb(lab);
rgb_result = uint8(rgb_result*255); ///out_img is rgb_result
/////// need to select the color conversion mode /////////
g = zeros(400,400,3);
%g = zeros(720,1280,3);
g(:,:,1) = 0.05 * rgb_result(:,:,1);
g(:,:,2) = rgb_result(:,:,2);
g(:,:,3) = rgb_result(:,:,3);
HSV = rgb2hsv(g);
HSV(:,:,1) = mod(HSV(:,:,1)-0.33,1);
g3 = hsv2rgb(HSV);
g3(:,:,1) = 0.85*g3(:,:,1);
g3(:,:,3) = g3(:,:,2);1 ////out_img is g3
end
Thanks in advance
Hi Gayathri,
Apologies for the delayed response. Thank you for additional details.
GPU Coder has sevaral examples demostrating how to use various features of the the tool. Here is the link https://www.mathworks.com/help/gpucoder/getting-started-with-gpu-coder.html
It looks like you are looking for ways to pass input to your function. There is nothing specific needs to be done for GPU Coder. One can achieve this by defining a MATLAB function and passing necessary input as arguments, and then generating code for the function. Please take a look at this example for more details.
hi Ram
Thanks for the response.
So during code generation step it is possible to give input argument. In executable file, it is not possible to change its input parameters.
My requirement is to change the input parameter durign the run time.
This is my understanding from the document i referred for the gpu coder.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Get Started with GPU Coder en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Preguntada:

el 24 de Ag. de 2022

Comentada:

el 7 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by