public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/47895] New: usage of __attribute__ ((__target__ ("xyz"))) with buitins @ 2011-02-25 14:00 vincenzo.innocente at cern dot ch 2011-02-25 15:40 ` [Bug middle-end/47895] " rguenth at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: vincenzo.innocente at cern dot ch @ 2011-02-25 14:00 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47895 Summary: usage of __attribute__ ((__target__ ("xyz"))) with buitins Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: vincenzo.innocente@cern.ch I would like to generate code for multiple targets from the same source when using builtins ( I think that this issue has been discussed before for instance in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39840 ) I have code as in the example below that compiles only with -mavx. In such a case it will use AVX instruction for all functions including the one "targetted" for sse3 while I would like to obtain an object file that I can run on multiple platform. This problem occurs only when builtins are used: standard c code is correctly emitted accordingly to the target provided that the minimal -m is used. Is there any preprocessor flag to "activate" all intrinsics and builtins in x86intrin.h? ----------------------------- example #include <x86intrin.h> float __attribute__ ((__target__ ("sse3"))) sum3(float const * __restrict__ x, float const * __restrict__ y, float const * __restrict__ z) { __m128 sum = _mm_setzero_ps(); for (int i=0; i!=1024; i+=4) sum += _mm_add_ps(_mm_loadu_ps(z+i), _mm_mul_ps(_mm_loadu_ps(x+i),_mm_loadu_ps(y+i)) ); sum = _mm_hadd_ps(sum,sum); sum = _mm_hadd_ps(sum,sum); float ret; _mm_store_ss(&ret,sum); return ret; } float __attribute__ ((__target__ ("avx"))) sumv(float const * __restrict__ x, float const * __restrict__ y, float const * __restrict__ z) { __m256 sum = _mm256_setzero_ps(); for (int i=0; i!=1024; i+=8) sum += _mm256_add_ps(_mm256_loadu_ps(z+i), _mm256_mul_ps(_mm256_loadu_ps(x+i),_mm256_loadu_ps(y+i)) ); sum = _mm256_hadd_ps(sum,sum); sum = _mm256_hadd_ps(sum,sum); sum = _mm256_hadd_ps(sum,sum); float ret[8]; _mm256_store_ps(ret,sum); return ret[0]; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/47895] usage of __attribute__ ((__target__ ("xyz"))) with buitins 2011-02-25 14:00 [Bug middle-end/47895] New: usage of __attribute__ ((__target__ ("xyz"))) with buitins vincenzo.innocente at cern dot ch @ 2011-02-25 15:40 ` rguenth at gcc dot gnu.org 2011-02-26 11:09 ` vincenzo.innocente at cern dot ch ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2011-02-25 15:40 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47895 --- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-25 14:44:27 UTC --- A way easier and more portable way is to split your source into multiple compilation units and use appropriate flags to compile them. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/47895] usage of __attribute__ ((__target__ ("xyz"))) with buitins 2011-02-25 14:00 [Bug middle-end/47895] New: usage of __attribute__ ((__target__ ("xyz"))) with buitins vincenzo.innocente at cern dot ch 2011-02-25 15:40 ` [Bug middle-end/47895] " rguenth at gcc dot gnu.org @ 2011-02-26 11:09 ` vincenzo.innocente at cern dot ch 2021-08-05 22:12 ` pinskia at gcc dot gnu.org 2021-08-05 22:19 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: vincenzo.innocente at cern dot ch @ 2011-02-26 11:09 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47895 --- Comment #2 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-02-26 09:55:03 UTC --- I find that the solution with multiple files shifts the problem to the build system, which is not necessarily an easier solution in all projects, and make maintenance more difficult as more files need to be tracked for each single algorithm. I would much prefer a solution that is fully confined to the source code without involving the configuration and build system. In any case at the moment there is a clear unbalance between plane c code, for which a single compilation unit with multiple functions for different "targets" do work, and code exploiting builtins for which __attribute__ ((__target__ ("xyz"))) is not ineffective. I consider this behavior a defect. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/47895] usage of __attribute__ ((__target__ ("xyz"))) with buitins 2011-02-25 14:00 [Bug middle-end/47895] New: usage of __attribute__ ((__target__ ("xyz"))) with buitins vincenzo.innocente at cern dot ch 2011-02-25 15:40 ` [Bug middle-end/47895] " rguenth at gcc dot gnu.org 2011-02-26 11:09 ` vincenzo.innocente at cern dot ch @ 2021-08-05 22:12 ` pinskia at gcc dot gnu.org 2021-08-05 22:19 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-08-05 22:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47895 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Target| |x86_64 Resolution|--- |FIXED Target Milestone|--- |4.9.0 Known to work| |4.9.0, 5.1.0 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This has been fixed since GCC 4.9.0. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/47895] usage of __attribute__ ((__target__ ("xyz"))) with buitins 2011-02-25 14:00 [Bug middle-end/47895] New: usage of __attribute__ ((__target__ ("xyz"))) with buitins vincenzo.innocente at cern dot ch ` (2 preceding siblings ...) 2021-08-05 22:12 ` pinskia at gcc dot gnu.org @ 2021-08-05 22:19 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-08-05 22:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47895 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This was fixed by r0-124016. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-05 22:19 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-02-25 14:00 [Bug middle-end/47895] New: usage of __attribute__ ((__target__ ("xyz"))) with buitins vincenzo.innocente at cern dot ch 2011-02-25 15:40 ` [Bug middle-end/47895] " rguenth at gcc dot gnu.org 2011-02-26 11:09 ` vincenzo.innocente at cern dot ch 2021-08-05 22:12 ` pinskia at gcc dot gnu.org 2021-08-05 22:19 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).