Mercurial > audlegacy-plugins
annotate src/madplug/SFMT-alti.h @ 2284:d19b53359b24
cleaned up the sndfile wav plugin, currently limiting it ONLY TO WAV
PLAYBACK. if somebody is more experienced with it and wants to restore
the other formats, go ahead (maybe change the name of the plugin too?).
author | mf0102 <0102@gmx.at> |
---|---|
date | Wed, 09 Jan 2008 15:41:22 +0100 |
parents | b8dd67ad7b86 |
children |
rev | line source |
---|---|
922
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
1 /** |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
2 * @file SFMT-alti.h |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
3 * |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
4 * @brief SIMD oriented Fast Mersenne Twister(SFMT) |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
5 * pseudorandom number generator |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
6 * |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
7 * @author Mutsuo Saito (Hiroshima University) |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
8 * @author Makoto Matsumoto (Hiroshima University) |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
9 * |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
10 * Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
11 * University. All rights reserved. |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
12 * |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
13 * The new BSD License is applied to this software. |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
14 * see LICENSE.txt |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
15 */ |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
16 |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
17 #ifndef SFMT_ALTI_H |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
18 #define SFMT_ALTI_H |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
19 |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
20 inline static vector unsigned int vec_recursion(vector unsigned int a, |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
21 vector unsigned int b, |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
22 vector unsigned int c, |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
23 vector unsigned int d) |
1386
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
24 ALWAYSINLINE; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
25 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
26 /** |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
27 * This function represents the recursion formula in AltiVec and BIG ENDIAN. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
28 * @param a a 128-bit part of the interal state array |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
29 * @param b a 128-bit part of the interal state array |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
30 * @param c a 128-bit part of the interal state array |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
31 * @param d a 128-bit part of the interal state array |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
32 * @return output |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
33 */ |
922
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
34 inline static vector unsigned int vec_recursion(vector unsigned int a, |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
35 vector unsigned int b, |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
36 vector unsigned int c, |
1386
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
37 vector unsigned int d) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
38 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
39 const vector unsigned int sl1 = ALTI_SL1; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
40 const vector unsigned int sr1 = ALTI_SR1; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
41 #ifdef ONLY64 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
42 const vector unsigned int mask = ALTI_MSK64; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
43 const vector unsigned char perm_sl = ALTI_SL2_PERM64; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
44 const vector unsigned char perm_sr = ALTI_SR2_PERM64; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
45 #else |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
46 const vector unsigned int mask = ALTI_MSK; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
47 const vector unsigned char perm_sl = ALTI_SL2_PERM; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
48 const vector unsigned char perm_sr = ALTI_SR2_PERM; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
49 #endif |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
50 vector unsigned int v, w, x, y, z; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
51 x = vec_perm(a, (vector unsigned int)perm_sl, perm_sl); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
52 v = a; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
53 y = vec_sr(b, sr1); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
54 z = vec_perm(c, (vector unsigned int)perm_sr, perm_sr); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
55 w = vec_sl(d, sl1); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
56 z = vec_xor(z, w); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
57 y = vec_and(y, mask); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
58 v = vec_xor(v, x); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
59 z = vec_xor(z, y); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
60 z = vec_xor(z, v); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
61 return z; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
62 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
63 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
64 /** |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
65 * This function fills the internal state array with pseudorandom |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
66 * integers. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
67 */ |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
68 inline static void gen_rand_all(void) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
69 int i; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
70 vector unsigned int r, r1, r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
71 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
72 r1 = sfmt[N - 2].s; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
73 r2 = sfmt[N - 1].s; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
74 for (i = 0; i < N - POS1; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
75 r = vec_recursion(sfmt[i].s, sfmt[i + POS1].s, r1, r2); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
76 sfmt[i].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
77 r1 = r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
78 r2 = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
79 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
80 for (; i < N; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
81 r = vec_recursion(sfmt[i].s, sfmt[i + POS1 - N].s, r1, r2); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
82 sfmt[i].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
83 r1 = r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
84 r2 = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
85 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
86 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
87 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
88 /** |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
89 * This function fills the user-specified array with pseudorandom |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
90 * integers. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
91 * |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
92 * @param array an 128-bit array to be filled by pseudorandom numbers. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
93 * @param size number of 128-bit pesudorandom numbers to be generated. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
94 */ |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
95 inline static void gen_rand_array(w128_t *array, int size) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
96 int i, j; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
97 vector unsigned int r, r1, r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
98 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
99 r1 = sfmt[N - 2].s; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
100 r2 = sfmt[N - 1].s; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
101 for (i = 0; i < N - POS1; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
102 r = vec_recursion(sfmt[i].s, sfmt[i + POS1].s, r1, r2); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
103 array[i].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
104 r1 = r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
105 r2 = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
106 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
107 for (; i < N; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
108 r = vec_recursion(sfmt[i].s, array[i + POS1 - N].s, r1, r2); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
109 array[i].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
110 r1 = r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
111 r2 = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
112 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
113 /* main loop */ |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
114 for (; i < size - N; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
115 r = vec_recursion(array[i - N].s, array[i + POS1 - N].s, r1, r2); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
116 array[i].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
117 r1 = r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
118 r2 = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
119 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
120 for (j = 0; j < 2 * N - size; j++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
121 sfmt[j].s = array[j + size - N].s; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
122 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
123 for (; i < size; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
124 r = vec_recursion(array[i - N].s, array[i + POS1 - N].s, r1, r2); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
125 array[i].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
126 sfmt[j++].s = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
127 r1 = r2; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
128 r2 = r; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
129 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
130 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
131 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
132 #ifndef ONLY64 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
133 #if defined(__APPLE__) |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
134 #define ALTI_SWAP (vector unsigned char) \ |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
135 (4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11) |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
136 #else |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
137 #define ALTI_SWAP {4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11} |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
138 #endif |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
139 /** |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
140 * This function swaps high and low 32-bit of 64-bit integers in user |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
141 * specified array. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
142 * |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
143 * @param array an 128-bit array to be swaped. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
144 * @param size size of 128-bit array. |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
145 */ |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
146 inline static void swap(w128_t *array, int size) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
147 int i; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
148 const vector unsigned char perm = ALTI_SWAP; |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
149 |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
150 for (i = 0; i < size; i++) { |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
151 array[i].s = vec_perm(array[i].s, (vector unsigned int)perm, perm); |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
152 } |
b8dd67ad7b86
update SFMT files to version 1.3. please let me know if it break on altivec box.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
926
diff
changeset
|
153 } |
922
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
154 #endif |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
155 |
7e14701aef54
[svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents:
diff
changeset
|
156 #endif |