Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Microsoft/CNTK into amita…
Browse files Browse the repository at this point in the history
…ga/htkmlfreaderMemoryOptimizations
  • Loading branch information
amitaga committed Feb 9, 2016
2 parents 5a67cf2 + 5945c39 commit 57fd382
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions Source/Common/fileutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,20 +407,12 @@ void fprintfOrDie(FILE* f, const char* fmt, ...)
#pragma warning(pop)

// ----------------------------------------------------------------------------
// fflushOrDie(): like fflush() but terminate with err msg in case of error
// fsyncOrDie(): like fsync() but terminate with err msg in case of error
// ----------------------------------------------------------------------------

void fflushOrDie(FILE* f)
void fsyncOrDie(FILE* f)
{
int rc = fflush(f);

if (rc != 0)
{
RuntimeError("error flushing to file: %s", strerror(errno));
}

int fd = fileno(f);

if (fd == -1)
{
RuntimeError("unable to convert file handle to file descriptor: %s", strerror(errno));
Expand All @@ -433,15 +425,27 @@ void fflushOrDie(FILE* f)
RuntimeError("error syncing to file: %d", (int) ::GetLastError());
}
#else
rc = fsync(fd);

int rc = fsync(fd);
if (rc != 0)
{
RuntimeError("error syncing to file: %s", strerror(errno));
}
#endif
}

// ----------------------------------------------------------------------------
// fflushOrDie(): like fflush() but terminate with err msg in case of error
// ----------------------------------------------------------------------------

void fflushOrDie(FILE* f)
{
int rc = fflush(f);
if (rc != 0)
{
RuntimeError("error flushing to file: %s", strerror(errno));
}
}

// ----------------------------------------------------------------------------
// filesize(): determine size of the file in bytes (with open file)
// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Source/SGDLib/SGD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ void SGD<ElemType>::TrainOrAdaptModel(int startEpoch, ComputationNetworkPtr net,
// persist model and check-point info
if ((g_mpi == nullptr) || g_mpi->IsMainNode())
{
net->Save(GetModelNameForEpoch(i));
SaveCheckPointInfo(i, totalSamplesSeen, learnRatePerSample, smoothedGradients, prevCriterion, chosenMinibatchSize);
net->Save(GetModelNameForEpoch(i));
if (!m_keepCheckPointFiles)
{
// delete previous checkpoint file to save space
Expand Down

0 comments on commit 57fd382

Please sign in to comment.