-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathopenblas-0.3.19-e2k.patch
374 lines (359 loc) · 11 KB
/
openblas-0.3.19-e2k.patch
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
From 5d51b1092156e11cac3e48a432c394395f2013a2 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <jpegqs@gmail.com>
Date: Thu, 20 Jan 2022 22:34:16 +0700
Subject: [PATCH] openblas-0.3.19 e2k support
---
Makefile.e2k | 1 +
c_check | 7 +++
common.h | 4 ++
common_e2k.h | 64 +++++++++++++++++++
common_macro.h | 2 +-
ctest.c | 4 ++
getarch.c | 11 ++++
kernel/Makefile.L3 | 4 ++
kernel/e2k/KERNEL | 149 ++++++++++++++++++++++++++++++++++++++++++++
kernel/e2k/Makefile | 2 +
10 files changed, 247 insertions(+), 1 deletion(-)
create mode 100644 Makefile.e2k
create mode 100644 common_e2k.h
create mode 100644 kernel/e2k/KERNEL
create mode 100644 kernel/e2k/Makefile
diff --git a/Makefile.e2k b/Makefile.e2k
new file mode 100644
index 0000000..a5e50b1
--- /dev/null
+++ b/Makefile.e2k
@@ -0,0 +1 @@
+COPT = -Wall -O2 # -DGEMMTEST
diff --git a/c_check b/c_check
index bdf5b77..e73c46d 100644
--- a/c_check
+++ b/c_check
@@ -84,6 +84,7 @@ $os = Haiku if ($data =~ /OS_HAIKU/);
$architecture = x86 if ($data =~ /ARCH_X86/);
$architecture = x86_64 if ($data =~ /ARCH_X86_64/);
+$architecture = e2k if ($data =~ /ARCH_E2K/);
$architecture = power if ($data =~ /ARCH_POWER/);
$architecture = mips if ($data =~ /ARCH_MIPS/);
$architecture = mips64 if ($data =~ /ARCH_MIPS64/);
@@ -124,6 +125,11 @@ if ($architecture eq "zarch") {
$binary = 64;
}
+if ($architecture eq "e2k") {
+ $defined = 1;
+ $binary = 64;
+}
+
if ($architecture eq "alpha") {
$defined = 1;
$binary = 64;
@@ -224,6 +230,7 @@ if (($architecture eq "mips") || ($architecture eq "mips64")) {
$architecture = x86 if ($data =~ /ARCH_X86/);
$architecture = x86_64 if ($data =~ /ARCH_X86_64/);
+$architecture = e2k if ($data =~ /ARCH_E2K/);
$architecture = power if ($data =~ /ARCH_POWER/);
$architecture = mips if ($data =~ /ARCH_MIPS/);
$architecture = mips64 if ($data =~ /ARCH_MIPS64/);
diff --git a/common.h b/common.h
index ff5254a..00d1d0b 100644
--- a/common.h
+++ b/common.h
@@ -474,6 +474,10 @@ please https://github.com/xianyi/OpenBLAS/issues/246
#include "common_loongarch64.h"
#endif
+#ifdef ARCH_E2K
+#include "common_e2k.h"
+#endif
+
#ifndef ASSEMBLER
#ifdef OS_WINDOWSSTORE
typedef char env_var_t[MAX_PATH];
diff --git a/common_e2k.h b/common_e2k.h
new file mode 100644
index 0000000..0739c94
--- /dev/null
+++ b/common_e2k.h
@@ -0,0 +1,64 @@
+/*****************************************************************************
+Copyright (c) 2011-2016, The OpenBLAS Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. Neither the name of the OpenBLAS project nor the names of
+ its contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**********************************************************************************/
+
+#ifndef COMMON_E2K
+#define COMMON_E2K
+
+#ifdef ASSEMBLER
+#error
+#endif
+
+#define MB do { __asm__ __volatile__("": : :"memory"); } while (0)
+#define WMB do { __asm__ __volatile__("": : :"memory"); } while (0)
+#define RMB
+
+#define INLINE __attribute__((__always_inline__)) inline
+
+static inline int blas_quickdivide(blasint x, blasint y) {
+ return x / y;
+}
+
+#ifndef PAGESIZE
+#define PAGESIZE ( 4 << 10)
+#endif
+#define HUGE_PAGESIZE ( 2 << 20)
+
+#ifndef BUFFERSIZE
+#define BUFFER_SIZE (32 << 20)
+#else
+#define BUFFER_SIZE (32 << BUFFERSIZE)
+#endif
+
+#define SEEK_ADDRESS
+
+#endif
+
diff --git a/common_macro.h b/common_macro.h
index cf2a3fd..9826f18 100644
--- a/common_macro.h
+++ b/common_macro.h
@@ -2611,7 +2611,7 @@
#ifndef ASSEMBLER
#if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_IA64) || defined(ARCH_MIPS64) || defined(ARCH_ARM64)\
-|| defined(ARCH_LOONGARCH64)
+|| defined(ARCH_LOONGARCH64) || defined(ARCH_E2K)
extern BLASLONG gemm_offset_a;
extern BLASLONG gemm_offset_b;
extern BLASLONG sbgemm_p;
diff --git a/ctest.c b/ctest.c
index 2afd93f..fc52b43 100644
--- a/ctest.c
+++ b/ctest.c
@@ -165,3 +165,7 @@ ARCH_LOONGARCH64
HAVE_C11
#endif
+#if defined(__e2k__)
+ARCH_E2K
+#endif
+
diff --git a/getarch.c b/getarch.c
index 8222bde..19c9935 100644
--- a/getarch.c
+++ b/getarch.c
@@ -1515,6 +1515,17 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
+#if defined(FORCE_E2K) || defined(__e2k__)
+#define FORCE
+#define ARCHITECTURE "E2K"
+#define ARCHCONFIG "-DGENERIC " \
+ "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
+ "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
+ "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
+#define LIBNAME "generic"
+#define CORENAME "generic"
+#endif
+
#ifndef FORCE
#ifdef USER_TARGET
diff --git a/kernel/Makefile.L3 b/kernel/Makefile.L3
index d22bd46..917b733 100644
--- a/kernel/Makefile.L3
+++ b/kernel/Makefile.L3
@@ -617,6 +617,10 @@ $(KDIR)zgemm_beta$(TSUFFIX).$(SUFFIX) : $(KERNELDIR)/$(ZGEMM_BETA)
$(KDIR)xgemm_beta$(TSUFFIX).$(SUFFIX) : $(KERNELDIR)/$(XGEMM_BETA)
$(CC) $(CFLAGS) -c -DXDOUBLE -DCOMPLEX $< -o $@
+ifeq ($(ARCH), E2K)
+USE_TRMM = 1
+endif
+
ifeq ($(BUILD_BFLOAT16), 1)
diff --git a/kernel/e2k/KERNEL b/kernel/e2k/KERNEL
new file mode 100644
index 0000000..afa8a08
--- /dev/null
+++ b/kernel/e2k/KERNEL
@@ -0,0 +1,149 @@
+SAMAXKERNEL = ../arm/amax.c
+DAMAXKERNEL = ../arm/amax.c
+CAMAXKERNEL = ../arm/zamax.c
+ZAMAXKERNEL = ../arm/zamax.c
+
+SAMINKERNEL = ../arm/amin.c
+DAMINKERNEL = ../arm/amin.c
+CAMINKERNEL = ../arm/zamin.c
+ZAMINKERNEL = ../arm/zamin.c
+
+SMAXKERNEL = ../arm/max.c
+DMAXKERNEL = ../arm/max.c
+
+SMINKERNEL = ../arm/min.c
+DMINKERNEL = ../arm/min.c
+
+ISAMAXKERNEL = ../arm/iamax.c
+IDAMAXKERNEL = ../arm/iamax.c
+ICAMAXKERNEL = ../arm/izamax.c
+IZAMAXKERNEL = ../arm/izamax.c
+
+ISAMINKERNEL = ../arm/iamin.c
+IDAMINKERNEL = ../arm/iamin.c
+ICAMINKERNEL = ../arm/izamin.c
+IZAMINKERNEL = ../arm/izamin.c
+
+ISMAXKERNEL = ../arm/imax.c
+IDMAXKERNEL = ../arm/imax.c
+
+ISMINKERNEL = ../arm/imin.c
+IDMINKERNEL = ../arm/imin.c
+
+SASUMKERNEL = ../arm/asum.c
+DASUMKERNEL = ../arm/asum.c
+CASUMKERNEL = ../arm/zasum.c
+ZASUMKERNEL = ../arm/zasum.c
+
+SSUMKERNEL = ../arm/sum.c
+DSUMKERNEL = ../arm/sum.c
+CSUMKERNEL = ../arm/zsum.c
+ZSUMKERNEL = ../arm/zsum.c
+
+SAXPYKERNEL = ../arm/axpy.c
+DAXPYKERNEL = ../arm/axpy.c
+CAXPYKERNEL = ../arm/zaxpy.c
+ZAXPYKERNEL = ../arm/zaxpy.c
+
+SCOPYKERNEL = ../arm/copy.c
+DCOPYKERNEL = ../arm/copy.c
+CCOPYKERNEL = ../arm/zcopy.c
+ZCOPYKERNEL = ../arm/zcopy.c
+
+SDOTKERNEL = ../arm/dot.c
+DDOTKERNEL = ../arm/dot.c
+CDOTKERNEL = ../arm/zdot.c
+ZDOTKERNEL = ../arm/zdot.c
+DSDOTKERNEL = ../generic/dot.c
+
+SNRM2KERNEL = ../arm/nrm2.c
+DNRM2KERNEL = ../arm/nrm2.c
+CNRM2KERNEL = ../arm/znrm2.c
+ZNRM2KERNEL = ../arm/znrm2.c
+
+SROTKERNEL = ../arm/rot.c
+DROTKERNEL = ../arm/rot.c
+CROTKERNEL = ../arm/zrot.c
+ZROTKERNEL = ../arm/zrot.c
+
+SSCALKERNEL = ../arm/scal.c
+DSCALKERNEL = ../arm/scal.c
+CSCALKERNEL = ../arm/zscal.c
+ZSCALKERNEL = ../arm/zscal.c
+
+SSWAPKERNEL = ../arm/swap.c
+DSWAPKERNEL = ../arm/swap.c
+CSWAPKERNEL = ../arm/zswap.c
+ZSWAPKERNEL = ../arm/zswap.c
+
+SGEMVNKERNEL = ../arm/gemv_n.c
+DGEMVNKERNEL = ../arm/gemv_n.c
+CGEMVNKERNEL = ../arm/zgemv_n.c
+ZGEMVNKERNEL = ../arm/zgemv_n.c
+
+SGEMVTKERNEL = ../arm/gemv_t.c
+DGEMVTKERNEL = ../arm/gemv_t.c
+CGEMVTKERNEL = ../arm/zgemv_t.c
+ZGEMVTKERNEL = ../arm/zgemv_t.c
+
+STRMMKERNEL = ../generic/trmmkernel_2x2.c
+DTRMMKERNEL = ../generic/trmmkernel_2x2.c
+CTRMMKERNEL = ../generic/ztrmmkernel_2x2.c
+ZTRMMKERNEL = ../generic/ztrmmkernel_2x2.c
+
+SGEMMKERNEL = ../generic/gemmkernel_2x2.c
+SGEMMONCOPY = ../generic/gemm_ncopy_2.c
+SGEMMOTCOPY = ../generic/gemm_tcopy_2.c
+SGEMMONCOPYOBJ = sgemm_oncopy$(TSUFFIX).$(SUFFIX)
+SGEMMOTCOPYOBJ = sgemm_otcopy$(TSUFFIX).$(SUFFIX)
+
+DGEMMKERNEL = ../generic/gemmkernel_2x2.c
+DGEMMONCOPY = ../generic/gemm_ncopy_2.c
+DGEMMOTCOPY = ../generic/gemm_tcopy_2.c
+DGEMMONCOPYOBJ = dgemm_oncopy$(TSUFFIX).$(SUFFIX)
+DGEMMOTCOPYOBJ = dgemm_otcopy$(TSUFFIX).$(SUFFIX)
+
+CGEMMKERNEL = ../generic/zgemmkernel_2x2.c
+CGEMMONCOPY = ../generic/zgemm_ncopy_2.c
+CGEMMOTCOPY = ../generic/zgemm_tcopy_2.c
+CGEMMONCOPYOBJ = cgemm_oncopy$(TSUFFIX).$(SUFFIX)
+CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)
+
+ZGEMMKERNEL = ../generic/zgemmkernel_2x2.c
+ZGEMMONCOPY = ../generic/zgemm_ncopy_2.c
+ZGEMMOTCOPY = ../generic/zgemm_tcopy_2.c
+ZGEMMONCOPYOBJ = zgemm_oncopy$(TSUFFIX).$(SUFFIX)
+ZGEMMOTCOPYOBJ = zgemm_otcopy$(TSUFFIX).$(SUFFIX)
+
+STRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
+STRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
+STRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
+STRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
+
+DTRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
+DTRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
+DTRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
+DTRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
+
+CTRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
+CTRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
+CTRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
+CTRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
+
+ZTRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
+ZTRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
+ZTRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
+ZTRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
+
+
+SCABS_KERNEL = ../generic/cabs.c
+DCABS_KERNEL = ../generic/cabs.c
+QCABS_KERNEL = ../generic/cabs.c
+LSAME_KERNEL = ../generic/lsame.c
+
+SGEMM_BETA = ../generic/gemm_beta.c
+DGEMM_BETA = ../generic/gemm_beta.c
+CGEMM_BETA = ../generic/zgemm_beta.c
+ZGEMM_BETA = ../generic/zgemm_beta.c
+
+
diff --git a/kernel/e2k/Makefile b/kernel/e2k/Makefile
new file mode 100644
index 0000000..efae70d
--- /dev/null
+++ b/kernel/e2k/Makefile
@@ -0,0 +1,2 @@
+clean ::
+
--
2.17.1