Skip to content

Commit e927373

Browse files
authored
Merge pull request #5371 from martin-frbg/fixup-5357
Complete the infrastructure changes for adding BGEMM
2 parents d030f81 + 9a272fe commit e927373

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

driver/others/parameter.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ BLASLONG shgemm_p = DEFAULT_GEMM_P;
7272
#else
7373
BLASLONG shgemm_p = SHGEMM_P;
7474
#endif
75+
#if BGEMM_P == bgemm_p
76+
BLASLONG bgemm_p = DEFAULT_GEMM_P;
77+
#else
78+
BLASLONG bgemm_p = BGEMM_P;
79+
#endif
7580
#if SGEMM_P == sgemm_p
7681
BLASLONG sgemm_p = DEFAULT_GEMM_P;
7782
#else
@@ -103,6 +108,11 @@ BLASLONG shgemm_q = DEFAULT_GEMM_Q;
103108
#else
104109
BLASLONG shgemm_q = SHGEMM_Q;
105110
#endif
111+
#if BGEMM_Q == bgemm_q
112+
BLASLONG bgemm_q = DEFAULT_GEMM_Q;
113+
#else
114+
BLASLONG bgemm_q = BGEMM_Q;
115+
#endif
106116
#if SGEMM_Q == sgemm_q
107117
BLASLONG sgemm_q = DEFAULT_GEMM_Q;
108118
#else
@@ -134,6 +144,11 @@ BLASLONG shgemm_r = DEFAULT_GEMM_R;
134144
#else
135145
BLASLONG shgemm_r = SHGEMM_R;
136146
#endif
147+
#if BGEMM_R == bgemm_r
148+
BLASLONG bgemm_r = DEFAULT_GEMM_R;
149+
#else
150+
BLASLONG bgemm_r = BGEMM_R;
151+
#endif
137152
#if SGEMM_R == sgemm_r
138153
BLASLONG sgemm_r = DEFAULT_GEMM_R;
139154
#else
@@ -541,6 +556,7 @@ void blas_set_parameter(void){
541556

542557
#ifdef BUILD_BFLOAT16
543558
sbgemm_r = (((BUFFER_SIZE - ((SBGEMM_P * SBGEMM_Q * 4 + GEMM_OFFSET_A + GEMM_ALIGN) & ~GEMM_ALIGN)) / (SBGEMM_Q * 4)) - 15) & ~15;
559+
bgemm_r = (((BUFFER_SIZE - ((BGEMM_P * BGEMM_Q * 4 + GEMM_OFFSET_A + GEMM_ALIGN) & ~GEMM_ALIGN)) / (BGEMM_Q * 4)) - 15) & ~15;
544560
#endif
545561
#ifdef BUILD_HFLOAT16
546562
shgemm_r = (((BUFFER_SIZE - ((SHGEMM_P * SHGEMM_Q * 4 + GEMM_OFFSET_A + GEMM_ALIGN) & ~GEMM_ALIGN)) / (SHGEMM_Q * 4)) - 15) & ~15;
@@ -653,6 +669,7 @@ void blas_set_parameter(void){
653669

654670
#ifdef BUILD_BFLOAT16
655671
sbgemm_r = (((BUFFER_SIZE - ((SBGEMM_P * SBGEMM_Q * 4 + GEMM_OFFSET_A + GEMM_ALIGN) & ~GEMM_ALIGN)) / (SBGEMM_Q * 4)) - 15) & ~15;
672+
bgemm_r = (((BUFFER_SIZE - ((BGEMM_P * BGEMM_Q * 4 + GEMM_OFFSET_A + GEMM_ALIGN) & ~GEMM_ALIGN)) / (BGEMM_Q * 4)) - 15) & ~15;
656673
#endif
657674
#ifdef BUILD_HFLOAT16
658675
shgemm_r = (((BUFFER_SIZE - ((SHGEMM_P * SHGEMM_Q * 4 + GEMM_OFFSET_A + GEMM_ALIGN) & ~GEMM_ALIGN)) / (SHGEMM_Q * 4)) - 15) & ~15;

kernel/setparam-ref.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ gotoblas_t TABLE_NAME = {
926926
static void init_parameter(void) {
927927
#if (BUILD_BFLOAT16)
928928
TABLE_NAME.sbgemm_p = SBGEMM_DEFAULT_P;
929+
TABLE_NAME.bgemm_p = BGEMM_DEFAULT_P;
929930
#endif
930931
#if (BUILD_SINGLE==1) || (BUILD_COMPLEX==1)
931932
TABLE_NAME.sgemm_p = SGEMM_DEFAULT_P;
@@ -942,6 +943,7 @@ static void init_parameter(void) {
942943

943944
#if (BUILD_BFLOAT16)
944945
TABLE_NAME.sbgemm_q = SBGEMM_DEFAULT_Q;
946+
TABLE_NAME.bgemm_q = BGEMM_DEFAULT_Q;
945947
#endif
946948
#if BUILD_SINGLE == 1 || (BUILD_COMPLEX==1)
947949
TABLE_NAME.sgemm_q = SGEMM_DEFAULT_Q;
@@ -958,6 +960,7 @@ static void init_parameter(void) {
958960

959961
#if (BUILD_BFLOAT16)
960962
TABLE_NAME.sbgemm_r = SBGEMM_DEFAULT_R;
963+
TABLE_NAME.bgemm_r = BGEMM_DEFAULT_R;
961964
#endif
962965
#if BUILD_SINGLE == 1 || (BUILD_COMPLEX==1)
963966
TABLE_NAME.sgemm_r = SGEMM_DEFAULT_R;
@@ -1113,10 +1116,12 @@ static void init_parameter(void) {
11131116

11141117
#ifdef BUILD_BFLOAT16
11151118
TABLE_NAME.sbgemm_p = SBGEMM_DEFAULT_P;
1119+
TABLE_NAME.bgemm_p = BGEMM_DEFAULT_P;
11161120
#endif
11171121

11181122
#ifdef BUILD_BFLOAT16
11191123
TABLE_NAME.sbgemm_r = SBGEMM_DEFAULT_R;
1124+
TABLE_NAME.bgemm_r = BGEMM_DEFAULT_R;
11201125
#endif
11211126

11221127
#if defined(LA464)
@@ -1215,6 +1220,7 @@ static void init_parameter(void) {
12151220

12161221
#ifdef BUILD_BFLOAT16
12171222
TABLE_NAME.sbgemm_q = SBGEMM_DEFAULT_Q;
1223+
TABLE_NAME.bgemm_q = BGEMM_DEFAULT_Q;
12181224
#endif
12191225
}
12201226
#else // (ARCH_LOONGARCH64)
@@ -1223,6 +1229,7 @@ static void init_parameter(void) {
12231229

12241230
#ifdef BUILD_BFLOAT16
12251231
TABLE_NAME.sbgemm_p = SBGEMM_DEFAULT_P;
1232+
TABLE_NAME.bgemm_p = BGEMM_DEFAULT_P;
12261233
#endif
12271234
TABLE_NAME.sgemm_p = SGEMM_DEFAULT_P;
12281235
TABLE_NAME.dgemm_p = DGEMM_DEFAULT_P;
@@ -1231,6 +1238,7 @@ static void init_parameter(void) {
12311238

12321239
#ifdef BUILD_BFLOAT16
12331240
TABLE_NAME.sbgemm_r = SBGEMM_DEFAULT_R;
1241+
TABLE_NAME.bgemm_r = BGEMM_DEFAULT_R;
12341242
#endif
12351243
TABLE_NAME.sgemm_r = SGEMM_DEFAULT_R;
12361244
TABLE_NAME.dgemm_r = DGEMM_DEFAULT_R;
@@ -1240,6 +1248,7 @@ static void init_parameter(void) {
12401248

12411249
#ifdef BUILD_BFLOAT16
12421250
TABLE_NAME.sbgemm_q = SBGEMM_DEFAULT_Q;
1251+
TABLE_NAME.bgemm_q = BGEMM_DEFAULT_Q;
12431252
#endif
12441253
TABLE_NAME.sgemm_q = SGEMM_DEFAULT_Q;
12451254
TABLE_NAME.dgemm_q = DGEMM_DEFAULT_Q;
@@ -1252,6 +1261,7 @@ static void init_parameter(void) {
12521261
static void init_parameter(void) {
12531262
#ifdef BUILD_BFLOAT16
12541263
TABLE_NAME.sbgemm_p = SBGEMM_DEFAULT_P;
1264+
TABLE_NAME.bgemm_p = BGEMM_DEFAULT_P;
12551265
#endif
12561266
TABLE_NAME.sgemm_p = SGEMM_DEFAULT_P;
12571267
TABLE_NAME.dgemm_p = DGEMM_DEFAULT_P;
@@ -1260,6 +1270,7 @@ static void init_parameter(void) {
12601270

12611271
#ifdef BUILD_BFLOAT16
12621272
TABLE_NAME.sbgemm_r = SBGEMM_DEFAULT_R;
1273+
TABLE_NAME.bgemm_r = BGEMM_DEFAULT_R;
12631274
#endif
12641275
TABLE_NAME.sgemm_r = SGEMM_DEFAULT_R;
12651276
TABLE_NAME.dgemm_r = DGEMM_DEFAULT_R;
@@ -1269,6 +1280,7 @@ static void init_parameter(void) {
12691280

12701281
#ifdef BUILD_BFLOAT16
12711282
TABLE_NAME.sbgemm_q = SBGEMM_DEFAULT_Q;
1283+
TABLE_NAME.bgemm_q = BGEMM_DEFAULT_Q;
12721284
#endif
12731285
TABLE_NAME.sgemm_q = SGEMM_DEFAULT_Q;
12741286
TABLE_NAME.dgemm_q = DGEMM_DEFAULT_Q;
@@ -1282,6 +1294,7 @@ static void init_parameter(void) {
12821294

12831295
#ifdef BUILD_BFLOAT16
12841296
TABLE_NAME.sbgemm_p = SBGEMM_DEFAULT_P;
1297+
TABLE_NAME.bgemm_p = BGEMM_DEFAULT_P;
12851298
#endif
12861299
#ifdef BUILD_HFLOAT16
12871300
TABLE_NAME.shgemm_p = SHGEMM_DEFAULT_P;
@@ -1293,6 +1306,7 @@ static void init_parameter(void) {
12931306

12941307
#ifdef BUILD_BFLOAT16
12951308
TABLE_NAME.sbgemm_r = SBGEMM_DEFAULT_R;
1309+
TABLE_NAME.bgemm_r = BGEMM_DEFAULT_R;
12961310
#endif
12971311
#ifdef BUILD_HFLOAT16
12981312
TABLE_NAME.shgemm_r = SHGEMM_DEFAULT_R;
@@ -1305,6 +1319,7 @@ static void init_parameter(void) {
13051319

13061320
#ifdef BUILD_BFLOAT16
13071321
TABLE_NAME.sbgemm_q = SBGEMM_DEFAULT_Q;
1322+
TABLE_NAME.bgemm_q = BGEMM_DEFAULT_Q;
13081323
#endif
13091324
#ifdef BUILD_HFLOAT16
13101325
TABLE_NAME.shgemm_q = SHGEMM_DEFAULT_Q;
@@ -1455,6 +1470,8 @@ static void init_parameter(void) {
14551470
#ifdef BUILD_BFLOAT16
14561471
TABLE_NAME.sbgemm_p = SBGEMM_DEFAULT_P;
14571472
TABLE_NAME.sbgemm_q = SBGEMM_DEFAULT_Q;
1473+
TABLE_NAME.bgemm_p = BGEMM_DEFAULT_P;
1474+
TABLE_NAME.bgemm_q = BGEMM_DEFAULT_Q;
14581475
#endif
14591476
#ifdef BUILD_HFLOAT16
14601477
TABLE_NAME.shgemm_p = SHGEMM_DEFAULT_P;
@@ -2053,6 +2070,10 @@ static void init_parameter(void) {
20532070
((TABLE_NAME.sbgemm_p * TABLE_NAME.sbgemm_q * 4 + TABLE_NAME.offsetA
20542071
+ TABLE_NAME.align) & ~TABLE_NAME.align)
20552072
) / (TABLE_NAME.sbgemm_q * 4) - 15) & ~15);
2073+
TABLE_NAME.bgemm_r = (((BUFFER_SIZE -
2074+
((TABLE_NAME.bgemm_p * TABLE_NAME.bgemm_q * 4 + TABLE_NAME.offsetA
2075+
+ TABLE_NAME.align) & ~TABLE_NAME.align)
2076+
) / (TABLE_NAME.bgemm_q * 4) - 15) & ~15);
20562077
#endif
20572078

20582079
#if BUILD_HFLOAT16==1

test/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ ifneq ($(CROSS), 1)
229229
ifeq ($(BUILD_BFLOAT16),1)
230230
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./test_sbgemm > SBBLAT3.SUMM
231231
@$(GREP) -q FATAL SBBLAT3.SUMM && cat SBBLAT3.SUMM || exit 0
232-
# OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./test_bgemm > BBLAT3.SUMM
233-
# @$(GREP) -q FATAL BBLAT3.SUMM && cat BBLAT3.SUMM || exit 0
232+
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./test_bgemm > BBLAT3.SUMM
233+
@$(GREP) -q FATAL BBLAT3.SUMM && cat BBLAT3.SUMM || exit 0
234234
endif
235235
ifeq ($(BUILD_SINGLE),1)
236236
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat3 < ./sblat3.dat
@@ -254,8 +254,8 @@ ifeq ($(USE_OPENMP), 1)
254254
ifeq ($(BUILD_BFLOAT16),1)
255255
OMP_NUM_THREADS=2 ./test_sbgemm > SBBLAT3.SUMM
256256
@$(GREP) -q FATAL SBBLAT3.SUMM && cat SBBLAT3.SUMM || exit 0
257-
# OMP_NUM_THREADS=2 ./test_bgemm > BBLAT3.SUMM
258-
# @$(GREP) -q FATAL BBLAT3.SUMM && cat BBLAT3.SUMM || exit 0
257+
OMP_NUM_THREADS=2 ./test_bgemm > BBLAT3.SUMM
258+
@$(GREP) -q FATAL BBLAT3.SUMM && cat BBLAT3.SUMM || exit 0
259259
endif
260260
ifeq ($(BUILD_SINGLE),1)
261261
OMP_NUM_THREADS=2 ./sblat3 < ./sblat3.dat
@@ -277,8 +277,8 @@ else
277277
ifeq ($(BUILD_BFLOAT16),1)
278278
OPENBLAS_NUM_THREADS=2 ./test_sbgemm > SBBLAT3.SUMM
279279
@$(GREP) -q FATAL SBBLAT3.SUMM && cat SBBLAT3.SUMM || exit 0
280-
# OPENBLAS_NUM_THREADS=2 ./test_bgemm > BBLAT3.SUMM
281-
# @$(GREP) -q FATAL BBLAT3.SUMM && cat BBLAT3.SUMM || exit 0
280+
OPENBLAS_NUM_THREADS=2 ./test_bgemm > BBLAT3.SUMM
281+
@$(GREP) -q FATAL BBLAT3.SUMM && cat BBLAT3.SUMM || exit 0
282282
endif
283283
ifeq ($(BUILD_SINGLE),1)
284284
OPENBLAS_NUM_THREADS=2 ./sblat3 < ./sblat3.dat

test/compare_sgemm_bgemm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
#include <stdint.h>
2929
#include <stdio.h>
3030

31-
#include <arm_neon.h>
3231

3332
#define SGEMM BLASFUNC(sgemm)
3433
#define BGEMM BLASFUNC(bgemm)

0 commit comments

Comments
 (0)