From ffc9ded8503b6fa9e6c21e45c411b2925a2a083b Mon Sep 17 00:00:00 2001 From: dolphin8 Date: Thu, 6 Sep 2018 14:03:52 +0800 Subject: [PATCH] add openmp support --- CMakeLists.txt | 3 ++- src/ios_io/PaddleMobile.mm | 1 + tools/ios-cmake/ios.toolchain.cmake | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7f063e468..24b7118964 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required(VERSION 3.6) +option(USE_OPENMP "openmp support" ON) + project(paddle-mobile) option(DEBUGING "enable debug mode" OFF) -option(USE_OPENMP "openmp support" OFF) option(USE_EXCEPTION "use std exception" OFF) option(LOG_PROFILE "log profile" OFF) # select the platform to build diff --git a/src/ios_io/PaddleMobile.mm b/src/ios_io/PaddleMobile.mm index 9298e79077..5c7b801be0 100644 --- a/src/ios_io/PaddleMobile.mm +++ b/src/ios_io/PaddleMobile.mm @@ -58,6 +58,7 @@ static std::mutex shared_mutex; - (BOOL)load:(NSString *)modelPath andWeightsPath:(NSString *)weighsPath{ std::string model_path_str = std::string([modelPath UTF8String]); std::string weights_path_str = std::string([weighsPath UTF8String]); + pam_->SetThreadNum(2); if (loaded_ = pam_->Load(model_path_str, weights_path_str, true)) { return YES; } else { diff --git a/tools/ios-cmake/ios.toolchain.cmake b/tools/ios-cmake/ios.toolchain.cmake index 4db079d01d..6000f7a8e5 100644 --- a/tools/ios-cmake/ios.toolchain.cmake +++ b/tools/ios-cmake/ios.toolchain.cmake @@ -50,8 +50,13 @@ endif (CMAKE_UNAME) #include (CMakeForceCompiler) #CMAKE_C_COMPILER (/usr/bin/gcc) #CMAKE_CXX_COMPILER (/usr/bin/g++) -set(CMAKE_C_COMPILER /usr/bin/gcc) -set(CMAKE_CXX_COMPILER /usr/bin/g++) +if(USE_OPENMP) + set(CMAKE_C_COMPILER /usr/local/opt/llvm/bin/clang) + set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++) +else() + set(CMAKE_C_COMPILER /usr/bin/gcc) + set(CMAKE_CXX_COMPILER /usr/bin/g++) +endif() set(CMAKE_AR ar CACHE FILEPATH "" FORCE) # Skip the platform compiler checks for cross compiling -- GitLab