Skip to content

Commit

Permalink
Added CUDA memory allocation/free tracing facility to GPUMatrx and GP…
Browse files Browse the repository at this point in the history
…USparseMatrix
  • Loading branch information
amitaga committed Jan 20, 2016
1 parent 01bdefe commit cf14913
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 113 deletions.
5 changes: 5 additions & 0 deletions Source/CNTK/CNTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "SynchronousExecutionEngine.h"
#include "ModelEditLanguage.h"
#include "CPUMatrix.h" // used for SetNumThreads()
#include "GPUMatrix.h"
#include "SGD.h"
#include "MPIWrapper.h"
#include "Config.h"
Expand Down Expand Up @@ -473,6 +474,8 @@ int wmainWithBS(int argc, wchar_t* argv[]) // called from wmain which is a wrapp

g_shareNodeValueMatrices = config(L"shareNodeValueMatrices", false);

SetTraceGPUMemoryAllocations(config(L"traceGPUMemoryAllocations", false));

// logging
wstring logpath = config(L"stderr", L"");
if (logpath != L"")
Expand Down Expand Up @@ -560,6 +563,8 @@ int wmainOldCNTKConfig(int argc, wchar_t* argv[]) // called from wmain which is

g_shareNodeValueMatrices = config(L"shareNodeValueMatrices", false);

SetTraceGPUMemoryAllocations(config(L"traceGPUMemoryAllocations", false));

if (logpath != L"")
{
for (int i = 0; i < command.size(); i++)
Expand Down
9 changes: 9 additions & 0 deletions Source/Math/CommonMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ MATH_API DEVICEID_TYPE EnforceOneGPUOnly(DEVICEID_TYPE requestedDeviceId);

namespace Microsoft { namespace MSR { namespace CNTK {

template<typename AllocatedElemType>
AllocatedElemType* AllocateDeviceMemory(int deviceId, size_t numRows, size_t numCols);

template<typename AllocatedElemType>
AllocatedElemType* AllocateDeviceMemory(int deviceId, size_t numElements, bool disableTrace = false);

template<typename AllocatedElemType>
void FreeDeviceMemory(int deviceId, AllocatedElemType* bufferPtr);

// -----------------------------------------------------------------------
// ElementWiseOperator -- This enum represents which function to apply.
// This is shared between all matrix types and tensors.
Expand Down
Loading

0 comments on commit cf14913

Please sign in to comment.