Date: Wed, 27 Dec 2017 21:01:00 +0100 From: Jan Beich <jbeich@FreeBSD.org> Cc: ports@freebsd.org Subject: Re: Should building for different SIMD levels be supported using flavors? Message-ID: <fu7w-c54z-wny@FreeBSD.org> In-Reply-To: <61cfc2b2-d121-64ad-ad80-c81ff08916f6@rawbw.com> (yuri@rawbw.com's message of "Wed, 27 Dec 2017 10:12:15 -0800") References: <61cfc2b2-d121-64ad-ad80-c81ff08916f6@rawbw.com>
next in thread | previous in thread | raw e-mail | index | archive | help
(Resent to ports@ because, apparently, I wasn't subscribed to the list anymore) Yuri <yuri@rawbw.com> writes: > Some projects rely on SIMD to perform computations. Sometimes, > utilizing specific SIMD instructions can result in 10 times better > performance, so it is important for the ports system to properly > support SIMD. There are some projects that do automatic run-time SIMD > detection, like Embree, but there are many that do not. "10x times better performance" usually requires more than just passing -msse* or -march=native without underlying code doing anything to take advantage of it. Do you expect auto-vectorization to be that good? Projects that use SSE 4.1 or AVX without runtime detections are rare because they'd risk to shun away users if binaries are prebuilt on modern hardware. > I proposed the solution for this using flavors, see the proposed port > science/g2o: https://reviews.freebsd.org/D13610 What in there actually requires -msse*? I can't find any __SSE*__ blocks or #include <*intrin.h> while CMakeLists.txt tries to mimic -march=native by parsing /proc/cpuinfo then passing -msse* individually. Looks like a regular violation of https://www.freebsd.org/doc/en/books/porters-handbook/dads-cflags.html > It maps SIMD levels into port flavors. So that g2o-sse42 is for SSE42, > and g2o-nosimd is not using SIMD. This won't work for ports with consumers until pkg supports a way to swap dependencies e.g., g2o -> g2o-sse41, ffmpeg -> libav. On Linux systems this is usually handled by update-alternatives(8). > Later, the user will to install the flavor corresponding to his > machine's SIMD support. > > Further, ports framework and tools (pkg) should automatically detect > machine's SIMD, and install the ports with the correct SIMD flavor for > it. ABI string is probably where SIMD should be advertised but pkg repo format, currently, isn't even flexible for ports marked as NO_ARCH. > How can FreeBSD support SSE then? For one, Linux i686 assumes SSE2. To mimic on FreeBSD i386 try adding the following to make.conf(5) CPUTYPE?= pentium4 then in the port use MACHINE_CPU, port options or both e.g., OPTIONS_DEFINE= SSE2 SSE41 AVX AVX2 OPTIONS_DEFAULT= ${MACHINE_CPU:tu} SSE2_CONFIGURE_ENABLE= sse2 ... AVX2_CONFIGURE_ENABLE= avx2
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?fu7w-c54z-wny>