Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0EC05200B9C for ; Mon, 10 Oct 2016 17:46:16 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0D66D160AD1; Mon, 10 Oct 2016 15:46:16 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 01E3A160AE1 for ; Mon, 10 Oct 2016 17:46:14 +0200 (CEST) Received: (qmail 64778 invoked by uid 500); 10 Oct 2016 15:46:14 -0000 Mailing-List: contact commits-help@singa.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.incubator.apache.org Delivered-To: mailing list commits@singa.incubator.apache.org Received: (qmail 64762 invoked by uid 99); 10 Oct 2016 15:46:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Oct 2016 15:46:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B621318014A for ; Mon, 10 Oct 2016 15:46:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 7Byf4b2Ex0WF for ; Mon, 10 Oct 2016 15:46:10 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 7D76B5FB76 for ; Mon, 10 Oct 2016 15:46:08 +0000 (UTC) Received: (qmail 64323 invoked by uid 99); 10 Oct 2016 15:46:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Oct 2016 15:46:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7BD41E0556; Mon, 10 Oct 2016 15:46:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wangwei@apache.org To: commits@singa.incubator.apache.org Date: Mon, 10 Oct 2016 15:46:08 -0000 Message-Id: <46b91134b850482c96737755a43e370a@git.apache.org> In-Reply-To: <6edd322f08b84996b5ad8ed1b5471a4c@git.apache.org> References: <6edd322f08b84996b5ad8ed1b5471a4c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/8] incubator-singa git commit: SINGA-247 Add windows support for singa archived-at: Mon, 10 Oct 2016 15:46:16 -0000 SINGA-247 Add windows support for singa Add MSVC codes in cmake files. Add DISABLE_WARNINGS into configure files. Fix incompatible codes and add some definitions. Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/350bdf41 Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/350bdf41 Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/350bdf41 Branch: refs/heads/master Commit: 350bdf41487221a692b8c335b54e9034a71c1834 Parents: 8055515 Author: xiezl Authored: Mon Sep 19 01:59:44 2016 +0800 Committer: Wei Wang Committed: Mon Oct 10 17:41:28 2016 +0800 ---------------------------------------------------------------------- CMakeLists.txt | 12 ++++++++++-- cmake/Templates/singa_config.h.in | 2 ++ include/singa/core/tensor.h | 2 +- src/CMakeLists.txt | 13 ++++++++++--- src/core/device/opencl_device.cc | 3 ++- src/core/device/platform.cc | 3 +-- src/core/memory/memory.cc | 5 ++++- src/core/tensor/sparse_tensor.cc | 4 ++++ src/core/tensor/tensor.cc | 2 +- src/io/jpg_decoder.cc | 3 +-- src/io/jpg_encoder.cc | 2 +- src/io/lmdb_reader.cc | 2 +- src/io/lmdb_writer.cc | 3 ++- src/model/optimizer/local_all_reduce.cc | 4 ++++ src/utils/logging.cc | 3 ++- test/singa/test_cross_entropy.cc | 2 +- test/singa/test_mse.cc | 4 ++-- test/singa/test_timer.cc | 4 ++-- 18 files changed, 51 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index e799348..2e9f27a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,21 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(singa) SET(PACKAGE_VERSION "1.0.0") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -O2 ") +MESSAGE(STATUS "CMAKE paths: ${CMAKE_PREFIX_PATH} test ${CMAKE_SYSTEM_PREFIX_PATH}") LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Thirdparty) #message(STATUS "module path: ${CMAKE_MODULE_PATH}") # Flags IF(UNIX OR APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -O2 -fPIC -Wall") +ENDIF() +IF(WIN32) + IF (MSVC) + MESSAGE(STATUS "Using msvc compiler") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SCL_SECURE_NO_WARNINGS") + MESSAGE(STATUS "Using msvc compiler ${CMAKE_CXX_FLAGS}") + ENDIF() ENDIF() IF(CMAKE_BUILD_TYPE=Debug) SET(NVCC_FLAG "${NVCC_FLAG} -g -G ") @@ -46,6 +53,7 @@ OPTION(USE_PYTHON "Generate py wrappers" ON) OPTION(USE_JAVA "Generate java wrappers" OFF) OPTION(USE_OPENCL "Use OpenCL" OFF) OPTION(ENABLE_DIST "enable distributed training" OFF) +OPTION(DISABLE_WARNINGS "disable warnings under windows" ON) INCLUDE("cmake/Dependencies.cmake") #INCLUDE("cmake/Utils.cmake") http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/cmake/Templates/singa_config.h.in ---------------------------------------------------------------------- diff --git a/cmake/Templates/singa_config.h.in b/cmake/Templates/singa_config.h.in index f3500d0..324f7a3 100644 --- a/cmake/Templates/singa_config.h.in +++ b/cmake/Templates/singa_config.h.in @@ -40,6 +40,8 @@ #cmakedefine ENABLE_DIST +#cmakedefine DISABLE_WARNINGS + // lmdb #cmakedefine USE_LMDB http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/include/singa/core/tensor.h ---------------------------------------------------------------------- diff --git a/include/singa/core/tensor.h b/include/singa/core/tensor.h index a41afbc..00df60b 100644 --- a/include/singa/core/tensor.h +++ b/include/singa/core/tensor.h @@ -211,7 +211,7 @@ class Tensor { /// Note: block_ is allocated in lazy manner to avoid frequent malloc/free. /// If you want to get an allocated Block, use block() instead of block_. Block *block_ = nullptr; - Shape shape_ = {}; + Shape shape_;// = {}; }; typedef Shape::iterator ShapeIter; http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f70204..7b94580 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,10 @@ LIST(APPEND singa_sources ${proto_hdrs} ${proto_srcs}) AUX_SOURCE_DIRECTORY(utils utils_source) LIST(APPEND singa_sources ${utils_source}) +AUX_SOURCE_DIRECTORY(io io_source) +AUX_SOURCE_DIRECTORY(io/network io_source) +LIST(APPEND singa_sources ${io_source}) + AUX_SOURCE_DIRECTORY(core/device core_source) AUX_SOURCE_DIRECTORY(core/memory core_source) AUX_SOURCE_DIRECTORY(core/scheduler core_source) @@ -57,9 +61,6 @@ AUX_SOURCE_DIRECTORY(model/metric model_source) AUX_SOURCE_DIRECTORY(model/updater model_source) LIST(APPEND singa_sources ${model_source}) -AUX_SOURCE_DIRECTORY(io io_source) -AUX_SOURCE_DIRECTORY(io/network io_source) -LIST(APPEND singa_sources ${io_source}) ADD_CUSTOM_TARGET( copy_protobuf ALL @@ -78,6 +79,12 @@ FOREACH(fil ${proto_hdrs}) ENDFOREACH() ADD_LIBRARY(singa_objects OBJECT ${singa_sources}) +IF(WIN32) + IF (MSVC) + SET_TARGET_PROPERTIES(singa_objects + PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267 /wd4018 /wd4005 /wd4804 /wd4800") + ENDIF() +ENDIF() #ADD_DEPENDENCIES(singa_objects copy_protobuf) ADD_LIBRARY(singa SHARED $ ${cuda_objs}) http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/core/device/opencl_device.cc ---------------------------------------------------------------------- diff --git a/src/core/device/opencl_device.cc b/src/core/device/opencl_device.cc index 0c8f010..c9c2211 100644 --- a/src/core/device/opencl_device.cc +++ b/src/core/device/opencl_device.cc @@ -16,6 +16,8 @@ * limitations under the License. */ +#ifdef USE_OPENCL + #include #include #include @@ -25,7 +27,6 @@ #include "singa/utils/tinydir.h" #include "singa/utils/opencl_utils.h" -#ifdef USE_OPENCL using namespace viennacl; using namespace viennacl::backend::opencl; http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/core/device/platform.cc ---------------------------------------------------------------------- diff --git a/src/core/device/platform.cc b/src/core/device/platform.cc index a3661f2..3392492 100644 --- a/src/core/device/platform.cc +++ b/src/core/device/platform.cc @@ -15,12 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifdef USE_CUDA #include "singa/core/device.h" #include "singa/singa_config.h" -#ifdef USE_CUDA - namespace singa { int Platform::GetNumGPUs() { http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/core/memory/memory.cc ---------------------------------------------------------------------- diff --git a/src/core/memory/memory.cc b/src/core/memory/memory.cc index cb33a48..2dd1cbe 100644 --- a/src/core/memory/memory.cc +++ b/src/core/memory/memory.cc @@ -15,13 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef DISABLE_WARNINGS +#ifdef USE_CUDA #include "singa/core/memory.h" #include "singa/utils/logging.h" #include "singa/proto/core.pb.h" #include -#ifdef USE_CUDA namespace singa { std::atomic CnMemPool::pool_count(0); std::pair CnMemPool::GetMemUsage() { @@ -109,3 +110,5 @@ void CudaMemPool::Free(void *ptr) { } } #endif + +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/core/tensor/sparse_tensor.cc ---------------------------------------------------------------------- diff --git a/src/core/tensor/sparse_tensor.cc b/src/core/tensor/sparse_tensor.cc index a8ae973..46ea850 100644 --- a/src/core/tensor/sparse_tensor.cc +++ b/src/core/tensor/sparse_tensor.cc @@ -15,5 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef DISABLE_WARNINGS + #include "singa/core/tensor.h" namespace singa {} + +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/core/tensor/tensor.cc ---------------------------------------------------------------------- diff --git a/src/core/tensor/tensor.cc b/src/core/tensor/tensor.cc index d7e8f86..516a088 100644 --- a/src/core/tensor/tensor.cc +++ b/src/core/tensor/tensor.cc @@ -567,7 +567,7 @@ GenBinaryTensorFn(operator>=, GE); void fn(const Tensor &in, const SType x, Tensor *ret) { \ EltwiseTensorScalarFn(fn, in, x, ret); \ } \ - template Tensor op(const Tensor &in, const float x); \ + template Tensor op (const Tensor &in, const float x); \ template void fn(const Tensor &in, const float x, Tensor *ret) GenTensorScalarFn(operator+, Add); http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/io/jpg_decoder.cc ---------------------------------------------------------------------- diff --git a/src/io/jpg_decoder.cc b/src/io/jpg_decoder.cc index b778b98..e0d458c 100644 --- a/src/io/jpg_decoder.cc +++ b/src/io/jpg_decoder.cc @@ -15,11 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifdef USE_OPENCV #include "singa/io/decoder.h" -#ifdef USE_OPENCV - #include #include http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/io/jpg_encoder.cc ---------------------------------------------------------------------- diff --git a/src/io/jpg_encoder.cc b/src/io/jpg_encoder.cc index 8335a91..4a4ee85 100644 --- a/src/io/jpg_encoder.cc +++ b/src/io/jpg_encoder.cc @@ -15,10 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifdef USE_OPENCV #include "singa/io/encoder.h" -#ifdef USE_OPENCV #include #include http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/io/lmdb_reader.cc ---------------------------------------------------------------------- diff --git a/src/io/lmdb_reader.cc b/src/io/lmdb_reader.cc index 7f78080..8bb82c0 100644 --- a/src/io/lmdb_reader.cc +++ b/src/io/lmdb_reader.cc @@ -15,10 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifdef USE_LMDB #include "singa/io/reader.h" #include "singa/utils/logging.h" -#ifdef USE_LMDB namespace singa { namespace io { http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/io/lmdb_writer.cc ---------------------------------------------------------------------- diff --git a/src/io/lmdb_writer.cc b/src/io/lmdb_writer.cc index e89894b..3e6d5f8 100644 --- a/src/io/lmdb_writer.cc +++ b/src/io/lmdb_writer.cc @@ -16,9 +16,10 @@ * limitations under the License. */ +#ifdef USE_LMDB + #include "singa/io/writer.h" #include "singa/utils/logging.h" -#ifdef USE_LMDB namespace singa { namespace io { http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/model/optimizer/local_all_reduce.cc ---------------------------------------------------------------------- diff --git a/src/model/optimizer/local_all_reduce.cc b/src/model/optimizer/local_all_reduce.cc index ea03e39..9cda321 100644 --- a/src/model/optimizer/local_all_reduce.cc +++ b/src/model/optimizer/local_all_reduce.cc @@ -15,6 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef DISABLE_WARNINGS + #ifndef SRC_MODEL_OPTIMIZER_LOCAL_ALL_REDUCE_H_ #define SRC_MODEL_OPTIMIZER_LOCAL_ALL_REDUCE_H_ #include "singa/model/optimizer.h" @@ -23,3 +25,5 @@ namespace singa { } #endif // SRC_MODEL_OPTIMIZER_LOCAL_ALL_REDUCE_H_ + +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/src/utils/logging.cc ---------------------------------------------------------------------- diff --git a/src/utils/logging.cc b/src/utils/logging.cc index 3b0916b..50fa7dc 100644 --- a/src/utils/logging.cc +++ b/src/utils/logging.cc @@ -23,7 +23,8 @@ #include #include -#include +//#include +#include namespace singa { http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/test/singa/test_cross_entropy.cc ---------------------------------------------------------------------- diff --git a/test/singa/test_cross_entropy.cc b/test/singa/test_cross_entropy.cc index c7fa2fb..8235766 100644 --- a/test/singa/test_cross_entropy.cc +++ b/test/singa/test_cross_entropy.cc @@ -32,7 +32,7 @@ class TestSoftmaxCrossEntropy : public ::testing::Test { p.Reshape(singa::Shape{2, 4}); t.Reshape(singa::Shape{2, 1}); } - const float pdat[8] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; + const float pdat[8] = {0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f }; const int tdat[2] = {0, 2}; singa::Tensor p, t; http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/test/singa/test_mse.cc ---------------------------------------------------------------------- diff --git a/test/singa/test_mse.cc b/test/singa/test_mse.cc index a0ab1a1..9cf0e9c 100644 --- a/test/singa/test_mse.cc +++ b/test/singa/test_mse.cc @@ -33,8 +33,8 @@ class TestMSE : public ::testing::Test { p.CopyDataFromHostPtr(pdat, sizeof(pdat) / sizeof(float)); t.CopyDataFromHostPtr(tdat, sizeof(pdat) / sizeof(float)); } - const float pdat[6] = {0.1, 1.1, 2.1, 0.3, 2.2, 1.8}; - const float tdat[6] = {0.1, 1.1, 2.0, 0.3, 2.2, 1.8}; + const float pdat[6] = { 0.1f, 1.1f, 2.1f, 0.3f, 2.2f, 1.8f}; + const float tdat[6] = { 0.1f, 1.1f, 2.0f, 0.3f, 2.2f, 1.8f}; singa::Tensor p, t; }; http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/350bdf41/test/singa/test_timer.cc ---------------------------------------------------------------------- diff --git a/test/singa/test_timer.cc b/test/singa/test_timer.cc index 76d3597..735b72d 100644 --- a/test/singa/test_timer.cc +++ b/test/singa/test_timer.cc @@ -24,7 +24,7 @@ TEST(TimerTest, TestTick) { singa::Timer t; - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); int time = t.Elapsed(); - EXPECT_GE(time, 1000); + EXPECT_GE(time, 10); }