add timing statements for colamd

release/4.3a0
Yong-Dian Jian 2012-11-16 22:59:57 +00:00
parent 539f32ad66
commit e5dc2b86b2
3 changed files with 12 additions and 0 deletions

View File

@ -33,6 +33,7 @@ namespace inference {
template<typename CONSTRAINED>
Permutation::shared_ptr PermutationCOLAMD(
const VariableIndex& variableIndex, const CONSTRAINED& constrainLast, bool forceOrder) {
gttic(PermutationCOLAMD_constrained);
size_t n = variableIndex.size();
std::vector<int> cmember(n, 0);
@ -59,6 +60,7 @@ Permutation::shared_ptr PermutationCOLAMD(
template<typename CONSTRAINED_MAP>
Permutation::shared_ptr PermutationCOLAMDGrouped(
const VariableIndex& variableIndex, const CONSTRAINED_MAP& constraints) {
gttic(PermutationCOLAMD_grouped);
size_t n = variableIndex.size();
std::vector<int> cmember(n, 0);
@ -74,6 +76,7 @@ Permutation::shared_ptr PermutationCOLAMDGrouped(
/* ************************************************************************* */
inline Permutation::shared_ptr PermutationCOLAMD(const VariableIndex& variableIndex) {
gttic(PermutationCOLAMD_unconstrained);
size_t n = variableIndex.size();
std::vector<int> cmember(n, 0);
return PermutationCOLAMD_(variableIndex, cmember);

View File

@ -33,6 +33,9 @@ namespace inference {
/* ************************************************************************* */
Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, std::vector<int>& cmember) {
gttic(PermutationCOLAMD_internal);
gttic(Prepare);
size_t nEntries = variableIndex.nEntries(), nFactors = variableIndex.nFactors(), nVars = variableIndex.size();
// Convert to compressed column major format colamd wants it in (== MATLAB format!)
int Alen = ccolamd_recommended(nEntries, nFactors, nVars); /* colamd arg 3: size of the array A */
@ -69,9 +72,12 @@ Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, s
int stats[CCOLAMD_STATS]; /* colamd arg 7: colamd output statistics and error codes */
gttoc(Prepare);
// call colamd, result will be in p
/* returns (1) if successful, (0) otherwise*/
if(nVars > 0) {
gttic(ccolamd);
int rv = ccolamd(nFactors, nVars, Alen, &A[0], &p[0], knobs, stats, &cmember[0]);
if(rv != 1)
throw runtime_error((boost::format("ccolamd failed with return value %1%")%rv).str());
@ -79,6 +85,7 @@ Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, s
// ccolamd_report(stats);
gttic(Create_permutation);
// Convert elimination ordering in p to an ordering
Permutation::shared_ptr permutation(new Permutation(nVars));
for (Index j = 0; j < nVars; j++) {
@ -89,6 +96,7 @@ Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, s
if(debug) cout << "COLAMD: " << j << "->" << p[j] << endl;
}
if(debug) cout << "COLAMD: p[" << nVars << "] = " << p[nVars] << endl;
gttoc(Create_permutation);
return permutation;
}

View File

@ -34,6 +34,7 @@ Ordering::Ordering(const std::list<Key> & L):nVars_(0) {
/* ************************************************************************* */
void Ordering::permuteWithInverse(const Permutation& inversePermutation) {
gttic(Ordering_permuteWithInverse);
BOOST_FOREACH(Ordering::value_type& key_order, *this) {
key_order.second = inversePermutation[key_order.second];
}