From owner-freebsd-ports@freebsd.org Wed Dec 27 20:01:07 2017 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FBABEA9F83 for ; Wed, 27 Dec 2017 20:01:07 +0000 (UTC) (envelope-from jbeich@freebsd.org) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 2DF397574A for ; Wed, 27 Dec 2017 20:01:07 +0000 (UTC) (envelope-from jbeich@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 2A78BEA9F82; Wed, 27 Dec 2017 20:01:07 +0000 (UTC) Delivered-To: ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A1D8EA9F81 for ; Wed, 27 Dec 2017 20:01:07 +0000 (UTC) (envelope-from jbeich@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0CD8275749 for ; Wed, 27 Dec 2017 20:01:07 +0000 (UTC) (envelope-from jbeich@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1354) id 56F991A20A; Wed, 27 Dec 2017 20:01:06 +0000 (UTC) From: Jan Beich Cc: ports@freebsd.org Subject: Re: Should building for different SIMD levels be supported using flavors? 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> Date: Wed, 27 Dec 2017 21:01:00 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Dec 2017 20:01:07 -0000 (Resent to ports@ because, apparently, I wasn't subscribed to the list anymore) Yuri 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