From de111a1c267c3c385ad1ec794f120edbaa6b5828 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Wed, 27 Aug 2014 21:01:39 -0700 Subject: [PATCH] make windows version in 2010 --- src/io/simple_fmatrix-inl.hpp | 2 +- src/learner/evaluation-inl.hpp | 2 +- windows/README.md | 2 +- windows/xgboost.sln | 41 ++++----- windows/xgboost/xgboost.vcxproj | 18 ++-- .../xgboost_wrapper/xgboost_wrapper.vcxproj | 92 ++++++------------- wrapper/xgboost_wrapper.cpp | 18 ++-- 7 files changed, 69 insertions(+), 106 deletions(-) diff --git a/src/io/simple_fmatrix-inl.hpp b/src/io/simple_fmatrix-inl.hpp index 5bbde0740..86763a105 100644 --- a/src/io/simple_fmatrix-inl.hpp +++ b/src/io/simple_fmatrix-inl.hpp @@ -211,7 +211,7 @@ class FMatrixS : public IFMatrix{ for (size_t i = 0; i < col_data_.size(); ++i) { const bst_uint ridx = col_index_[i]; col_data_[i] = SparseBatch::Inst(&data[0] + ptr[ridx], - ptr[ridx+1] - ptr[ridx]); + static_cast(ptr[ridx+1] - ptr[ridx])); } batch_.col_index = &col_index_[0]; batch_.col_data = &col_data_[0]; diff --git a/src/learner/evaluation-inl.hpp b/src/learner/evaluation-inl.hpp index 3e05880ec..3058cf06b 100644 --- a/src/learner/evaluation-inl.hpp +++ b/src/learner/evaluation-inl.hpp @@ -133,7 +133,7 @@ struct EvalCTest: public IEvaluator { } wsum += base_->Eval(tpred, tinfo); } - return wsum / ngroup; + return static_cast(wsum / ngroup); } private: diff --git a/windows/README.md b/windows/README.md index 33d11f0c4..d74c5bbf6 100644 --- a/windows/README.md +++ b/windows/README.md @@ -1,4 +1,4 @@ -The solution has been created with Visual Studio Express 2013. +The solution has been created with Visual Studio Express 2010. Make sure to compile the Release version, unless you need to debug the code (and in the latter case modify the path in xgboost.py from release to test). Note that you have two projects in one solution and they need to be compiled to use the standalone executable from the command line diff --git a/windows/xgboost.sln b/windows/xgboost.sln index e3ce195d3..cdfe1548e 100644 --- a/windows/xgboost.sln +++ b/windows/xgboost.sln @@ -1,11 +1,9 @@  -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xgboost", "xgboost\xgboost.vcxproj", "{1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}" +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xgboost", "xgboost\xgboost.vcxproj", "{19766C3F-7508-49D0-BAAC-0988FCC9970C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xgboost_wrapper", "xgboost_wrapper\xgboost_wrapper.vcxproj", "{2E1AF937-28BB-4832-B916-309C9A0F6C4F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xgboost_wrapper", "xgboost_wrapper\xgboost_wrapper.vcxproj", "{B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,22 +13,21 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Debug|Win32.ActiveCfg = Debug|Win32 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Debug|Win32.Build.0 = Debug|Win32 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Debug|x64.ActiveCfg = Debug|x64 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Debug|x64.Build.0 = Debug|x64 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Release|Win32.ActiveCfg = Release|Win32 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Release|Win32.Build.0 = Release|Win32 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Release|x64.ActiveCfg = Release|x64 - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C}.Release|x64.Build.0 = Release|x64 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Debug|Win32.ActiveCfg = Debug|Win32 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Debug|Win32.Build.0 = Debug|Win32 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Debug|x64.ActiveCfg = Debug|x64 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Debug|x64.Build.0 = Debug|x64 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Release|Win32.ActiveCfg = Release|Win32 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Release|Win32.Build.0 = Release|Win32 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Release|x64.ActiveCfg = Release|x64 - {2E1AF937-28BB-4832-B916-309C9A0F6C4F}.Release|x64.Build.0 = Release|x64 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Debug|Win32.ActiveCfg = Debug|Win32 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Debug|Win32.Build.0 = Debug|Win32 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Debug|x64.ActiveCfg = Release|x64 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Debug|x64.Build.0 = Release|x64 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Release|Win32.ActiveCfg = Release|Win32 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Release|Win32.Build.0 = Release|Win32 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Release|x64.ActiveCfg = Release|x64 + {19766C3F-7508-49D0-BAAC-0988FCC9970C}.Release|x64.Build.0 = Release|x64 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Debug|Win32.ActiveCfg = Debug|Win32 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Debug|Win32.Build.0 = Debug|Win32 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Debug|x64.ActiveCfg = Debug|Win32 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Release|Win32.ActiveCfg = Release|Win32 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Release|Win32.Build.0 = Release|Win32 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Release|x64.ActiveCfg = Release|x64 + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/windows/xgboost/xgboost.vcxproj b/windows/xgboost/xgboost.vcxproj index fac91075c..3d303efc4 100644 --- a/windows/xgboost/xgboost.vcxproj +++ b/windows/xgboost/xgboost.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,8 +18,14 @@ x64 + + + + + + - {1D6A56A5-5557-4D20-9D50-3DE4C30BE00C} + {19766C3F-7508-49D0-BAAC-0988FCC9970C} xgboost @@ -27,27 +33,23 @@ Application true MultiByte - v120 Application true MultiByte - v120 Application false true MultiByte - v120 Application false true MultiByte - v120 @@ -111,10 +113,6 @@ true - - - - diff --git a/windows/xgboost_wrapper/xgboost_wrapper.vcxproj b/windows/xgboost_wrapper/xgboost_wrapper.vcxproj index b167e8d7d..95a94841d 100644 --- a/windows/xgboost_wrapper/xgboost_wrapper.vcxproj +++ b/windows/xgboost_wrapper/xgboost_wrapper.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,40 +18,38 @@ x64 + + + + + + - {2E1AF937-28BB-4832-B916-309C9A0F6C4F} - v4.5 - ManagedCProj + {B0E22ADD-7849-4D3A-BDC6-0932C5F11ED5} xgboost_wrapper - DynamicLibrary + Application true - v120 - true - Unicode + MultiByte - DynamicLibrary + Application true - v120 - true - Unicode + MultiByte - DynamicLibrary + Application false - v120 - true - Unicode + true + MultiByte DynamicLibrary false - v120 - true - Unicode + true + MultiByte @@ -69,85 +67,53 @@ - - true - - - true - - - false - - - false - + Level3 Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - NotUsing true - Level3 Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - NotUsing - true true - - Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - Use + MaxSpeed + true + true + true true - + true + true Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - NotUsing + MaxSpeed + true + true true true - - + true + true - - - - - - - - - - - - - - - - - diff --git a/wrapper/xgboost_wrapper.cpp b/wrapper/xgboost_wrapper.cpp index a81d3f34c..9ae48e007 100644 --- a/wrapper/xgboost_wrapper.cpp +++ b/wrapper/xgboost_wrapper.cpp @@ -1,4 +1,6 @@ // implementations in ctypes +#define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_DEPRECATE #include #include #include @@ -25,8 +27,8 @@ class Booster: public learner::BoostLearner { } const float *Pred(const DataMatrix &dmat, int output_margin, bst_ulong *len) { this->CheckInitModel(); - this->Predict(dmat, output_margin, &this->preds_); - *len = this->preds_.size(); + this->Predict(dmat, output_margin != 0, &this->preds_); + *len = static_cast(this->preds_.size()); return &this->preds_[0]; } inline void BoostOneIter(const DataMatrix &train, @@ -54,7 +56,7 @@ class Booster: public learner::BoostLearner { for (size_t i = 0; i < model_dump.size(); ++i) { model_dump_cptr[i] = model_dump[i].c_str(); } - *len = model_dump.size(); + *len = static_cast(model_dump.size()); return &model_dump_cptr[0]; } // temporal fields @@ -74,7 +76,7 @@ using namespace xgboost::wrapper; extern "C"{ void* XGDMatrixCreateFromFile(const char *fname, int silent) { - return LoadDataMatrix(fname, silent, false); + return LoadDataMatrix(fname, silent != 0, false); } void* XGDMatrixCreateFromCSR(const bst_ulong *indptr, const unsigned *indices, @@ -166,7 +168,7 @@ extern "C"{ delete static_cast(handle); } void XGDMatrixSaveBinary(void *handle, const char *fname, int silent) { - SaveDataMatrix(*static_cast(handle), fname, silent); + SaveDataMatrix(*static_cast(handle), fname, silent != 0); } void XGDMatrixSetFloatInfo(void *handle, const char *field, const float *info, bst_ulong len) { std::vector &vec = @@ -191,17 +193,17 @@ extern "C"{ const float* XGDMatrixGetFloatInfo(const void *handle, const char *field, bst_ulong* len) { const std::vector &vec = static_cast(handle)->info.GetFloatInfo(field); - *len = vec.size(); + *len = static_cast(vec.size()); return &vec[0]; } const unsigned* XGDMatrixGetUIntInfo(const void *handle, const char *field, bst_ulong* len) { const std::vector &vec = static_cast(handle)->info.GetUIntInfo(field); - *len = vec.size(); + *len = static_cast(vec.size()); return &vec[0]; } bst_ulong XGDMatrixNumRow(const void *handle) { - return static_cast(handle)->info.num_row(); + return static_cast(static_cast(handle)->info.num_row()); } // xgboost implementation