From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13101 invoked by alias); 26 May 2014 08:22:58 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 13001 invoked by uid 55); 26 May 2014 08:22:55 -0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/49363] [feature request] multiple target attribute (and runtime dispatching based on cpuid) Date: Mon, 26 May 2014 08:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg02186.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49363 --- Comment #24 from rguenther at suse dot de --- On Mon, 26 May 2014, vincenzo.innocente at cern dot ch wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49363 > > --- Comment #23 from vincenzo Innocente --- > Which Syntax? > I want to reuse the same code for the various architecture and let gcc deal > with vectorization details. > The best I manage to do to share code is something like this > > namespace { > inline > float _sum0(float const * x, > float const * y, float const * z) { > float sum=0; > for (int i=0; i!=1024; ++i) > sum += z[i]+x[i]*y[i]; > return sum; > } > } > > > float __attribute__ ((__target__ ("arch=haswell"))) > sum1(float const * x, > float const * y, float const * z) { > return _sum0(x,y,z); > } > > float __attribute__ ((__target__ ("arch=nehalem"))) > sum1(float const * x, > float const * y, float const * z) { > return _sum0(x,y,z); > } I think that's the desired interface (it was designed with the expectation you'd use intrinsics in the special functions, not simply let the autovectorizer do its work IIRC).