Fixing compilation of CPUMatrix on Windows: heap overflow fixed

This commit is contained in:
Eldar Akchurin 2017-04-18 18:39:58 +02:00
Родитель aa47f38f6c
Коммит ed2f97311c
6 изменённых файлов: 55 добавлений и 27 удалений

Просмотреть файл

@ -360,7 +360,8 @@ MATH_SRC =\
$(SOURCEDIR)/Math/BatchNormalizationEngine.cpp \
$(SOURCEDIR)/Math/BlockHandlerSSE.cpp \
$(SOURCEDIR)/Math/CUDAPageLockedMemAllocator.cpp \
$(SOURCEDIR)/Math/CPUMatrix.cpp \
$(SOURCEDIR)/Math/CPUMatrixFloat.cpp \
$(SOURCEDIR)/Math/CPUMatrixDouble.cpp \
$(SOURCEDIR)/Math/CPURNGHandle.cpp \
$(SOURCEDIR)/Math/CPUSparseMatrix.cpp \
$(SOURCEDIR)/Math/ConvolutionEngine.cpp \

Просмотреть файл

@ -0,0 +1,12 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
#include "stdafx.h"
#include "CPUMatrixImpl.h"
namespace Microsoft { namespace MSR { namespace CNTK {
// explicit instantiations, due to CPUMatrix being too big and causing VS2015 cl crash.
template class MATH_API CPUMatrix<double>;
}}}

Просмотреть файл

@ -0,0 +1,24 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
#include "stdafx.h"
#include "CPUMatrixImpl.h"
namespace Microsoft { namespace MSR { namespace CNTK {
int MATH_API TracingGPUMemoryAllocator::m_traceLevel = 0;
void TracingGPUMemoryAllocator::SetTraceLevel(int traceLevel)
{
m_traceLevel = traceLevel;
}
bool TracingGPUMemoryAllocator::IsTraceEnabled()
{
return (m_traceLevel > 0);
}
// explicit instantiations, due to CPUMatrix being too big and causing VS2015 cl crash.
template class MATH_API CPUMatrix<float>;
}}}

Просмотреть файл

@ -2,10 +2,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
// CPUMatrix.cpp : full implementation of all matrix functions on the CPU side
// CPUMatrix.h : template implementation of all matrix functions on the CPU side
//
#include "stdafx.h"
#pragma once
#include "Basics.h"
#include "File.h"
@ -66,18 +67,6 @@
#define IDX2C(i, j, ld) (((j) * (ld)) + (i)) // 0 based indexing
namespace Microsoft { namespace MSR { namespace CNTK {
int MATH_API TracingGPUMemoryAllocator::m_traceLevel = 0;
void TracingGPUMemoryAllocator::SetTraceLevel(int traceLevel)
{
m_traceLevel = traceLevel;
}
bool TracingGPUMemoryAllocator::IsTraceEnabled()
{
return (m_traceLevel > 0);
}
#pragma region Helpful Enum Definitions
enum class MatrixOrder
{
@ -5923,7 +5912,7 @@ CPUMatrix<ElemType>& CPUMatrix<ElemType>::AssignElementProductOfWithShift(const
#pragma endregion Static BLAS Functions
// 'double' version of LogAdd
double LogAddD(double x, double y)
inline double LogAddD(double x, double y)
{
return LogAdd(x, y);
}
@ -7184,12 +7173,6 @@ void CPUMatrix<ElemType>::TensorArgOp(const CPUMatrix<ElemType>& a, ElementWiseO
}
}
// =======================================================================
// explicit instantiations
// =======================================================================
template class MATH_API CPUMatrix<float>;
template class MATH_API CPUMatrix<double>;
// We use Matrix<char> as the backing store for QuantizedMatrix
// Let's explicitly instantiate the methods we need for that purpose
template CPUMatrix<char>::CPUMatrix(const size_t numRows, const size_t numCols);

Просмотреть файл

@ -194,12 +194,15 @@
<ClInclude Include="QuantizedMatrix.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="CPUMatrixImpl.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="BatchNormalizationEngine.cpp" />
<ClCompile Include="BlockHandlerAVX.cpp" />
<ClCompile Include="BlockHandlerSSE.cpp" />
<ClCompile Include="ConvolutionEngine.cpp" />
<ClCompile Include="CPUMatrixDouble.cpp" />
<ClCompile Include="CPUMatrixFloat.cpp" />
<ClCompile Include="CPURNGHandle.cpp" />
<ClCompile Include="CPUSparseMatrix.cpp" />
<ClCompile Include="CUDAPageLockedMemAllocator.cpp" />
@ -209,7 +212,6 @@
<PrecompiledHeader>
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="CPUMatrix.cpp" />
<ClCompile Include="MatrixQuantizerCPU.cpp" />
<ClCompile Include="MatrixQuantizerImpl.cpp" />
<ClCompile Include="NoGPU.cpp" />
@ -231,4 +233,4 @@
<Error Condition="'$(MathLibrary)' == 'MKL' And !Exists('$(CNTKCustomMKLPath)')" Text="CNTK custom MKL version $(CNTKCustomMKLVersion) not found. See https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Windows#mkl for instructions." />
<Error Condition="!$(HasBoost)" Text="The Boost library is required to build. Please see https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Windows#boost for installation instructions." />
</Target>
</Project>
</Project>

Просмотреть файл

@ -2,9 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Matrix.cpp" />
<ClCompile Include="CPUMatrix.cpp">
<Filter>CPU</Filter>
</ClCompile>
<ClCompile Include="CPUSparseMatrix.cpp">
<Filter>CPU</Filter>
</ClCompile>
@ -49,6 +46,12 @@
<Filter>CPU</Filter>
</ClCompile>
<ClCompile Include="DataTransferer.cpp" />
<ClCompile Include="CPUMatrixDouble.cpp">
<Filter>CPU</Filter>
</ClCompile>
<ClCompile Include="CPUMatrixFloat.cpp">
<Filter>CPU</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CommonMatrix.h" />
@ -131,6 +134,9 @@
<ClInclude Include="QuantizedOperations.h" />
<ClInclude Include="BlockMultiplierMatrixUtil.h" />
<ClInclude Include="DataTransferer.h" />
<ClInclude Include="CPUMatrixImpl.h">
<Filter>CPU</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="GPUMatrix.h">