1 |
Thought: I like it :) |
2 |
|
3 |
On 7/6/06, Diego 'Flameeyes' Pettenò <flameeyes@g.o> wrote: |
4 |
> So, I've been drafting this up in my blog[1], and it is a simple way to |
5 |
> replace the CPU feature useflags. Let's try to summarise: |
6 |
> |
7 |
> Right now we have mmx, 3dnow, 3dnowex, sse, sse2 and so on useflags present in |
8 |
> the tree, almost never used to get new dependencies, but usually used to |
9 |
> supply econf switches. |
10 |
> |
11 |
> This works as long as the user enable the flags, but for AMD64 the story was, |
12 |
> until now, that we simply enabled them when they worked, because we had some |
13 |
> minimum support available. Unfortunately this became a problem with the |
14 |
> introduction of nocona, because that is an amd64-like system but with no |
15 |
> 3dnow. And there is the problem that sse3 is supported only in later versions |
16 |
> of Athlon64 and so on. |
17 |
> |
18 |
> To try to clean up this mess, and to make it simpler to work in |
19 |
> cross-compilation, I thought of using the definitions created by the C |
20 |
> Preprocessor (CPP) by default for the given CFLAGS. Basically when |
21 |
> using -march=athlon64, the preprocessor will enable a few definitions that |
22 |
> tells the availability of MMX, 3dNOW, SSE and so on... if we wrap that |
23 |
> around, we can use it to know if it's the case of enabling something or not. |
24 |
> This is customisable by the user by setting the CFLAGS themselves. If one does |
25 |
> not want MMX instructions to be generated, but still want the rest of |
26 |
> Athlon64 optimisations, it's simply the matter of |
27 |
> using "-march=athlon64 -mno-mmx". |
28 |
> |
29 |
> So, rather than the functions proposed in [1], I've sampled today the |
30 |
> following function: |
31 |
> |
32 |
> has_cpuset() { |
33 |
> local def hasfeat |
34 |
> |
35 |
> while [[ -n $1 ]]; do |
36 |
> case $1 in |
37 |
> mmx) |
38 |
> def="__MMX__" ;; |
39 |
> 3dnow) |
40 |
> def="__3dNOW__" ;; |
41 |
> 3dnowex) |
42 |
> def="__3dNOW_A__" ;; |
43 |
> sse) |
44 |
> def="__SSE__" ;; |
45 |
> sse2) |
46 |
> def="__SSE2__" ;; |
47 |
> sse3) |
48 |
> def="__SSE3__" ;; |
49 |
> altivec) |
50 |
> def="__ALTIVEC__" ;; |
51 |
> *) |
52 |
> ewarn "Instruction set $1 not supported." |
53 |
> die "Instruction set not supported." |
54 |
> esac |
55 |
> |
56 |
> echo | $(tc-getCC) ${CFLAGS} -dM -E - 2>/dev/null | grep -q ${def} || |
57 |
> hasfeat="no" |
58 |
> shift |
59 |
> done |
60 |
> |
61 |
> if [[ ${hasfeat} == "no" ]]; then |
62 |
> return 1 |
63 |
> else |
64 |
> return 0 |
65 |
> fi |
66 |
> } |
67 |
> |
68 |
> that can be tested easily with the following code: |
69 |
> |
70 |
> yesno() { |
71 |
> if "$@"; then |
72 |
> echo "yes" |
73 |
> else |
74 |
> echo "no" |
75 |
> fi |
76 |
> } |
77 |
> |
78 |
> echo "Does it have 3dnow mmx sse2?" |
79 |
> yesno has_cpuset 3dnow mmx sse2 |
80 |
> echo "Does it have mmx sse sse3?" |
81 |
> yesno has_cpuset mmx sse sse3 |
82 |
> echo "Does it have altivec?" |
83 |
> yesno has_cpuset altivec |
84 |
> |
85 |
> |
86 |
> Note that you need to set your CFLAGS corretly or it will, by default, tell |
87 |
> you that everything is disabled. |
88 |
> |
89 |
> Thoughts? Comments? |
90 |
> |
91 |
> SPARC team: I'd like to know if VIS does a similar thing, would make simpler |
92 |
> for instance its handling in xine-lib ebuild. |
93 |
> |
94 |
> [1] |
95 |
> http://farragut.flameeyes.is-a-geek.org/articles/2006/06/24/crazy-idea-an-alternative-to-cpu-features-useflags |
96 |
> -- |
97 |
> Diego "Flameeyes" Pettenò - http://farragut.flameeyes.is-a-geek.org/ |
98 |
> Gentoo/Alt lead, Gentoo/FreeBSD, Video, AMD64, Sound, PAM, KDE |
99 |
> |
100 |
> |
101 |
> |
102 |
|
103 |
|
104 |
-- |
105 |
Ioannis Aslanidis |
106 |
|
107 |
<deathwing00[at]gentoo.org> 0xB9B11F4E |
108 |
|
109 |
-- |
110 |
gentoo-dev@g.o mailing list |