Skip to content

Commit

Permalink
print error message when trying to run consecutive mcmc runs with beagle
Browse files Browse the repository at this point in the history
  • Loading branch information
ayresdl committed Aug 2, 2018
1 parent d3e2f23 commit 8365d76
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/mcmc-primates.nex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end;

begin mrbayes;

set usebeagle=yes;


set autoclose=yes nowarn=yes seed=1 swapseed=1;

Expand All @@ -49,5 +49,6 @@ set seed=1 swapseed=1;
[mcmc ngen=50000 nruns=1 nchains=1;]
[mcmc ngen=1 nruns=1 nchains=1;]
mcmc ngen=5000 nruns=1 nchains=1 printfreq=1000;
mcmc;

end;
26 changes: 18 additions & 8 deletions src/mbbeagle.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ int InitBeagleInstance (ModelInfo *m, int division)
double *inPartials;
BitsLong *charBits;

if (m->beagleInstance == -99) {
MrBayesPrint ("\n%s Error: Consecutive MCMC runs not currently supported with BEAGLE. Please restart MrBayes.\n\n", spacer);
exit(1);
}


if (m->useBeagle == NO)
return ERROR;

Expand Down Expand Up @@ -169,16 +175,15 @@ int InitBeagleInstance (ModelInfo *m, int division)

int createBeagleInstance(int nCijkParts, int numGammaCats, int numModelStates, int numCondLikes, int numScalers, int numChars, int numTiProbs, int numPartAmbigTips, int division)
{
int resource, beagleInstance;
int resource, resourceCount, beagleInstance;
BeagleInstanceDetails details;
long preferredFlags, requiredFlags;

resourceCount = beagleResourceCount;

preferredFlags = beagleFlags;

requiredFlags = 0L;

long benchmarkFlags = BEAGLE_BENCHFLAG_SCALING_NONE;

if (beagleScalingScheme == MB_BEAGLE_SCALE_ALWAYS) {
requiredFlags |= BEAGLE_FLAG_SCALERS_LOG; //BEAGLE_FLAG_SCALERS_RAW;
benchmarkFlags = BEAGLE_BENCHFLAG_SCALING_ALWAYS;
Expand All @@ -189,7 +194,7 @@ int createBeagleInstance(int nCijkParts, int numGammaCats, int numModelStates, i
if (beagleResourceNumber >= 0 && beagleResourceNumber != 99)
{
resource = beagleResourceNumber;
beagleResourceCount = 1;
resourceCount = 1;
}
else if (beagleResourceCount != 0)
{
Expand Down Expand Up @@ -267,7 +272,7 @@ int createBeagleInstance(int nCijkParts, int numGammaCats, int numModelStates, i
if (rBList != NULL) {
double fastestTime = rBList->list[0].benchmarkResult;
resource = rBList->list[0].number;
beagleResourceCount = 1;
resourceCount = 1;

for (int i = 1; i < rBList->length; i++) {
if (rBList->list[i].benchmarkResult < fastestTime) {
Expand All @@ -290,8 +295,8 @@ int createBeagleInstance(int nCijkParts, int numGammaCats, int numModelStates, i
numTiProbs*nCijkParts,
numGammaCats,
numScalers * nCijkParts,
(beagleResourceCount == 0 ? NULL : &resource),
(beagleResourceCount == 0 ? 0 : 1),
(resourceCount == 0 ? NULL : &resource),
(resourceCount == 0 ? 0 : 1),
preferredFlags,
requiredFlags,
&details);
Expand Down Expand Up @@ -1508,6 +1513,11 @@ int InitBeagleMultiPartitionInstance ()

m = &modelSettings[0];

if (m->beagleInstance == -99) {
MrBayesPrint ("\n%s Error: Consecutive MCMC runs not currently supported with BEAGLE. Please restart MrBayes.\n\n", spacer);
exit(1);
}

if (m->useBeagle == NO)
return ERROR;

Expand Down
6 changes: 4 additions & 2 deletions src/mcmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4644,8 +4644,10 @@ void FreeChainMemory (void)
if (m->useBeagle == NO)
continue;

if (!(m->useBeagleMultiPartitions == YES && m->divisionIndex > 0))
if (!(m->useBeagleMultiPartitions == YES && m->divisionIndex > 0)) {
beagleFinalizeInstance(m->beagleInstance);
m->beagleInstance = -99; // TODO: allow consecutive 'mcmc' runs using BEAGLE
}

SafeFree((void **)(&m->logLikelihoods));
SafeFree((void **)(&m->inRates));
Expand Down Expand Up @@ -5892,7 +5894,7 @@ int InitChainCondLikes (void)

useBeagleMultiPartitions = NO;
# if defined (BEAGLE_MULTIPART_ENABLED)
if (beagleResourceNumber != 0 && numCurrentDivisions > 1 && InitBeagleMultiPartitionInstance() != ERROR)
if (beagleResourceNumber != 0 && numCurrentDivisions > 1 && InitBeagleMultiPartitionInstance() != ERROR && m->useBeagle == YES)
useBeagleMultiPartitions = YES;
# endif

Expand Down

0 comments on commit 8365d76

Please sign in to comment.