Computational Speed of MLDIVIDE When Called From MEX Function
Afficher commentaires plus anciens
Has anyone ever seen significant performance reduction on
x = A \ b
when A is created in a mexFunction using mxCreateSparse and filling in the Ir, Jc, and Pr arrays?
The reason I ask is that I'm using mexCallMATLAB to invoke mldivide on a moderately sized system (about 416,000 unknowns, 1.63 million non-zeros) and there is about a factor of 3.5 difference in computational speed (35 seconds vs. 10 seconds) in calling mldivide from MEX rather than directly from within the MATLAB environment.
Moreover, if I replace the direct call to mldivide with a call to a simple wrapper that does
[i, j, v] = find(A);
x = sparse(i, j, v) \ b;
I recover MATLAB's "inline" 10 second run-time and produce the same numerical solution (relative difference in the order of eps). I am quite probably doing something wrong and/or unusual in my mexFunction that's causing the slowdown, but I can't think of anything obvious. I have verified that the row indices appear in sorted (ascending) order within each column.
Any hints, explanations or suggestions would be greatly appreciated.
5 commentaires
James Tursa
le 9 Juin 2015
Can you post your code, or a reduced version of your code, that does this?
Bård Skaflestad
le 9 Juin 2015
Modifié(e) : Bård Skaflestad
le 9 Juin 2015
James Tursa
le 9 Juin 2015
Modifié(e) : James Tursa
le 28 Jan 2024
I was asking for the code that built the sparse matrix. But if that is proprietary then nevermind. I will make some tests tomorrow to see if there is a big difference on my versions. What version of MATLAB are you running?
You might try running SPOK on it to see if there is anything amiss:
*** EDIT ***
spok has been removed from the FEX. You can use my replacement function sarek instead:
Bård Skaflestad
le 9 Juin 2015
Bård Skaflestad
le 9 Juin 2015
Réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!