MATLAB Answers

0

Parallel Computation of Covariance and C Code Generation

Asked by Manjinder Benning on 16 Jan 2013
Latest activity Edited by Ryan Livingston on 25 Oct 2018
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 Comments

Sign in to comment.

1 Answer

回答者: 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 Comments

Sign in to comment.