Parallel Computing in C when using Matlab Coder (parpool and gpuArray)
이전 댓글 표시
Hello,
In Matlab I'm able to run my code parallel either with utilizing "parpool" or "gpuArray".
Now, with the help of Matlab Coder I'm able to convert my code in C by generating a dynamic library, which I can access and run via Visual Studio.
Still, I have no clue how to run the generated code in Visual Studio parallel.
My thought was:
Using parpool and gpuArray in Matlab
-> Converting via Matlab Coder in dynamic library
-> Running in Visual Studio parallelized Code
I'm aware that Matlab is multi-processing and C is multi-threading, but I hope there is a possibility to tell Matlab during the convertation to get "multi-processing in multi-threading".
Thank you for any help in advance!
채택된 답변
추가 답변 (1개)
Joss Knight
2024년 1월 13일
1 개 추천
GPU Coder will generate CUDA code for you. It can even automatically vectorize for loops. For a multithreaded parallel for loop, you're probably better off generating code for an ordinary for loop and then annotating it for appropriate OpenMP or TBB extensions. parfor is not supported for code generation.
댓글 수: 3
Wladimir Plotnikov
2024년 1월 14일
Joss Knight
2024년 1월 15일
- GPU Coder and Parallel Computing Toolbox have different licenses. Maybe you have one and not the other. However, to generate or use GPU mex functions, GPU Coder requires a Parallel Computing Toolbox license.
- GPU Coder requires a compiler to be installed and MinGW does not work.
- The workflow is different. If you want to use Coder for desktop computation you have to first compile and then integrate a mex function into your MATLAB code. You would need to separately maintain the mex function code and the code using it.
- GPU Coder can vectorize for loops for you.
- Coder generates CUDA kernels that you can subsequently edit.
- There will be differences in performance and precise answers, since the implementations are not the same.
Wladimir Plotnikov
2024년 1월 16일
카테고리
도움말 센터 및 File Exchange에서 Get Started with GPU Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!