OpenMP not enabled w/ --enable-openmp, needs CFLAGS
briend opened this issue · 2 comments
Debian Stable
libmypaint current git
It felt like OpenMP wasn't really working so I tried setting CFLAGS manually before compiling libmypaint, and I noticed a BIG performance increase (with really big brushes).
export CFLAGS='-fopenmp'
Results in "-fopenmp":
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/json-c -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -D_POSIX_C_SOURCE=200809L -fopenmp -MT brushmodes.lo -MD -MP -MF $depbase.Tpo -c -o brushmodes.lo brushmodes.c &&\
Whereas without the CFLAGS:
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/json-c -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -D_POSIX_C_SOURCE=200809L -MT brushmodes.lo -MD -MP -MF $depbase.Tpo -c -o brushmodes.lo brushmodes.c &&\
This is part of my build script that I've been using for quite a while:
export CFLAGS='-fopenmp'
./autogen.sh
./configure --enable-openmp
make clean
make -j8
sudo make install
sudo ldconfig
To verify whether openMP is really working or not:
- Open MyPaint on a multi-core CPU
- Select Ramon/ Big Airbrush
- Zoom out all the way and increase the brush size to maximum
- Draw and observe CPU usage. OpenMP is noticeably faster and will consume almost all the cores. Without OpenMP only a little bit more than one core will be used, and it is much slower.
As an aside, we should consider enabling OpenMP by default once we figure this out. This is an example of how to configure OpenMP "safely" so that it even checks to make sure openMP is functional before it enables it:
https://stat.ethz.ch/pipermail/r-devel/2010-September/058488.html
Maybe @Jehan can help here? :-)
one way to achieve this is by patching Makefile.am like so
--- Makefile.am 2018-04-01 16:20:01.393459906 +0100
+++ Makefile.am.new 2018-04-01 16:18:15.593563229 +0100
@@ -80,7 +80,7 @@
## libmypaint-@LIBMYPAINT_API_PLATFORM_VERSION@ ##
-AM_CFLAGS =
+AM_CFLAGS =
LIBS =
I think the above quoted patch may be a little mangled by markdown but I hope you see what I mean.
ldd on libmypaint-2.0.so.0.0.0
linux-vdso.so.1 (0x00007fffb8353000)
libjson-c.so.2 => /usr/lib64/../lib64/libjson-c.so.2 (0x00007efc9d190000)
libgobject-2.0.so.0 => /usr/lib64/../lib64/libgobject-2.0.so.0 (0x00007efc9cf38000)
libffi.so.6 => /usr/lib64/../lib64/libffi.so.6 (0x00007efc9cd30000)
libglib-2.0.so.0 => /usr/lib64/../lib64/libglib-2.0.so.0 (0x00007efc9ca18000)
libpcre.so.1 => /usr/lib64/../lib64/libpcre.so.1 (0x00007efc9c7a0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007efc9c580000)
libm.so.6 => /lib64/libm.so.6 (0x00007efc9c270000)
libgomp.so.1 => /usr/lib64/../lib64/libgomp.so.1 (0x00007efc9c048000)
libc.so.6 => /lib64/libc.so.6 (0x00007efc9bc78000)
/lib64/ld-linux-x86-64.so.2 (0x00007efc9d5b8000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007efc9ba70000)
Closing. From my experience enabling openmp actually slows things down. It's better to just use normal compiler optimizations and autovectorization