Skip to content
Snippets Groups Projects
Commit 9bcc79dc authored by Marco van Oort's avatar Marco van Oort
Browse files

Only apply upper bound algorithm when it is applicable

parent f7fc55be
No related branches found
No related tags found
No related merge requests found
#include "DistributeMat.h"
#include "Permute.h"
#include "FreeNonzeros.h"
#include "SplitMatrixUpperBound.h"
#ifdef USE_PATOH
#include <patoh.h>
......@@ -684,20 +682,31 @@ int DistributeMatrixMondriaan(struct sparsematrix *pT, int P, double eps, const
#endif
if(pOptions->CheckUpperBound == CheckUpperBoundYes) {
/* Compute volume. It should be at most (min(m,n)+1)(P-1) */
long ComVol1, ComVol2, tmp;
CalcCom(pT, NULL, (pT->m < pT->n)?ROW:COL, &ComVol1, &tmp, &tmp, &tmp, &tmp);
CalcCom(pT, NULL, (pT->m < pT->n)?COL:ROW, &ComVol2, &tmp, &tmp, &tmp, &tmp);
long upperBound = (((pT->m < pT->n)?pT->m:pT->n)+1)*(P-1);
/* Check whether we can apply the upper bound algorithm */
int isSymmetric = ((pT->MMTypeCode[3]=='S' || pT->MMTypeCode[3]=='K' || pT->MMTypeCode[3]=='H') &&
pOptions->SymmetricMatrix_UseSingleEntry == SingleEntYes);
int hasDummies = (pT->NrDummies > 0);
int isColWeighted = (pT->MMTypeCode[0] == 'W' && pT->NrColWeights > 0);
if(ComVol1+ComVol2 > upperBound) {
/* To support OrderPermutation, new code should be written to recompute the permutation from scratch */
int orderPermute = (pOptions->OrderPermutation != OrderNone);
if(!isSymmetric && !hasDummies && !isColWeighted && !orderPermute) {
/* Compute volume. It should be at most (min(m,n)+1)(P-1) */
long ComVol1, ComVol2, tmp;
CalcCom(pT, NULL, (pT->m < pT->n)?ROW:COL, &ComVol1, &tmp, &tmp, &tmp, &tmp);
CalcCom(pT, NULL, (pT->m < pT->n)?COL:ROW, &ComVol2, &tmp, &tmp, &tmp, &tmp);
long upperBound = (((pT->m < pT->n)?pT->m:pT->n)+1)*(P-1);
if(ComVol1+ComVol2 > upperBound) {
#ifdef INFO
printf("Info: Achieved volume %ld is larger than upper bound %ld. Attempting to generate upper bound solution.\n", ComVol1+ComVol2, upperBound);
printf("Info: Achieved volume %ld is larger than upper bound %ld. Attempting to generate upper bound solution.\n", ComVol1+ComVol2, upperBound);
#endif
if (!SplitMatrixUpperBound(pT, P, pOptions)) {
fprintf(stderr, "DistributeMatrixMondriaan(): Unable to compute upper bound solution!\n");
if (!SplitMatrixUpperBound(pT, P, pOptions)) {
fprintf(stderr, "DistributeMatrixMondriaan(): Unable to compute upper bound solution!\n");
}
k = P;
}
k = P;
}
}
......
......@@ -8,6 +8,8 @@
#include "SparseMatrix.h"
#include "Remembrance.h"
#include "ZeroVolumeSearch.h"
#include "FreeNonzeros.h"
#include "SplitMatrixUpperBound.h"
/* Function declarations for DistributeMat.c */
long ComputeWeight(const struct sparsematrix *pT, long lo, long hi, long *wnz, const struct opts *pOptions);
......
......@@ -414,6 +414,10 @@ int SplitMatrixUpperBound(struct sparsematrix *pT, int P, const struct opts *pOp
}
#endif
/* Compute new lambdas */
InitNprocs(pT, COL, pT->RowLambda);
InitNprocs(pT, ROW, pT->ColLambda);
return TRUE;
} /* end SplitMatrixUpperBound */
......
#ifndef __SplitMatrixUpperBound_h__
#define __SplitMatrixUpperBound_h__
#include "Heap.h"
#include "DistributeVecLib.h"
int SplitMatrixUpperBound(struct sparsematrix *pT, int P, const struct opts *pOptions);
int CheckUpperBoundSolution(struct sparsematrix *pT);
#endif /* __SplitMatrixUpperBound_h__ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment