Processing on GPU in Simulink

4 ビュー (過去 30 日間)
Bhavanithya Thiraviaraja
Bhavanithya Thiraviaraja 2018 年 4 月 23 日
コメント済み: Joss Knight 2021 年 6 月 23 日
I have a block in Simulink which does a frequency shift of a Signal. It consists of calculations involving exponential. I used the 'Math function' block. The whole Simulink model takes approximately 1042.34s. When this block is removed it takes 249.38s. So the execution time is increased so much because of this exponential block.
I am trying to find different ways to reduce the time taken because of this. I tried replacing this with a MATLAB function block using GPU Arrays like below,
function y = exponential(u)
%#codegen
y = zeros(size(u),'single');
coder.extrinsic('gpuArray');
u = gpuArray(u);
y = exp(u);
This throws a runtime error 'MATLAB expression 'exp' is not numeric.'
How to get rid of this error and use GPU in Simulink? If this is not the right way to use GPU then please give me a reference for using it right.

採用された回答

Joss Knight
Joss Knight 2018 年 4 月 28 日
gpuArray is not yet supported by GPU Coder. To see how you can use GPU Coder with Simulink, take a look at this example.
  2 件のコメント
Bhavanithya Thiraviaraja
Bhavanithya Thiraviaraja 2018 年 5 月 4 日
編集済み: Bhavanithya Thiraviaraja 2018 年 5 月 4 日
So if I understand it right, there is no way to use gpuArray in Simulink via a MATLAB function block but it can be made to run on the GPU using the GPU coder as given in the exaample
Joss Knight
Joss Knight 2018 年 5 月 10 日
That's the way I understand it, yes.

サインインしてコメントする。

その他の回答 (1 件)

Hassan Khan
Hassan Khan 2021 年 6 月 23 日
hello brother..
i have a GPU of GTX 1650 ... i want to run my simulink model on gpu but i dont know how to do this... please give me an example of simulink or give some other reference that can help me.
Thanks
  1 件のコメント
Joss Knight
Joss Knight 2021 年 6 月 23 日
Hang on, let me Google "MATLAB Simulink GPU" for you and post the first hit:

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with GPU Coder についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by