add timing statements for colamd
parent
539f32ad66
commit
e5dc2b86b2
|
|
@ -33,6 +33,7 @@ namespace inference {
|
||||||
template<typename CONSTRAINED>
|
template<typename CONSTRAINED>
|
||||||
Permutation::shared_ptr PermutationCOLAMD(
|
Permutation::shared_ptr PermutationCOLAMD(
|
||||||
const VariableIndex& variableIndex, const CONSTRAINED& constrainLast, bool forceOrder) {
|
const VariableIndex& variableIndex, const CONSTRAINED& constrainLast, bool forceOrder) {
|
||||||
|
gttic(PermutationCOLAMD_constrained);
|
||||||
|
|
||||||
size_t n = variableIndex.size();
|
size_t n = variableIndex.size();
|
||||||
std::vector<int> cmember(n, 0);
|
std::vector<int> cmember(n, 0);
|
||||||
|
|
@ -59,6 +60,7 @@ Permutation::shared_ptr PermutationCOLAMD(
|
||||||
template<typename CONSTRAINED_MAP>
|
template<typename CONSTRAINED_MAP>
|
||||||
Permutation::shared_ptr PermutationCOLAMDGrouped(
|
Permutation::shared_ptr PermutationCOLAMDGrouped(
|
||||||
const VariableIndex& variableIndex, const CONSTRAINED_MAP& constraints) {
|
const VariableIndex& variableIndex, const CONSTRAINED_MAP& constraints) {
|
||||||
|
gttic(PermutationCOLAMD_grouped);
|
||||||
size_t n = variableIndex.size();
|
size_t n = variableIndex.size();
|
||||||
std::vector<int> cmember(n, 0);
|
std::vector<int> cmember(n, 0);
|
||||||
|
|
||||||
|
|
@ -74,6 +76,7 @@ Permutation::shared_ptr PermutationCOLAMDGrouped(
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
inline Permutation::shared_ptr PermutationCOLAMD(const VariableIndex& variableIndex) {
|
inline Permutation::shared_ptr PermutationCOLAMD(const VariableIndex& variableIndex) {
|
||||||
|
gttic(PermutationCOLAMD_unconstrained);
|
||||||
size_t n = variableIndex.size();
|
size_t n = variableIndex.size();
|
||||||
std::vector<int> cmember(n, 0);
|
std::vector<int> cmember(n, 0);
|
||||||
return PermutationCOLAMD_(variableIndex, cmember);
|
return PermutationCOLAMD_(variableIndex, cmember);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ namespace inference {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, std::vector<int>& cmember) {
|
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();
|
size_t nEntries = variableIndex.nEntries(), nFactors = variableIndex.nFactors(), nVars = variableIndex.size();
|
||||||
// Convert to compressed column major format colamd wants it in (== MATLAB format!)
|
// 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 */
|
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 */
|
int stats[CCOLAMD_STATS]; /* colamd arg 7: colamd output statistics and error codes */
|
||||||
|
|
||||||
|
gttoc(Prepare);
|
||||||
|
|
||||||
// call colamd, result will be in p
|
// call colamd, result will be in p
|
||||||
/* returns (1) if successful, (0) otherwise*/
|
/* returns (1) if successful, (0) otherwise*/
|
||||||
if(nVars > 0) {
|
if(nVars > 0) {
|
||||||
|
gttic(ccolamd);
|
||||||
int rv = ccolamd(nFactors, nVars, Alen, &A[0], &p[0], knobs, stats, &cmember[0]);
|
int rv = ccolamd(nFactors, nVars, Alen, &A[0], &p[0], knobs, stats, &cmember[0]);
|
||||||
if(rv != 1)
|
if(rv != 1)
|
||||||
throw runtime_error((boost::format("ccolamd failed with return value %1%")%rv).str());
|
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);
|
// ccolamd_report(stats);
|
||||||
|
|
||||||
|
gttic(Create_permutation);
|
||||||
// Convert elimination ordering in p to an ordering
|
// Convert elimination ordering in p to an ordering
|
||||||
Permutation::shared_ptr permutation(new Permutation(nVars));
|
Permutation::shared_ptr permutation(new Permutation(nVars));
|
||||||
for (Index j = 0; j < nVars; j++) {
|
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: " << j << "->" << p[j] << endl;
|
||||||
}
|
}
|
||||||
if(debug) cout << "COLAMD: p[" << nVars << "] = " << p[nVars] << endl;
|
if(debug) cout << "COLAMD: p[" << nVars << "] = " << p[nVars] << endl;
|
||||||
|
gttoc(Create_permutation);
|
||||||
|
|
||||||
return permutation;
|
return permutation;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ Ordering::Ordering(const std::list<Key> & L):nVars_(0) {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Ordering::permuteWithInverse(const Permutation& inversePermutation) {
|
void Ordering::permuteWithInverse(const Permutation& inversePermutation) {
|
||||||
|
gttic(Ordering_permuteWithInverse);
|
||||||
BOOST_FOREACH(Ordering::value_type& key_order, *this) {
|
BOOST_FOREACH(Ordering::value_type& key_order, *this) {
|
||||||
key_order.second = inversePermutation[key_order.second];
|
key_order.second = inversePermutation[key_order.second];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue