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/removeCopyCtorFromMatrix
  • Loading branch information
amitaga committed Mar 5, 2016
2 parents 9078a9f + 003fef0 commit d86c608
Show file tree
Hide file tree
Showing 17 changed files with 488 additions and 167 deletions.
1 change: 1 addition & 0 deletions Source/Common/BestGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ BestGpu::~BestGpu()

if (m_nvmlData)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
nvmlShutdown();
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Common/CrossProcessMutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class CrossProcessMutex
void Release()
{
assert(m_handle != NULL);
// TODO: Check for error code and throw if !std::uncaught_exception()
::ReleaseMutex(m_handle);
::CloseHandle(m_handle);
m_handle = NULL;
Expand Down Expand Up @@ -180,6 +181,7 @@ class CrossProcessMutex
m_lock.l_type = F_UNLCK;
// Now removing the lock and closing the file descriptor
// waiting processes will be notified
// TODO: Check for error code and throw if !std::uncaught_exception()
fcntl(m_fd, F_SETLKW, &m_lock);
close(m_fd);
m_fd = -1;
Expand Down
11 changes: 9 additions & 2 deletions Source/Common/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,20 @@ bool File::IsTextBased()

// File Destructor
// closes the file
// Note: this does not check for errors. Use Flush() before closing a file you are writing.
// Note: this does not check for errors when the File corresponds to pipe stream. In this case, use Flush() before closing a file you are writing.
File::~File(void)
{
if (m_pcloseNeeded)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
_pclose(m_file);
}
else if (m_file != stdin && m_file != stdout && m_file != stderr)
fclose(m_file); // (since destructors may not throw, we ignore the return code here)
{
int rc = fclose(m_file);
if ((rc != 0) && !std::uncaught_exception())
RuntimeError("File: failed to close file at %S", m_filename.c_str());
}
}

void File::Flush()
Expand Down
1 change: 1 addition & 0 deletions Source/Common/Include/Basics.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ class Plugin
}
~Plugin()
{
// TODO: Check for error code and throw if !std::uncaught_exception()
if (handle != NULL)
dlclose(handle);
}
Expand Down
1 change: 1 addition & 0 deletions Source/Common/Include/MPIWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class MPIWrapper
{
fprintf(stderr, "~MPIWrapper\n");
fflush(stderr);
// TODO: Check for error code and throw if !std::uncaught_exception()
MPI_Finalize();
}

Expand Down
19 changes: 8 additions & 11 deletions Source/Common/Include/fileutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,19 +694,16 @@ class auto_file_ptr
FILE* f;
FILE* operator=(auto_file_ptr&); // can't ref-count: no assignment
auto_file_ptr(auto_file_ptr&);
// implicit close (destructor, assignment): we ignore error
void close() throw()
{
if (f)
try
{
if (f != stdin && f != stdout && f != stderr)
::fclose(f);
}
catch (...)
{
}
f = NULL;
if (f && f != stdin && f != stdout && f != stderr)
{
int rc = ::fclose(f);
if ((rc != 0) && !std::uncaught_exception())
RuntimeError("auto_file_ptr: failed to close file");

f = NULL;
}
}
#pragma warning(push)
#pragma warning(disable : 4996)
Expand Down
1 change: 1 addition & 0 deletions Source/Common/fileutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,7 @@ class auto_find_handle
}
~auto_find_handle()
{
// TODO: Check for error code and throw if !std::uncaught_exception()
if (h != INVALID_HANDLE_VALUE)
::FindClose(h);
}
Expand Down
7 changes: 7 additions & 0 deletions Source/Math/CuDnnConvolutionEngine.cu
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool CuDnnConvolutionEngineFactory<ElemType>::IsSupported(DEVICEID_TYPE deviceId

CudaTimer::~CudaTimer()
{
// TODO: Should not throw if std::uncaught_exception()
if (m_start != nullptr)
CUDA_CALL(cudaEventDestroy(reinterpret_cast<cudaEvent_t>(m_start)));
if (m_stop != nullptr)
Expand Down Expand Up @@ -99,6 +100,7 @@ public:
{
if (m_tensor != nullptr)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudnnDestroyTensorDescriptor(m_tensor);
m_tensor = nullptr;
}
Expand Down Expand Up @@ -137,6 +139,7 @@ public:
{
if (m_filter != nullptr)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudnnDestroyFilterDescriptor(m_filter);
m_filter = nullptr;
}
Expand Down Expand Up @@ -169,6 +172,7 @@ public:
{
if (m_conv != nullptr)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudnnDestroyConvolutionDescriptor(m_conv);
m_conv = nullptr;
}
Expand Down Expand Up @@ -204,6 +208,7 @@ public:
{
if (m_pool != nullptr)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudnnDestroyPoolingDescriptor(m_pool);
m_pool = nullptr;
}
Expand Down Expand Up @@ -283,6 +288,7 @@ public:
{
if (m_cudnn != nullptr)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudnnDestroy(m_cudnn);
m_cudnn = nullptr;
}
Expand Down Expand Up @@ -535,6 +541,7 @@ public:
{
if (m_cudnn != nullptr)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudnnDestroy(m_cudnn);
m_cudnn = nullptr;
}
Expand Down
1 change: 1 addition & 0 deletions Source/Math/GPUDataTransferer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ template <class ElemType>
GPUDataTransferer<ElemType>::~GPUDataTransferer()
{
// BUGBUG: we don't destroy our streams (they are static variables); we need a static destructor, I am too lazy now
// TODO: Check for error code and throw if !std::uncaught_exception()
cudaEventDestroy(m_assignCompleteEvent);
cudaEventDestroy(m_fetchCompleteEvent);
}
Expand Down
3 changes: 2 additions & 1 deletion Source/Math/MatrixQuantizerGPU.cu
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ MatrixQuantizerGPU<ElemType>::~MatrixQuantizerGPU()
}

// BUGBUG: we don't destroy our streams (they are static variables); we need a static destructor, I am too lazy now
// TODO: Check for error code and throw if !std::uncaught_exception()
cudaEventDestroy(m_assignCompleteEvent);
cudaEventDestroy(m_fetchCompleteEvent);
cudaEventDestroy(m_quantizeCompleteEvent);
Expand Down Expand Up @@ -355,8 +356,8 @@ GPUMatrixComputeStreamEvent::GPUMatrixComputeStreamEvent(int deviceId)

GPUMatrixComputeStreamEvent::~GPUMatrixComputeStreamEvent()
{
// TODO: Check for error code and throw if !std::uncaught_exception()
cudaEventDestroy(m_mainGPUComputeStreamCUDAEvent) || "cudaEventDestroy failed";
;
}

void GPUMatrixComputeStreamEvent::SynchronizeEvent()
Expand Down
1 change: 1 addition & 0 deletions Source/Readers/BinaryReader/BinaryFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ BinaryFile::~BinaryFile()
// the view
iter = ReleaseView(iter, true);
}
// TODO: Check for error code and throw if !std::uncaught_exception()
CloseHandle(m_hndMapped);

// if we are writing the file, truncate to actual size
Expand Down
1 change: 1 addition & 0 deletions Source/Readers/BinaryReader/BinaryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ BinaryReader<ElemType>::~BinaryReader()

for (size_t i = 0; i < m_fStream.size(); i++)
{
// TODO: Check for error code and throw if !std::uncaught_exception()
fclose(m_fStream[i]);
}
}
Expand Down
Loading

0 comments on commit d86c608

Please sign in to comment.