Skip to content

Commit

Permalink
stop infinite EM loop during expectation when no kernels exist
Browse files Browse the repository at this point in the history
  • Loading branch information
cjang committed Sep 22, 2010
1 parent 193c0c1 commit 2031bfc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions benchMatmul.cpp
Expand Up @@ -536,6 +536,7 @@ int main(int argc, char *argv[])
// using EM
size_t bestGroupSize, bestBlockHeight, bestExtraParam = 0;
int bestIndex = -1;
int loopCount = 0; // stop infinite loop if there are no good kernels
vector< vector<size_t> > pargs;
bool foundMax = false;
while (! foundMax) {
Expand Down Expand Up @@ -590,6 +591,12 @@ int main(int argc, char *argv[])
// expectation lower bound could not be found for given value of extra parameter
// so try another one
bestExtraParam = (bestExtraParam + 1) % kernel.totalVariations();
// infinite loop case if there are no kernels at all
if (kernel.totalVariations() == loopCount++) {
cerr << "error: no good kernels found so giving up" << endl
<< "***DONE***" << endl;
exit(1);
}
continue;
} else {
// if this happens during maximization, then just give up
Expand All @@ -599,6 +606,8 @@ int main(int argc, char *argv[])
<< "***DONE***" << endl;
exit(1);
}
} else {
loopCount = 0;
}
kernel.setParams(pargs[bestIndex]);

Expand Down

0 comments on commit 2031bfc

Please sign in to comment.