1 #include "Matrix_init.h"
5 XBT_LOG_NEW_DEFAULT_CATEGORY(MM_init,
6 "Messages specific for this msg example");
7 #define _unused(x) ((void)x)
10 void matrices_initialisation( double ** p_a, double ** p_b, double ** p_c,
11 size_t m, size_t k_a, size_t k_b, size_t n,
12 size_t row, size_t col)
22 a = malloc(sizeof(double) * m * k_a);
25 perror("Error allocation Matrix A");
29 b = malloc(sizeof(double) * k_b * n);
32 perror("Error allocation Matrix B");
36 c = malloc(sizeof(double) * m * n);
38 perror("Error allocation Matrix C");
46 // size_tialisation of the matrices
48 for( z=0; z<k_a; z++){
52 a[x*lda+z] = (double)(z+col*n);
56 for( z=0; z<k_b; z++){
61 b[z*ldb+y] = (double)(y);
72 void matrices_allocation( double ** p_a, double ** p_b, double ** p_c,
73 size_t m, size_t k_a, size_t k_b, size_t n)
78 a = malloc(sizeof(double) * m * k_a);
81 perror("Error allocation Matrix A");
85 b = malloc(sizeof(double) * k_b * n);
88 perror("Error allocation Matrix B");
92 c = malloc(sizeof(double) * m * n);
94 perror("Error allocation Matrix C");
104 void blocks_initialisation( double ** p_a_local, double ** p_b_local,
105 size_t m, size_t B_k, size_t n)
110 double * a_local, *b_local;
112 a_local = malloc(sizeof(double) * m * B_k);
115 perror("Error allocation Matrix A");
119 b_local = malloc(sizeof(double) * B_k * n);
122 perror("Error allocation Matrix B");
126 *p_a_local = a_local;
127 *p_b_local = b_local;
129 // size_tialisation of the matrices
131 for( z=0; z<B_k; z++){
132 a_local[x*lda+z] = 0.0;
135 for( z=0; z<B_k; z++){
137 b_local[z*ldb+y] = 0.0;
142 void check_result(double *c, double *a, double *b,
143 size_t m, size_t n, size_t k_a, size_t k_b,
144 size_t row, size_t col,
145 size_t size_row, size_t size_col)
156 /* these variable could be use to check the result in function of the
157 * matrix initialization */
160 /*Display for checking */
162 XBT_INFO("Value get : %f excepted %zu multiply by y\n", c[((int)m/2)*ldc+1],size_row*k_a );
164 XBT_INFO("Value get : %f excepted %zu multiply by y\n", c[((int)m/2)*ldc+1], 1*(size_col*m)*((size_col*m)-1)/2) ;
168 /* WARNING this could be lead to some errors ( precision with double )*/
170 if ( fabs(c[x*ldc + y] - size_row*k_a) > 0.0000001)
172 if ( fabs(c[x*ldc + y] - y*(size_col*m)*((size_col*m)-1)/2) > 0.0000001)
176 XBT_INFO( "%f\t%zu, y : %zu x : %zu \n",
177 c[x*ldc+y], size_row*k_a, y, x);
179 XBT_INFO( "%f\t%zu, y : %zu x : %zu \n",
180 c[x*ldc+y], y*(size_col*m)*((size_col*m)-1)/2, y, x);
186 XBT_INFO("result check: ok\n");
189 XBT_INFO("result check not ok\n"
190 "WARNING the test could be lead to some "
191 "errors ( precision with double )\n");