From 85e212fececafdfd0a79102e5faff44f3719a619 Mon Sep 17 00:00:00 2001 From: raver119 Date: Thu, 11 Jul 2019 18:28:19 +0300 Subject: [PATCH] exclude memory tracker for android/ios/macos platforms (#8005) Signed-off-by: raver119 --- libnd4j/blas/CMakeLists.txt | 15 ++++++++++++++ libnd4j/buildnativeoperations.sh | 20 +++++++++---------- libnd4j/include/memory/impl/MemoryTracker.cpp | 8 ++++---- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/libnd4j/blas/CMakeLists.txt b/libnd4j/blas/CMakeLists.txt index 79cb7721c..71470ed09 100755 --- a/libnd4j/blas/CMakeLists.txt +++ b/libnd4j/blas/CMakeLists.txt @@ -29,6 +29,21 @@ if(APPLE) link_directories(/lib) endif() +if (APPLE_BUILD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DAPPLE_BUILD=true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAPPLE_BUILD=true") +endif() + +if (ANDROID_BUILD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID_BUILD=true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DANDROID_BUILD=true") +endif() + +if (IOS_BUILD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIOS_BUILD=true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIOS_BUILD=true") +endif() + if(WIN32) get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") diff --git a/libnd4j/buildnativeoperations.sh b/libnd4j/buildnativeoperations.sh index 39976d197..d6c855957 100755 --- a/libnd4j/buildnativeoperations.sh +++ b/libnd4j/buildnativeoperations.sh @@ -183,7 +183,7 @@ case "$OS" in export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/" export ANDROID_LLVM="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/" export ANDROID_ROOT="$ANDROID_NDK/platforms/android-14/arch-arm/" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm.cmake" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm.cmake -DANDROID_BUILD=true" ;; android-arm64) @@ -194,7 +194,7 @@ case "$OS" in export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/" export ANDROID_LLVM="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/" export ANDROID_ROOT="$ANDROID_NDK/platforms/android-21/arch-arm64/" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm64.cmake" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm64.cmake -DANDROID_BUILD=true" ;; android-x86) @@ -205,7 +205,7 @@ case "$OS" in export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/" export ANDROID_LLVM="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/" export ANDROID_ROOT="$ANDROID_NDK/platforms/android-14/arch-x86/" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-x86.cmake" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-x86.cmake -DANDROID_BUILD=true" ;; android-x86_64) @@ -216,7 +216,7 @@ case "$OS" in export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/" export ANDROID_LLVM="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/" export ANDROID_ROOT="$ANDROID_NDK/platforms/android-21/arch-x86_64/" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-x86_64.cmake" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-x86_64.cmake -DANDROID_BUILD=true" ;; ios-x86_64) @@ -229,7 +229,7 @@ case "$OS" in fi XCODE_PATH="$(xcode-select --print-path)" export IOS_SDK="$XCODE_PATH/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$IOS_VERSION.sdk" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-x86_64.cmake --debug-trycompile" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-x86_64.cmake --debug-trycompile -DIOS_BUILD=true" ;; ios-x86) @@ -242,7 +242,7 @@ case "$OS" in fi XCODE_PATH="$(xcode-select --print-path)" export IOS_SDK="$XCODE_PATH/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$IOS_VERSION.sdk" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-x86.cmake --debug-trycompile" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-x86.cmake --debug-trycompile -DIOS_BUILD=true" ;; ios-arm64) @@ -255,7 +255,7 @@ case "$OS" in fi XCODE_PATH="$(xcode-select --print-path)" export IOS_SDK="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$IOS_VERSION.sdk" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-arm64.cmake --debug-trycompile" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-arm64.cmake --debug-trycompile -DIOS_BUILD=true" ;; ios-arm) @@ -268,7 +268,7 @@ case "$OS" in fi XCODE_PATH="$(xcode-select --print-path)" export IOS_SDK="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$IOS_VERSION.sdk" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-arm.cmake --debug-trycompile" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-arm.cmake --debug-trycompile -DIOS_BUILD=true" ;; ios-armv7) @@ -278,7 +278,7 @@ case "$OS" in LIBTYPE="static" ARCH="armv7" export IOS_SDK="/Applications/Xcode.app/Contents/Developer/Platforms/${iPhoneOS}.platform/Developer/SDKs/${iPhoneOS}${IOS_VERSION}.sdk" - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-armv7.cmake --debug-trycompile" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/ios-armv7.cmake --debug-trycompile -DIOS_BUILD=true" ;; linux*) @@ -295,7 +295,7 @@ case "$OS" in export CXX="$(ls -1 /usr/local/bin/g++-? | head -n 1)" PARALLEL="true" fi - export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_MACOSX_RPATH=ON" + export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_MACOSX_RPATH=ON -DAPPLE_BUILD=true" ;; windows*) diff --git a/libnd4j/include/memory/impl/MemoryTracker.cpp b/libnd4j/include/memory/impl/MemoryTracker.cpp index 90e99f540..53a64f14d 100644 --- a/libnd4j/include/memory/impl/MemoryTracker.cpp +++ b/libnd4j/include/memory/impl/MemoryTracker.cpp @@ -25,7 +25,7 @@ #include -#if defined(__GNUC__) && !defined(__MINGW64__) +#if defined(__GNUC__) && !defined(__MINGW64__) && !defined(ANDROID_BUILD) && !defined(IOS_BUILD) && !defined(APPLE_BUILD) #include #include @@ -47,7 +47,7 @@ namespace nd4j { return _INSTANCE; } -#if defined(__GNUC__) && !defined(__MINGW64__) +#if defined(__GNUC__) && !defined(__MINGW64__) && !defined(ANDROID_BUILD) && !defined(IOS_BUILD) && !defined(APPLE_BUILD) std::string demangle(char *message) { char *mangled_name = 0, *offset_begin = 0, *offset_end = 0; @@ -95,7 +95,7 @@ namespace nd4j { #endif void MemoryTracker::countIn(MemoryType type, Nd4jPointer ptr, Nd4jLong numBytes) { -#if defined(__GNUC__) && !defined(__MINGW64__) +#if defined(__GNUC__) && !defined(__MINGW64__) && !defined(ANDROID_BUILD) && !defined(IOS_BUILD) && !defined(APPLE_BUILD) if (Environment::getInstance()->isDetectingLeaks()) { auto lptr = reinterpret_cast(ptr); @@ -129,7 +129,7 @@ namespace nd4j { } void MemoryTracker::countOut(Nd4jPointer ptr) { -#if defined(__GNUC__) && !defined(__MINGW64__) +#if defined(__GNUC__) && !defined(__MINGW64__) && !defined(ANDROID_BUILD) && !defined(IOS_BUILD) && !defined(APPLE_BUILD) if (Environment::getInstance()->isDetectingLeaks()) { auto lptr = reinterpret_cast(ptr);