필터 지우기
필터 지우기

How to compile&link mex extension with OpenMP on macOS? / MATLAB crash on call

조회 수: 13 (최근 30일)
Ingmar Rieger
Ingmar Rieger 2018년 11월 10일
답변: Siddharth Bhutiya 2018년 11월 13일
Hello,
I'm working on a MATLAB extension using some C++ code that is working with OpenMP for parallelisation for data processing. The mex file works well on Windows and Linux using OpenMP, while on macOS it works single threaded only. As llvm/clang on macOS/Xcode comes without OpenMP support, I compiled libomp myself as a static library with the code from the llvm project http://llvm.org/svn/llvm-project/openmp/trunk. Building an executable from some OpenMP test code with a command like
c++ -Xpreprocessor -fopenmp -I/path/to/omp/include -lpthread -o testcode omptest.cpp /path/to/omp/libomp.a
results in a well working executable.
In MATLAB I'm able to compile a mex extension with OpenMP with some additional parameters. However, when executed, it results in a MATLAB crash when it tries to fork the process. Here is some sample code I build to demonstrate the problem: https://bpaste.net/show/0c6f919e8662 and the crash dump: https://bpaste.net/show/97854a69a87c
The sample extension https://bpaste.net/show/0c6f919e8662 works on Linux but not on macOS. The C++ code contains the mex compiler call I used on both systems and a sample how I called the mex function in the comments. Can anyone help how to get OpenMP running in a mex extension?
Kind regards,
Ingmar

답변 (1개)

Siddharth Bhutiya
Siddharth Bhutiya 2018년 11월 13일
There are some limitations for mex files using OpenMP. Please take a look at the MATLAB Answers post below for details

카테고리

Help CenterFile Exchange에서 Execution Speed에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by