turicreate
turicreate copied to clipboard
Introducing OMP
following this post to let apple clang use external OpenMP libs.
In order to provide a smooth review experience, I exclude all the OpenMP source files, which are irrelevant to this review.
CompileC /Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/Objects-normal/arm64/z_Linux_asm.o src/external/openmp/openmp-src/runtime/src/z_Linux_asm.S normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/guihaoliang/Work/guicreate-1
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/opt/gnu-getopt/bin:/Users/guihaoliang/.pyenv/plugins/pyenv-virtualenv/shims:/Users/guihaoliang/.pyenv/shims:/Users/guihaoliang/.cargo/bin:/Users/guihaoliang/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/gnu-getopt/bin:/Users/guihaoliang/.pyenv/plugins/pyenv-virtualenv/shims:/Users/guihaoliang/.pyenv/shims:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/autojump:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/zsh_reload:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/command-not-found:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/gradle:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/colored-man-pages:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/fancy-ctrl-z:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/docker:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/docker-compose:/Users/guihaoliang/.antigen/bundles/rupa/z:/Users/guihaoliang/.antigen/bundles/zsh-users/zsh-autosuggestions:/Users/guihaoliang/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/Users/guihaoliang/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/osx"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch arm64 -fmessage-length=140 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCMAKE_INTDIR=\"Debug-iphoneos\" -DHAS_CORE_ML -DHAS_CORE_ML_BATCH_INFERENCE -DHAS_MPS -DHAS_MLCUSTOM_MODEL -DHAS_MACOS_10_15 -DTC_BUILD_IOS -DTC_DISABLE_REMOTEFS -DTC_BUILD_PATH_BASE=\"/Users/guihaoliang/Work/gui-1-36\" -DCURL_STATICLIB -DIN_TURI_SOURCE_TREE -DFUSION_MAX_VECTOR_SIZE=20 -DBOOST_SPIRIT_THREAD_SAFE -DBOOST_THREAD_ONCE_ATOMIC -DBOOST_FUSION_INVOKE_MAX_ARITY=12 -DBOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY=12 -DBOOST_FUSION_INVOKE_FUNCTION_OBJECT_MAX_ARITY=12 -DBOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK -DEIGEN_MPL2_ONLY -Dgoogle=_tc_google -DCOMPILER_HAS_IOS_BASE_FAILURE_WITH_ERROR_CODE -DCOMPILER_MODIFIER_ON_EXCEPTION_WHAT=noexcept -DHAVE_PTHREAD -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk -fstrict-aliasing -Wdeprecated-declarations -miphoneos-version-min=12 -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -fembed-bitcode-marker -I/Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Debug-iphoneos/include -I/Users/guihaoliang/Work/gui-1-36/src -I/Users/guihaoliang/Work/gui-1-36/src/core/system/platform -I/Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src -I/Users/guihaoliang/Work/gui-1-36/src/external/openmp/openmp-src/runtime/src -I/Users/guihaoliang/Work/gui-1-36/src/external/openmp/openmp-src/runtime/src/i18n -I/Users/guihaoliang/Work/gui-1-36/src/external/openmp/openmp-src/runtime/src/include -I/Users/guihaoliang/Work/gui-1-36/src/external/openmp/openmp-src/runtime/src/thirdparty/ittnotify -I/Users/guihaoliang/Work/gui-1-36/src/external/openmp -isystem /Users/guihaoliang/Work/gui-1-36/deps/local/include -isystem /Users/guihaoliang/Work/gui-1-36/src/external/boost/boost_1_68_0 -isystem /Users/guihaoliang/Work/gui-1-36/src/external/libpng/libpng-1.6.37 -isystem /Users/guihaoliang/Work/gui-1-36/src/external/libjpeg/jpeg-8d -isystem /Users/guihaoliang/Work/gui-1-36/src/external/bzip2 -isystem /Users/guihaoliang/Work/gui-1-36/src/external/zlib/zlib-1.2.11 -isystem /Users/guihaoliang/Work/gui-1-36/src/external/coremltools_wrap -isystem /Users/guihaoliang/Work/gui-1-36/src/external -isystem /Users/guihaoliang/Work/gui-1-36/src/external/google -isystem /Users/guihaoliang/Work/gui-1-36/src/external/nanomsg/nanomsg-1.0.0/src -isystem /Users/guihaoliang/Work/gui-1-36/debug/src -I/Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/DerivedSources-normal/arm64 -I/Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/DerivedSources/arm64 -I/Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Debug-iphoneos -target arm64-apple-darwin-eabi -fPIC -Wall -Werror -Wno-unused-command-line-argument -Wno-deprecated-declarations -Wno-implicit-function-declaration -Wno-deprecated-register -Qunused-arguments -Wno-mismatched-tags -Wno-enum-compare -Wno-conversion-null -Wno-constant-logical-operand -Wno-parentheses-equality -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-attributes -Wno-tautological-compare -fno-stack-check -fno-stack-protector -fobjc-arc -Wno-unknown-warning-option -fno-inline -fPIC -w -D _GNU_SOURCE -D _REENTRANT -x assembler-with-cpp -MMD -MT dependencies -MF /Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/Objects-normal/arm64/z_Linux_asm.d --serialize-diagnostics /Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/Objects-normal/arm64/z_Linux_asm.dia -c /Users/guihaoliang/Work/guicreate-1/src/external/openmp/openmp-src/runtime/src/z_Linux_asm.S -o /Users/guihaoliang/Work/gui-1-36/debug/src/external/openmp/openmp-src/runtime/src/Turi.build/Debug-iphoneos/omp.build/Objects-normal/arm64/z_Linux_asm.o
/Users/guihaoliang/Work/guicreate-1/src/external/openmp/openmp-src/runtime/src/z_Linux_asm.S:1546:5: error: unknown directive
.size __kmp_unnamed_critical_addr,8
^
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
still fails on ios. Disable cross compilation for ios now.
a simple program using in_parallel
1 #include <core/parallel/lambda_omp.hpp>
2 #include <sstream>
3 #include <thread>
4
5 int main() {
6
7 turi::in_parallel([](size_t id, size_t num_threads) {
8 std::stringstream ss;
9 ss << std::this_thread::get_id();
10 printf("internal thread id: %3zu, num_threads: %3zu, physical thread id: %s\n",
11 id, num_threads, ss.str().c_str());
12 });
13
14 return 0;
15 }
output is,
internal thread id: 7, num_threads: 12, physical thread id: 0x70000c83f000
internal thread id: 0, num_threads: 12, physical thread id: 0x70000e84b000
internal thread id: 3, num_threads: 12, physical thread id: 0x70000c03c000
internal thread id: 1, num_threads: 12, physical thread id: 0x700010054000
internal thread id: 11, num_threads: 12, physical thread id: 0x70000d042000
internal thread id: 9, num_threads: 12, physical thread id: 0x11882c5c0
internal thread id: 6, num_threads: 12, physical thread id: 0x70000f851000
internal thread id: 2, num_threads: 12, physical thread id: 0x700010857000
internal thread id: 8, num_threads: 12, physical thread id: 0x70000d845000
internal thread id: 10, num_threads: 12, physical thread id: 0x70000e048000
internal thread id: 4, num_threads: 12, physical thread id: 0x70000b839000
internal thread id: 5, num_threads: 12, physical thread id: 0x70000f04e000