Skip to content

Commit

Permalink
Fixed a memory allocation bug in GPUSparseMatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaga committed Feb 29, 2016
1 parent 33c7c10 commit 81fa019
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Math/GPUSparseMatrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void GPUSparseMatrix<ElemType>::ChangeDeviceTo(DEVICEID_TYPE to_id)
}
else
{
ElemType* d_dst = TracingGPUMemoryAllocator::Allocate<ElemType>(to_id, m_totalBufferSizeAllocated / sizeof(ElemType));
ElemType* d_dst = (ElemType*)TracingGPUMemoryAllocator::Allocate<char>(to_id, m_totalBufferSizeAllocated);

// first try peer access
int canAccessPeer = false;
Expand Down Expand Up @@ -694,7 +694,7 @@ void GPUSparseMatrix<ElemType>::Reshape(const size_t numRows, const size_t numCo

size_t bufferSizeNeeded = BufferSizeNeeded(numRows, numCols, m_elemSizeAllocated, m_format);

ElemType* pArray = TracingGPUMemoryAllocator::Allocate<ElemType>(m_computeDevice, bufferSizeNeeded / sizeof(ElemType));
ElemType* pArray = (ElemType*)TracingGPUMemoryAllocator::Allocate<char>(m_computeDevice, bufferSizeNeeded);

if (m_pArray != nullptr)
{
Expand Down Expand Up @@ -762,7 +762,7 @@ void GPUSparseMatrix<ElemType>::Resize(const size_t numRows, const size_t numCol

if (reallocate)
{
ElemType* pArray = TracingGPUMemoryAllocator::Allocate<ElemType>(m_computeDevice, bufferSizeNeeded / sizeof(ElemType));
ElemType* pArray = (ElemType*)TracingGPUMemoryAllocator::Allocate<char>(m_computeDevice, bufferSizeNeeded);

if (m_pArray != nullptr)
{
Expand Down

0 comments on commit 81fa019

Please sign in to comment.