1 #include "Matrix_init.h"
4 XBT_LOG_NEW_DEFAULT_CATEGORY(MM_init,
5 "Messages specific for this msg example");
6 #define _unused(x) ((void)x)
9 void matrices_initialisation( double ** p_a, double ** p_b, double ** p_c,
10 size_t m, size_t k_a, size_t k_b, size_t n,
11 size_t row, size_t col)
21 a = malloc(sizeof(double) * m * k_a);
24 perror("Error allocation Matrix A");
28 b = malloc(sizeof(double) * k_b * n);
31 perror("Error allocation Matrix B");
35 c = malloc(sizeof(double) * m * n);
37 perror("Error allocation Matrix C");
45 // size_tialisation of the matrices
47 for( z=0; z<k_a; z++){
51 a[x*lda+z] = (double)(z+col*n);
55 for( z=0; z<k_b; z++){
60 b[z*ldb+y] = (double)(y);
71 void matrices_allocation( double ** p_a, double ** p_b, double ** p_c,
72 size_t m, size_t k_a, size_t k_b, size_t n)
77 a = malloc(sizeof(double) * m * k_a);
80 perror("Error allocation Matrix A");
84 b = malloc(sizeof(double) * k_b * n);
87 perror("Error allocation Matrix B");
91 c = malloc(sizeof(double) * m * n);
93 perror("Error allocation Matrix C");
103 void blocks_initialisation( double ** p_a_local, double ** p_b_local,
104 size_t m, size_t B_k, size_t n)
109 double * a_local, *b_local;
111 a_local = malloc(sizeof(double) * m * B_k);
114 perror("Error allocation Matrix A");
118 b_local = malloc(sizeof(double) * B_k * n);
121 perror("Error allocation Matrix B");
125 *p_a_local = a_local;
126 *p_b_local = b_local;
128 // size_tialisation of the matrices
130 for( z=0; z<B_k; z++){
131 a_local[x*lda+z] = 0.0;
134 for( z=0; z<B_k; z++){
136 b_local[z*ldb+y] = 0.0;
141 void check_result(double *c, double *a, double *b,
142 size_t m, size_t n, size_t k_a, size_t k_b,
143 size_t row, size_t col,
144 size_t size_row, size_t size_col)
155 /* these variable could be use to check the result in function of the
156 * matrix initialization */
159 /*Display for checking */
161 XBT_INFO("Value get : %f excepted %zu multiply by y\n", c[((int)m/2)*ldc+1],size_row*k_a );
163 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) ;
167 /* WARNING this could be lead to some errors ( precision with double )*/
169 if ( fabs(c[x*ldc + y] - size_row*k_a) > 0.0000001)
171 if ( fabs(c[x*ldc + y] - y*(size_col*m)*((size_col*m)-1)/2) > 0.0000001)
175 XBT_INFO( "%f\t%zu, y : %zu x : %zu \n",
176 c[x*ldc+y], size_row*k_a, y, x);
178 XBT_INFO( "%f\t%zu, y : %zu x : %zu \n",
179 c[x*ldc+y], y*(size_col*m)*((size_col*m)-1)/2, y, x);
185 XBT_INFO("result check: ok\n");
188 XBT_INFO("result check not ok\n"
189 "WARNING the test could be lead to some "
190 "errors ( precision with double )\n");