Parallel Computation of Covariance and C Code Generation
1 次查看(过去 30 天)
显示 更早的评论
Hi i am trying to parallelize the computation of a large covariance matrix and then use CODER to generate C output ready to compile and deploy on a multi-core system.
Parfor wont work unless i break out the COV function into 3 for loops. So pain in the ass.
Can i somehow use the matlab COV function and then use CODER to create C code ready for Multi-core optimizations?
Or can i somehow convert matlab large inline matrix multiplication code to parallel C code using a multi-core lib like BLAS or OpenMP?
0 个评论
回答(1 个)
Ryan Livingston
2013-1-16
编辑:Ryan Livingston
2018-10-25
Update Starting in R2018b you can generate code that calls a CBLAS as well as an LAPACK library:
My answer here:
has more details.
Original Response
If you post a little of the troublesome PARFOR code the community may be able to give you some tips on it to simplify the implementation.
Using MATLAB Coder to generate code for the COV function will generally generate serial code. However, Coder does support replacing matrix operations with BLAS calls so large matrix calculations can be replaced by calls to the BLAS.
In a MEX build you can use the 'EnableBlas' property of a MEX configuration object described here:
and here
Note that the replacement occurs for matrices over a certain threshold to mitigate the overhead of calling the BLAS.
For generating standalone libraries or executables code replacement may be used to replace matrix operations with the BLAS. Doing so is described here:
under the heading "BLAS Support". This demo uses the BLAS shipped with MATLAB but the CRL approach allows you to swap in your desired BLAS implementation as well.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Execution Speed 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!