j'ai testé, les deux fonctionnent.
mais pourquoi ne pas recompiler la lib ?
C'est faisable mais GCC est très mauvais pour compiler ce genre de programmation générique. Les benchs FFT de GCC que j'avais fait il y a plus d'un an n'arrivaient pas à la cheville d'ICL ni de VC2005.Envoyé par epsilon68
Je n'ai pas fait encore de benchs avec GCC pour le produit matriciel, mais je pense pas qu'ils atteindront l'ordre de grandeur atteint par ICL, même si j'estime que GCC ne se laissera pas autant dépasser que pour la FFT.
Je n'ai certes pas pu tester encore avec la version 4.2, mais je doute que ça fasse une grande différence.
A part ça, j'ai trouvé sur internet la citation que 'malloc' assurait bien l'alignement sur 16 octets (comme pour FreeBSD donc)
on peut toujours essayer, je suis curieux de voir gcc 4.2 en action
OK, ça m'intéresse aussi!
Il faut que tu paramètres le fichier 'genial_config.h' avant de procéder aux étapes décries dans la doc (chapitre installation)
Aux endroits appropriés
1)
Tu pourras essayer diverses option pour les inlines selon ce qui donne les meilleurs benchs.
2)Si GCC 4.2 n'a pas encore (comme GCC 3.4.4) les bons fichiers d'en-tête, il faut que tu commentes HAS_SSE3
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 #elif defined(__GNUC__) //#define inline __inline //#define inline __attribute__((__always_inline__)) #endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 // Uncomment for SIMD calculation #define HAS_MMX #define HAS_SEE #define HAS_SSE2 #define HAS_SSE3
3)
4)Tu peux éventuellement compiler la FFT si tu le désires
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Define it to precompile the BLAS routines // and let it defined to link your programme with the compiled library #define BLAS_PRECOMPILE // Uncomment to make automatic convertions from GENIAL operators/functions to BLAS functions // => quicker calculation, but partial evaluation not possible for the corresponding calculations // WARNING: EXPERIMENTAL FEATURE //#define AUTO_BLAS // Define it to use multi-threaded algorithms for matrix multiplications // Multi-threading causes an overhead involved in synchronization, but increases // execution speed for big matrices on systems with several processors/cores. #ifndef BLAS_THREADING #define BLAS_THREADING #endif // BLAS_M, BLAS_N, BLAS_K and BLAS_K2 are dimensions of block matrices used to optimize the cache memory. // BLAS_M and BLAS_N must be multiple of 12. // Try various combinations to optimize speed on your system. #if !defined(BLAS_M) && !defined(BLAS_N) && !defined(BLAS_K) && !defined(BLAS_K2) #if defined(HAS_SSE3) #define BLAS_M 48 #define BLAS_N 48 #define BLAS_K 15 #define BLAS_K2 15 #elif defined(HAS_SSE2) #define BLAS_M 48 #define BLAS_N 48 #define BLAS_K 15 #define BLAS_K2 15 #else #define BLAS_M 12 #define BLAS_N 12 #define BLAS_K 2 #define BLAS_K2 2 #endif #endif
PS: La directive BLAS_THREADING ne sert encore à rien dans la version que tu as.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Define it to precompile the fft // and let it defined to link your programme with the compiled library #define FFT_PRECOMPILE // Set the complexity level of the fft algorithm. Possible values: 2,3,4,5,8,16,32,64. // Default value if not defined: 8. #ifndef FFT_LEVEL #define FFT_LEVEL 64 #endif // Define it to use multi-threaded algorithms for 2D-FFT // Multi-threading causes an overhead involved in synchronization, but increases // execution speed for big matrices on systems with several processors/cores. #ifndef FFT_THREADING #define FFT_THREADING #endif // Uncomment if the FFT has to be used on signals which lengths are only powers of 2. // => quicker compilation and smaller executable. #ifndef FFT_ONLY_POW2 //#define FFT_ONLY_POW2 #endif // Set the number of twiddles tables that can be kept in memory. // Increase this number to maximize execution speed, if you // foresee to alternately calculate the FFT on different array sizes. // Default value if not defined: 1 #ifndef FFT_TWIDDLES #define FFT_TWIDDLES 5 #endif
une idée ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 ./configure checking build system type... i686-apple-darwin8.9.1 checking host system type... i686-apple-darwin8.9.1 checking target system type... i686-apple-darwin8.9.1 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking for g++... g++ checking for C++ compiler default output file name... a.out checking whether the C++ compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for style of include used by make... GNU checking dependency style of g++... gcc3 checking for gcc... gcc checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking dependency style of gcc... gcc3 checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... no checking for /usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -p checking whether ln -s works... yes checking how to recognize dependent libraries... pass_all checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking how to run the C++ preprocessor... g++ -E checking for g77... no checking for xlf... no checking for f77... no checking for frt... no checking for pgf77... no checking for cf77... no checking for fort77... no checking for fl32... no checking for af77... no checking for xlf90... no checking for f90... no checking for pgf90... no checking for pghpf... no checking for epcf90... no checking for gfortran... no checking for g95... no checking for xlf95... no checking for f95... no checking for fort... no checking for ifort... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for ftn... no checking whether we are using the GNU Fortran 77 compiler... no checking whether accepts -g... no checking the maximum length of command line arguments... 196608 checking command to parse /usr/bin/nm -p output from gcc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fno-common checking if gcc PIC flag -fno-common works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin8.9.1 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes configure: creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common checking if g++ PIC flag -fno-common works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin8.9.1 dyld checking how to hardcode library paths into programs... immediate appending configuration tag "F77" to libtool configure: creating ./config.status config.status: creating Makefile config.status: creating genial/Makefile config.status: WARNING: genial/Makefile.in seems to ignore the --datarootdir setting config.status: creating src/Makefile config.status: creating samples/Makefile config.status: creating genial/autoconfig.h config.status: executing depfiles commands[EDIT]J'imagine que je dois trouver automake qui n'est pas installé en standard avec les outils de compilation ... :-/[/EDIT]
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 make cd . && /bin/sh /Users/xxx/Desktop/genial-2.0.2/autotools/missing --run aclocal-1.9 /Users/xxx/Desktop/genial-2.0.2/autotools/missing: line 52: aclocal-1.9: command not found WARNING: `aclocal-1.9' is missing on your system. You should only need it if you modified `acinclude.m4' or `configure.ac'. You might want to install the `Automake' and `Perl' packages. Grab them from any GNU archive site. cd . && /bin/sh /Users/xxx/Desktop/genial-2.0.2/autotools/missing --run automake-1.9 --foreign /Users/xxx/Desktop/genial-2.0.2/autotools/missing: line 52: automake-1.9: command not found WARNING: `automake-1.9' is missing on your system. You should only need it if you modified `Makefile.am', `acinclude.m4' or `configure.ac'. You might want to install the `Automake' and `Perl' packages. Grab them from any GNU archive site. cd . && /bin/sh /Users/xxx/Desktop/genial-2.0.2/autotools/missing --run autoconf /bin/sh ./config.status --recheck running CONFIG_SHELL=/bin/sh /bin/sh ./configure --no-create --no-recursion checking build system type... i686-apple-darwin8.9.1 checking host system type... i686-apple-darwin8.9.1 checking target system type... i686-apple-darwin8.9.1 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking for g++... g++ checking for C++ compiler default output file name... a.out checking whether the C++ compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for style of include used by make... GNU checking dependency style of g++... gcc3 checking for gcc... gcc checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking dependency style of gcc... gcc3 checking for a sed that does not truncate output... /usr/bin/sed checking for egrep... grep -E checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... no checking for /usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -p checking whether ln -s works... yes checking how to recognize dependent libraries... pass_all checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking how to run the C++ preprocessor... g++ -E checking for g77... no checking for f77... no checking for xlf... no checking for frt... no checking for pgf77... no checking for fort77... no checking for fl32... no checking for af77... no checking for f90... no checking for xlf90... no checking for pgf90... no checking for epcf90... no checking for f95... no checking for fort... no checking for xlf95... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for gfortran... no checking whether we are using the GNU Fortran 77 compiler... no checking whether accepts -g... no checking the maximum length of command line arguments... 196608 checking command to parse /usr/bin/nm -p output from gcc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fno-common checking if gcc PIC flag -fno-common works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin8.9.1 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes configure: creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common checking if g++ PIC flag -fno-common works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin8.9.1 dyld checking how to hardcode library paths into programs... immediate appending configuration tag "F77" to libtool configure: creating ./config.status /bin/sh ./config.status config.status: creating .infig.status: error: cannot find input file: make: *** [Makefile] Error 1
[EDIT 1]ha ba bon c'est installé, mais pourquoi il y a un numero de version du genre automake-1.9 et pas automake comme j'ai sur mon systeme ?[/EDIT 1]
Je ne m'y connais pas vraiment.
Tu compiles bien à partir du download pour Unix/Linux 'genial-2.0.2.zip' (et pas à partir d'un téléchargement pour Windows)? Parce que des outils nécessaires sont joints.
Mais visiblement il cherche 'aclocal', je ne sais pas ce que s'est (j'ai suivit des recettes toutes prêtes pour l'installation sous Unix/Linux).
Pour que ça marche sous cygwin il m'a aussi fallu installer les packets 'libtool' et 'automake'. Peut-être que ça manque sous Mac, mais j'en doute.
J'espère que ça marchera en suivant ces 2-3 pistes...
C'est le genre de problèmes qui me font apprécier Windows pas de makefile, pas de scripts, pas 36000 versions incompatibles entre elles...
je dois dire que je suis aussi un peu perdu
c'est pour ca aussi que je n'utilise plus que Qt && QMake
c'est beaucoup plus simple et multiplateforme...
EDIT oui je compile bien a partir des sources sinon je ne pouvais pas faire le configure comme marqué dans la doc
le makefile doit etre mal generé ou pas adapté pour Mac...
dis-moi si tu veux que je fasse d'autres tests
a+
Ce n'est plus vraiment la peine de faire d'autres tests.
Y'aura bien une version 4.X tôt ou tard sous Windows...
Tu peux quand même utiliser la bibliothèque mais sans la pré-compiler.
Il faut juste que tu commentes les lignes avec 'FFT_PRECOMPILE' et 'BLAS_PRECOMPILE', et fini les problèmes...
tu veux que je lance des benchmarks ?
Si tu veux tu peux compiler et executer le bench suivant de produits matriciels avec GCC 4.2.
Ca permettra de se faire une idée des perfs de GCC4.2 face à ICL.
Ca devrait se laisser compiler sans problème si tu laisse bien la macro 'BLAS_PRECOMPILE' dans 'genial_config.h" commentée (et bien sûr ne pas suivre la procédure d'installation)
J'ai commenté les bouts de programme qui font appel à ATLAS.
Si l'installation d'ATLAS t'intéresse, voici comment faire.
-télécharger ATLAS: http://math-atlas.sourceforge.net/
-Placer atlas dans un répretoire dont le chemin est sans espaces (peut-être pas pour Mac, en tout cas sous Cygwin)
-"make xconfig"
-"./xconfig.exe": choisir la bonne architecture et répondre par défaut (taper entrée) à une bonne dizaine de questions (sauf peut-être pour pthreads pour du multi-threading?)
-make install arch=WinNT_P4SSE2 (mettre le bon nom de ton architecture)
-attendre une petite heure (si je me souviens bien), faire la pause café...
-repérer les librairies .a, (libcblas.a, liblapack.a, libatlas.a ...) pour les lier à tes programmes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208 #include <fstream> //#define BLAS_M 48 //#define BLAS_N 48 //#define BLAS_K 12 //#define BLAS_K2 12 #include "blas/gemm.h" const double default_measure_time=1; const double default_max_error=0; static DenseVector<MatrixSize<int> >::self sizes(25, "(4x4) (8x8) (16x16) (32x32) (64x64) (100x100) (128x128) (144x144) (160x160) (176x176) (192x192) (200x200) (256x256) (400x400) (500x500) (512x512) (600x600) (700x700) (800x800) (900x900) (1000x1000) (1024x1024) (1500x1500) (2000x2000) (2048x2048)" ); //static DenseVector<MatrixSize<int> >::self sizes(114, "(1x1) (2x2) (3x3) (4x4) (5x5) (6x6) (7x7) (8x8) (9x9) (10x10) (11x11) (12x12) (13x13) (14x14) (15x15) (16x16) (17x17) (18x18) (19x19) (20x20) (21x21) (22x22) (23x23) (24x24) (25x25) (26x26) (27x27) (28x28) (29x29) (30x30) (31x31) (32x32) (33x33) (34x34) (35x35) (36x36) (37x37) (38x38) (39x39) (40x40) (41x41) (42x42) (43x43) (44x44) (45x45) (46x46) (47x47) (48x48) (49x49) (50x50) (51x51) (52x52) (53x53) (54x54) (55x55) (56x56) (57x57) (58x58) (59x59) (60x60) (61x61) (62x62) (63x63) (64x64) (65x65) (66x66) (67x67) (68x68) (69x69) (70x70) (71x71) (72x72) (73x73) (74x74) (75x75) (76x76) (77x77) (78x78) (79x79) (80x80) (81x81) (82x82) (83x83) (84x84) (85x85) (86x86) (87x87) (88x88) (89x89) (90x90) (91x91) (92x92) (93x93) (94x94) (95x95) (96x96) (97x97) (98x98) (99x99) (100x100) (200x200) (300x300) (400x400) (500x500) (600x600) (700x700) (800x800) (900x900) (1000x1000) (1200x1200) (1400x1400) (1600x1600) (1800x1800) (2000x2000)"); //extern "C" //{ //#include "atlas_misc.h" //#include "atlas_level1.h" //#include "atlas_level3.h" //#include "cblas.h" //#include "clapack.h" //} //template<class T> //struct atlas_gemm_function //{ //}; // //template<> //struct atlas_gemm_function<float> //{ // template<class G1,class G2,class G3> inline void operator()(CBLAS_TRANSPOSE TransA,CBLAS_TRANSPOSE TransB, const Matrix<G1> &A, const Matrix<G2> &B, Matrix<G3> &C) // { // int m=C.nrows(), n=C.ncols(), k=A.ncols(); // cblas_sgemm(AtlasRowMajor,TransA,TransB,m,n,k,1,&A(0,0),k,&B(0,0),n,0,&C(0,0),n); // } //}; // //template<> //struct atlas_gemm_function<double> //{ // template<class G1,class G2,class G3> inline void operator()(CBLAS_TRANSPOSE TransA,CBLAS_TRANSPOSE TransB, const Matrix<G1> &A, const Matrix<G2> &B, Matrix<G3> &C) // { // int m=C.nrows(), n=C.ncols(), k=A.ncols(); // cblas_dgemm(AtlasRowMajor,TransA,TransB,m,n,k,1,&A(0,0),k,&B(0,0),n,0,&C(0,0),n); // } //}; // //template<> //struct atlas_gemm_function<complex<float> > //{ // typedef float real_type; // typedef complex<real_type> value_type; // template<class G1,class G2,class G3> inline void operator()(CBLAS_TRANSPOSE TransA,CBLAS_TRANSPOSE TransB, const Matrix<G1> &A, const Matrix<G2> &B, Matrix<G3> &C) // { // int m=C.nrows(), n=C.ncols(), k=A.ncols(); // value_type alpha(1,0), beta(0,0); // cblas_cgemm(AtlasRowMajor,TransA,TransB,m,n,k,(real_type*)&alpha,(real_type*)&A(0,0),k,(real_type*)&B(0,0),n,(real_type*)&beta,(real_type*)&C(0,0),n); // } //}; // //template<> //struct atlas_gemm_function<complex<double> > //{ // typedef double real_type; // typedef complex<real_type> value_type; // template<class G1,class G2,class G3> inline void operator()(CBLAS_TRANSPOSE TransA,CBLAS_TRANSPOSE TransB, const Matrix<G1> &A, const Matrix<G2> &B, Matrix<G3> &C) // { // int m=C.nrows(), n=C.ncols(), k=A.ncols(); // value_type alpha(1,0), beta(0,0); // cblas_zgemm(AtlasRowMajor,TransA,TransB,m,n,k,(real_type*)&alpha,(real_type*)&A(0,0),k,(real_type*)&B(0,0),n,(real_type*)&beta,(real_type*)&C(0,0),n); // } //}; // //template<class G1,class G2,class G3> //void atlas_gemm(const Matrix<G1> &A, const Matrix<G2> &B, Matrix<G3> &C) //{ // atlas_gemm_function<typename Matrix<G3>::value_type>()(AtlasNoTrans,AtlasNoTrans,A,B,C); //} // //template<class G1,class G2,class G3> //void atlas_tgemm(const Matrix<G1> &A, const Matrix<G2> &B, Matrix<G3> &C) //{ // atlas_gemm_function<typename Matrix<G3>::value_type>()(AtlasNoTrans,AtlasTrans,A,B,C); //} template<class T> struct random_function : public binary_function<int,int,T> { typedef binary_function<int,int,T> base; typedef typename base::result_type result_type; typedef typename base::first_argument_type first_argument_type; typedef typename base::second_argument_type second_argument_type; result_type operator()(const first_argument_type &,const second_argument_type &) const { return result_type(rand(10)); } }; template<class T> struct random_function<complex<T> > : public binary_function<int,int,complex<T> > { typedef binary_function<int,int,complex<T> > base; typedef typename base::result_type result_type; typedef typename base::first_argument_type first_argument_type; typedef typename base::second_argument_type second_argument_type; result_type operator()(const first_argument_type &,const second_argument_type &) const { return result_type(rand(10),rand(10)); } }; template<class E,class Tr,class G1,class G2> void excel_output(basic_ostream<E,Tr> &os, const Vector<G1> &X, const Matrix<G2> &M) { for (int i=0; i<X.size(); ++i) { os<< X[i].nrows() << "\t"; for(int n=0;n<M.ncols();++n) os<< round(M(i,n)) << "\t"; os<< endl; } cout << endl << endl; } template<class V,class G> DenseMatrix<float>::self gemm_benchmark(const Vector<G> &S, float nops=1, double dt=default_measure_time) { int n = S.size(); DenseMatrix<float>::self M(n,2,-1); srand(static_cast<unsigned>(time(0))); for (int i=0;i<n;i++) { typedef V value_type; typedef typename DenseMatrix<value_type>::self array_type; int m=S[i].nrows(), n=m, k=S[i].ncols(); double t0=0, sum=1; array_type C1(m,n, value_type(0)), C2(m,n, value_type(0)); srand(2); array_type A=dense_matrix_generate(m,k, random_function<value_type>()); array_type B=dense_matrix_generate(k,n, random_function<value_type>()); // array_type A(m,k, 1); //array_type B(k,n, 1); //for (sum=0,t0=get_time(); (get_time()-t0)<dt; ++sum) // atlas_gemm(A,B,C2); //M(i,1)=(2*nops*m*n*k)/(1000000*(get_time()-t0)/sum); for (sum=0,t0=get_time(); (get_time()-t0)<dt; ++sum) gemm(1,A,B,1,C1); M(i,0)=(2*nops*m*n*k)/(1000000*(get_time()-t0)/sum); double d = dist(C1,C2); if (d/(m*n)>=default_max_error) cout << S[i] << "\t" << d << "\t" << M(i,0) << "\t" << M(i,1) << endl; } return M; } int main() { string s="Benchmark GEMM "; s+=to_string(BLAS_M)+" "+to_string(BLAS_K); #if defined(SSE3) s+=" SSE3"; #elif defined(SSE2) s+=" SSE2"; #endif #ifdef BLAS_THREADING #if defined(OPENMP) s+= " OpenMP" + to_string(max_threads()); #else s+= " MT" + to_string(max_threads()); #endif #endif s+=".txt"; cout << s << endl; ofstream fout(s.c_str()); fout << "BLAS_M = " << BLAS_M << endl; fout << "BLAS_N = " << BLAS_N << endl; fout << "BLAS_K = " << BLAS_K << endl; fout << "BLAS_K2 = " << BLAS_K2 << endl; fout << endl; DenseMatrix<float>::self M(sizes.size(),4, -1); cout << "float" << endl; sub(M,0,0,M.nrows(),2)=gemm_benchmark<float >(sizes); cout << "double" << endl; sub(M,0,2,M.nrows(),2)=gemm_benchmark<double >(sizes); fout << '\t' << "GENIAL sgemm" << '\t' << "ATLAS sgemm" << '\t' << "GENIAL dgemm" << '\t' << "ATLAS dgemm" << endl; excel_output(fout,sizes,M); //cout << "complex<float>" << endl; sub(M,0,0,M.nrows(),2)=gemm_benchmark<complex<float> >(sizes,4); //cout << "complex<double>" << endl; sub(M,0,2,M.nrows(),2)=gemm_benchmark<complex<double> >(sizes,4); //fout << '\t' << "GENIAL cgemm" << '\t' << "ATLAS cgemm" << '\t' << "GENIAL zgemm" << '\t' << "ATLAS zgemm" << endl; //excel_output(fout,sizes,M); }
j'essaie de le lancer ce soir
(je ne ferais pas ATLAS, trop consommateur de temps.)
t'es sur qu'il ne manque pas d'include ?
et a priori, il reste des references a BLAS dans le code ...
et pourquoi je ne peux pas copier sans que tout se retrouve sur une seule ligne ?....
EDIT non rien j'ai tort
Non ça compile bien sur mon ordi. Juste que tu confonds probablement BLAS et ATLAS.Envoyé par epsilon68
-BLAS c'est une sorte d'API standard pour le calcul matriciel (LAPACK aussi d'ailleur), c'est comme ça que je le comprends en tout cas, mais peut-être aussi qu'il y a eu une bibliothèque originel avec ce nom.
-ATLAS c'est une bibliothèque qui implémente les API BLAS et LAPACK
Il n'est pas impossible que mon fichier était en format Unix (un seul caractère pour le retour à la ligne, contre 2 pour DOS/Windows). Visual ne fait aucune différence.Envoyé par epsilon68
Les Macs n'utilisent pas le format Unix??
Je vais éditer le code plus haut, et j'espère que ça passera mieux...
merci pour les infos,
je m'étais trompé en fait, puis le copier ne marche pas simplement, il faut citer le message puis copier et la ca marche.
ca a compilé sans erreur et la ca s'execute...
a tout de suite...
... heu ca prend vraiment une plombe ...
et voila !
Ca prend quand meme une plombe de temps à s'executer...
Tu m'étonnes que ça mette une plombe. Ca fait grossomodo du 32MFlops (alors que compilé avec ICL mon Pentium4 fait dans les 5000).
T'as bien compilé en mode release?
Esaye de compiler avec la macro "#define inline __attribute__((__always_inline__))" dans 'genial_config.h'.
Et pas la peine de laisser le bench s'exécuter entièrement, il suffit de vérifier que la 3ème colonne sur la console correspondant au MFlops affiche bien des valeurs qui croissent assez rapidement et qui commence à plafonner vers les matrices de taille 100x100 (en tout cas il faut plus que 32 MFlops)
Haaaaaarrrrrrrgggggggg
Je n'ai pas compilé en mode release !!!!
donc je les relance ce soir avec les differentes optimisations ...
EDIT à ma décharge, j'ai fais les tests avec mon enfant dans les bras, entre à manger, le bain, le dodo, les couches ....
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager