-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsutils.c
More file actions
127 lines (114 loc) · 4.05 KB
/
Copy pathsutils.c
File metadata and controls
127 lines (114 loc) · 4.05 KB
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
/*
GEMM FLAVOURS
-----
GEMM FLAVOURS is a family of algorithms for matrix multiplication based
on the BLIS approach for this operation: https://github.com/flame/blis
-----
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details. You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----
author = "Enrique S. Quintana-Orti"
contact = "quintana@disca.upv.es"
copyright = "Copyright 2021, Universitat Politecnica de Valencia"
license = "GPLv3"
status = "Production"
version = "1.1"
*/
#define Mcol(a1, a2) M[(a2) * (ldM) + (a1)]
#define Mrow(a1, a2) M[(a1) * (ldM) + (a2)]
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "dtypes.h"
// ram parameters
//#include "pmsis.h"
//#include "bsp/ram.h"
//#include "bsp/ram/hyperram.h"
//#define BUFFER_SIZE ( 2048 )
/*
static signed char *buff_L2, *rcv_buff_L2; // buffers L2
static uint32_t buff_A_L3; // pointer to variable where return
the addres static uint32_t buff_B_L3; // pointer to variable
where return the addres static uint32_t buff_C_L3; // pointer to
variable where return the addres static struct pi_device ram; //
ram object static struct pi_hyperram_conf conf;// config object
*/
void generate_matrix(char orderM, int m, int n, DTYPE *M, int ldM) {
/*
* Generate a matrix with random entries
* m : Row dimension
* n : Column dimension
* M : Matrix
* ldM : Leading dimension
*
*/
int i, j;
if (orderM == 'C')
for (j = 0; j < n; j++)
for (i = 0; i < m; i++)
#if defined(FP16)
Mcol(i, j) = ((((DTYPE)j * m + i) / m) / n);
#elif defined(INT)
Mcol(i, j) = ((((DTYPE)j * m + i) / m) / n);
#else
Mcol(i, j) = ((DTYPE)((float)((i * 2 + j) % 3) - 1));
// Mcol(i,j) = ((DTYPE) rand());
// Mcol(i,j) = ((int) (10.0 * ((DTYPE) rand())/RAND_MAX));
#endif
else
for (j = 0; j < n; j++)
for (i = 0; i < m; i++)
#if defined(FP16)
Mrow(i, j) = ((((DTYPE)j * m + i) / m) / n);
#else
Mrow(i, j) = 1;
// Mrow(i,j) = ((DTYPE) rand())/__RAND_MAX + 1.0 ; El compilador no
// reconoce rand
// Mrow(i,j) = ((int) (10.0 * ((DTYPE) rand())/RAND_MAX));
#endif
}
/*===========================================================================*/
void print_matrix(char *name, char orderM, int m, int n, DTYPE *M, int ldM) {
int i, j;
if (orderM == 'C') {
for (j = 0; j < n; j++) {
for (i = 0; i < m; i++) {
#if defined(FP16)
printf("%s[%d,%d] = %8.2e;\n", name, i, j, ((DTYPE)Mcol(i, j)));
#elif defined(FP32)
printf("%s[%d,%d] = %14.8e;\n", name, i, j, ((DTYPE)Mcol(i, j)));
#elif defined(FP64)
printf("%s[%d,%d] = %22.16e;\n", name, i, j, ((DTYPE)Mcol(i, j)));
#elif defined(U_CHART)
printf("%s(%d,%d) = %u;\n", name, i + 1, j + 1, ((DTYPE)Mcol(i, j)));
#else
printf("%s(%d,%d) = %d;\n", name, i + 1, j + 1, ((DTYPE)Mcol(i, j)));
#endif
}
}
} else {
for (j = 0; j < n; j++) {
for (i = 0; i < m; i++) {
#if defined(FP16)
printf("%s[%d,%d] = %8.2e;\n", name, i, j, ((DTYPE)Mrow(i, j)));
#elif defined(FP32)
printf("%s[%d,%d] = %14.8e;\n", name, i, j, ((DTYPE)Mrow(i, j)));
#elif defined(FP64)
printf("%s[%d,%d] = %22.16e;\n", name, i, j, ((DTYPE)Mrow(i, j)));
#else
printf("%s[%d,%d] = %1.16e;\n", name, i, j, ((DTYPE)Mcol(i, j)));
#endif
}
}
}
} // end func
//==============================================================================