Install parallelised MRtrix3 openmp - issues qt on mac

installation
macos

#1

Hi all,

Following the instruction on the website I manage to install MRtrix3 without problem on Mac 10.11.5.
The second challenge is to install it with the flag -openmp.

If I run the followings:

export PATH=/usr/local/Cellar/qt/5.9.1/bin/:$PATH;
export CXX=/usr/local/bin/clang-omp++;
EIGEN_CFLAGS="-isystem /usr/local/Cellar/eigen/3.2.10/include/eigen3" ARCH=native ./configure;

Everything works fine the installation does not appear to be using openmp as I am missing the flag -openmp.

When adding the flag

EIGEN_CFLAGS="-isystem /usr/local/Cellar/eigen/3.2.10/include/eigen3" ARCH=native ./configure -openmp;

I had the following error in the log:

EXEC <<
CMD: /usr/local/bin/clang-omp++ -mmacosx-version-min=10.11 -lz -L/usr/local/Cellar/libtiff/4.0.7/lib -ltiff -L/usr/local/Cellar/fftw/3.3.6-pl2/lib -lfftw3 -fopenmp qt_moc.o qt.o -o qt -stdlib=libc++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11 -Wl,-rpath,@executable_path/Frameworks -F/usr/local/Cellar/qt/5.9.1/lib -framework QtOpenGL -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework QtSvg -framework OpenGL -framework AGL
EXIT: 1
STDERR:
ld: library not found for -liomp5
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

ERROR: error linking Qt application!

See the file ‘configure.log’ for details. If this doesn’t help and you need
further assistance, please post on the MRtrix3 community forum
(http://community.mrtrix.org/), and make sure to include the full contents of
the ‘configure.log’ file.

I tried other options, such as

EIGEN_CFLAGS="-isystem /usr/local/Cellar/eigen/3.2.10/include/eigen3" QMAKE="/usr/local/Cellar/qt/5.9.1/bin/qmake QMAKE_CXXFLAGS=-fopenmp LIBS=-fopenmp" ARCH=native ./configure -openmp;

With the following unsuccessful log:

REPORT: moc (version 5.9.1)

REPORT: Checking for Qt qmake:
EXEC <<
CMD: /usr/local/Cellar/qt/5.9.1/bin/qmake QMAKE_CXXFLAGS=-fopenmp LIBS=-fopenmp -v
error invoking command “/usr/local/Cellar/qt/5.9.1/bin/qmake QMAKE_CXXFLAGS=-fopenmp LIBS=-fopenmp”: No such file or directory

ERROR: Qt qmake not found!

MRtrix3 was unable to locate the Qt command ‘qmake’.

Make sure your PATH environment variable includes the location of the correct
version of this command, for example:
$ export PATH=/opt/qt5/bin:$PATH
$./configure
(amend with the actual path to the Qt executables on your system)

When, for a test, I run this

EIGEN_CFLAGS="-isystem /usr/local/Cellar/eigen/3.2.10/include/eigen3" QMAKE=/usr/local/Cellar/qt/5.9.1/bin/qmake ARCH=native ./configure -openmp

The output I get is

MRtrix build type requested: release

Detecting OS: darwin
OS X deployment target: 10.11
Machine architecture set by ARCH environment variable to: native
Looking for compiler [/usr/local/bin/clang-omp++]: clang version 3.5.0
Checking for C++11 compliance: ok
Checking shared library generation: ok
Detecting pointer size: 64 bit
Detecting byte order: little-endian
Checking for variable-length array support: ok
Checking for non-POD variable-length array support: not found
Checking for ::max_align_t: 16 bytes
Checking for std::max_align_t: 16 bytes
Checking for Eigen3 library: 3.2.10
Checking for zlib compression library: 1.2.5
Checking for “JSON for Modern C++” requirements: ok
Checking for TIFF library: LIBTIFF, Version 4.0.7
Checking for FFTW library: fftw-3.3.6-pl2-sse2
Checking for OpenMP support: ok
Checking for Qt moc: moc (version 5.9.1)
Checking for Qt qmake: /usr/local/Cellar/qt/5.9.1/bin/qmake (version 5.9.1)
Checking for Qt rcc: rcc (version 5.9.1)
Checking for Qt:
ERROR: error linking Qt application!

See the file ‘configure.log’ for details. If this doesn’t help and you need
further assistance, please post on the MRtrix3 community forum
(http://community.mrtrix.org/), and make sure to include the full contents of
the ‘configure.log’ file.

with the following log

EXEC <<
CMD: /usr/local/bin/clang-omp++ -mmacosx-version-min=10.11 -lz -L/usr/local/Cellar/libtiff/4.0.7/lib -ltiff -L/usr/local/Cellar/fftw/3.3.6-pl2/lib -lfftw3 -fopenmp qt_moc.o qt.o -o qt -stdlib=libc++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11 -Wl,-rpath,@executable_path/Frameworks -F/usr/local/Cellar/qt/5.9.1/lib -framework QtOpenGL -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework QtSvg -framework OpenGL -framework AGL
EXIT: 1
STDERR:
ld: library not found for -liomp5
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

ERROR: error linking Qt application!

See the file ‘configure.log’ for details. If this doesn’t help and you need
further assistance, please post on the MRtrix3 community forum
(http://community.mrtrix.org/), and make sure to include the full contents of
the ‘configure.log’ file.

Therefore it seems that openmp is close by, but qt is missing the parallel flags.
So, finally the question: what am I doing wrong?
How do I pass the CXXFLAGS and LIBS when calling qmake in installing MRtrix3?

Many thanks for the help and support!


#2

Before going any further, can I point out that there is currently no application within the MRtrix3 released code that uses OpenMP - this flag is there purely to support some of our internal developments. MRtrix3 handles its own multi-threading using standard C++11 functionality.

Is there a specific reason why you want to include OpenMP support? This would only matter to you if you were interested in developing your own MRtrix3 application and required parallelised Eigen3 operations - not a common use case amongst our users…


#3

Thanks for the reply!
Initially I wanted to include OpenMP support to have results quickly, and as I saw the flag I thought I would have been possible to do it. Maybe in future versions?
Have a nice day


#4

Sorry, I probably wasn’t clear enough. OpenMP is a framework for multi-threading on a single compute node. MRtrix3 already uses the standard C++11 multi-threading API to do this - there is no actual need of OpenMP for MRtrix3 to run at full tilt. The next step would be to support full-blown MPI to distribute the load over multiple compute nodes in a cluster (which OpenMP does not support, as far as I can tell) - but that is not something we’re even considering right now.

The only reason to include support for OpenMP in MRtrix3 is to allow the Eigen3 library to internally parallelize its operations, as this is the library that the Eigen3 developers have decided to use to multi-thread their operations. This is unnecessary for 99% of operations in MRtrix3, since everything is already multi-threaded across voxels, or across streamlines, etc. Where this becomes interesting is when we need to perform one giant linear algebra operation over the full dataset, in a way that can’t be broken up into smaller independent chunks - which is precisely the use case that this option was required for. But again, I stress that this is only required for our own internal developments currently - no code in the release makes use of it…