Skip to content

Commit f0560f9

Browse files
authored
Merge pull request #4689 from martin-frbg/issue4684
Fix compilation of the BLAS extension utests for NO_CBLAS=1
2 parents e1e0d9a + d8baf2f commit f0560f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+224
-62
lines changed

utest/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ OBJS = utest_main2.o
6161
OBJS_EXT = $(DIR_EXT)/utest_main2.o
6262
endif
6363

64+
ifeq ($(NO_CBLAS), 1)
65+
override CFLAGS += -DNO_CBLAS
66+
endif
67+
6468
all : run_test
6569

6670
ifeq ($(OSNAME), AIX)

utest/test_extensions/common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ float smatrix_difference(float *a, float *b, blasint cols, blasint rows, blasint
6969
for (j = 0; j < cols; j++) {
7070
a_ptr[j] -= b_ptr[j];
7171
}
72-
norm += cblas_snrm2(cols, a_ptr, inc);
72+
norm += BLASFUNC(snrm2)(&cols, a_ptr, &inc);
7373

7474
a_ptr += ld;
7575
b_ptr += ld;
@@ -92,7 +92,7 @@ double dmatrix_difference(double *a, double *b, blasint cols, blasint rows, blas
9292
for (j = 0; j < cols; j++) {
9393
a_ptr[j] -= b_ptr[j];
9494
}
95-
norm += cblas_dnrm2(cols, a_ptr, inc);
95+
norm += BLASFUNC(dnrm2)(&cols, a_ptr, &inc);
9696

9797
a_ptr += ld;
9898
b_ptr += ld;
@@ -256,4 +256,4 @@ void zcopy(blasint rows, blasint cols, double *alpha, double *a_src, int lda_src
256256
a_dst[i*lda_dst+j+1] = (-1.0) * conj *alpha[0] * a_src[i*lda_src+j+1] + alpha[1] * a_src[i*lda_src+j];
257257
}
258258
}
259-
}
259+
}

utest/test_extensions/test_caxpby.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static float check_caxpby(blasint n, float *alpha, blasint incx, float *beta, bl
9696
// Find the norm of differences
9797
return BLASFUNC(scnrm2)(&n, data_caxpby.y_test, &incy_abs);
9898
}
99-
99+
#ifndef NO_CBLAS
100100
/**
101101
* C API specific function
102102
* Test caxpby by comparing it with cscal and caxpy.
@@ -146,7 +146,7 @@ static float c_api_check_caxpby(blasint n, float *alpha, blasint incx, float *be
146146
// Find the norm of differences
147147
return cblas_scnrm2(n, data_caxpby.y_test, incy_abs);
148148
}
149-
149+
#endif
150150
/**
151151
* Fortran API specific test
152152
* Test caxpby by comparing it with cscal and caxpy.
@@ -388,6 +388,7 @@ CTEST(caxpby, check_n_zero)
388388
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
389389
}
390390

391+
#ifndef NO_CBLAS
391392
/**
392393
* C API specific test
393394
* Test caxpby by comparing it with cscal and caxpy.
@@ -629,3 +630,4 @@ CTEST(caxpby, c_api_check_n_zero)
629630
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
630631
}
631632
#endif
633+
#endif

utest/test_extensions/test_cgeadd.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ static void cgeadd_trusted(blasint m, blasint n, float *alpha, float *aptr,
6262
blasint lda, float *beta, float *cptr, blasint ldc)
6363
{
6464
blasint i;
65+
blasint one=1;
6566

6667
lda *= 2;
6768
ldc *= 2;
6869

6970
for (i = 0; i < n; i++)
7071
{
71-
cblas_caxpby(m, alpha, aptr, 1, beta, cptr, 1);
72+
BLASFUNC(caxpby)(&m, alpha, aptr, &one, beta, cptr, &one);
7273
aptr += lda;
7374
cptr += ldc;
7475
}
@@ -116,9 +117,11 @@ static float check_cgeadd(char api, OPENBLAS_CONST enum CBLAS_ORDER order,
116117
if (api == 'F')
117118
BLASFUNC(cgeadd)(&m, &n, alpha, data_cgeadd.a_test, &lda,
118119
beta, data_cgeadd.c_test, &ldc);
120+
#ifndef NO_CBLAS
119121
else
120122
cblas_cgeadd(order, m, n, alpha, data_cgeadd.a_test, lda,
121123
beta, data_cgeadd.c_test, ldc);
124+
#endif
122125

123126
// Find the differences between output matrix caculated by cgeadd and sgemm
124127
return smatrix_difference(data_cgeadd.c_test, data_cgeadd.c_verify, cols, rows, ldc*2);
@@ -150,9 +153,11 @@ static int check_badargs(char api, OPENBLAS_CONST enum CBLAS_ORDER order,
150153
if (api == 'F')
151154
BLASFUNC(cgeadd)(&m, &n, alpha, data_cgeadd.a_test, &lda,
152155
beta, data_cgeadd.c_test, &ldc);
156+
#ifndef NO_CBLAS
153157
else
154158
cblas_cgeadd(order, m, n, alpha, data_cgeadd.a_test, lda,
155159
beta, data_cgeadd.c_test, ldc);
160+
#endif
156161

157162
return check_error();
158163
}
@@ -419,7 +424,7 @@ CTEST(cgeadd, m_zero)
419424

420425
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
421426
}
422-
427+
#ifndef NO_CBLAS
423428
/**
424429
* C API specific test
425430
* Test cgeadd by comparing it against sgemm
@@ -877,4 +882,5 @@ CTEST(cgeadd, c_api_m_zero)
877882

878883
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
879884
}
880-
#endif
885+
#endif
886+
#endif

utest/test_extensions/test_cgemm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static float check_cgemm(char transa, char transb, blasint m, blasint n, blasint
7373
float alpha_conj[] = {1.0f, 0.0f};
7474
char transa_verify = transa;
7575
char transb_verify = transb;
76+
char cc[2]="C", cr[2]="R";
7677

7778
int arows = k, acols = m;
7879
int brows = n, bcols = k;
@@ -99,12 +100,12 @@ static float check_cgemm(char transa, char transb, blasint m, blasint n, blasint
99100
data_cgemm.c_verify[i] = data_cgemm.c_test[i];
100101

101102
if (transa == 'R'){
102-
cblas_cimatcopy(CblasColMajor, CblasConjNoTrans, arows, acols, alpha_conj, data_cgemm.a_verify, lda, lda);
103+
BLASFUNC(cimatcopy)(cc, cr, &arows, &acols, alpha_conj, data_cgemm.a_verify, &lda, &lda);
103104
transa_verify = 'N';
104105
}
105106

106107
if (transb == 'R'){
107-
cblas_cimatcopy(CblasColMajor, CblasConjNoTrans, brows, bcols, alpha_conj, data_cgemm.b_verify, ldb, ldb);
108+
BLASFUNC(cimatcopy)(cc, cr, &brows, &bcols, alpha_conj, data_cgemm.b_verify, &ldb, &ldb);
108109
transb_verify = 'N';
109110
}
110111

@@ -270,4 +271,4 @@ CTEST(cgemm, transa_conjnotransb)
270271

271272
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
272273
}
273-
#endif
274+
#endif

utest/test_extensions/test_cgemmt.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ static void cgemmt_trusted(char api, enum CBLAS_ORDER order, char uplo, char tra
7373
if(api == 'F')
7474
BLASFUNC(cgemm)(&transa, &transb, &m, &m, &k, alpha, data_cgemmt.a_test, &lda,
7575
data_cgemmt.b_test, &ldb, beta, data_cgemmt.c_gemm, &ldc);
76+
#ifndef NO_CBLAS
7677
else
7778
cblas_cgemm(order, transa, transb, m, m, k, alpha, data_cgemmt.a_test, lda,
7879
data_cgemmt.b_test, ldb, beta, data_cgemmt.c_gemm, ldc);
80+
#endif
7981

8082
ldc *= 2;
8183

@@ -160,9 +162,11 @@ static float check_cgemmt(char api, enum CBLAS_ORDER order, char uplo, char tran
160162
if (api == 'F')
161163
BLASFUNC(cgemmt)(&uplo, &transa, &transb, &m, &k, alpha, data_cgemmt.a_test,
162164
&lda, data_cgemmt.b_test, &ldb, beta, data_cgemmt.c_test, &ldc);
165+
#ifndef NO_CBLAS
163166
else
164167
cblas_cgemmt(order, uplo, transa, transb, m, k, alpha, data_cgemmt.a_test, lda,
165168
data_cgemmt.b_test, ldb, beta, data_cgemmt.c_test, ldc);
169+
#endif
166170

167171
for (i = 0; i < m * ldc * 2; i++)
168172
data_cgemmt.c_verify[i] -= data_cgemmt.c_test[i];
@@ -197,9 +201,11 @@ static int check_badargs(char api, enum CBLAS_ORDER order, char uplo, char trans
197201
if (api == 'F')
198202
BLASFUNC(cgemmt)(&uplo, &transa, &transb, &m, &k, alpha, data_cgemmt.a_test,
199203
&lda, data_cgemmt.b_test, &ldb, beta, data_cgemmt.c_test, &ldc);
204+
#ifndef NO_CBLAS
200205
else
201206
cblas_cgemmt(order, uplo, transa, transb, m, k, alpha, data_cgemmt.a_test, lda,
202207
data_cgemmt.b_test, ldb, beta, data_cgemmt.c_test, ldc);
208+
#endif
203209

204210
return check_error();
205211
}
@@ -680,6 +686,7 @@ CTEST(cgemmt, lower_beta_one)
680686
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
681687
}
682688

689+
#ifndef NO_CBLAS
683690
/**
684691
* C API specific test
685692
* Test cgemmt by comparing it against sgemm
@@ -1591,6 +1598,7 @@ CTEST(cgemmt, c_api_rowmajor_lower_beta_one)
15911598

15921599
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
15931600
}
1601+
#endif
15941602

15951603
/**
15961604
* Fortran API specific test
@@ -1736,6 +1744,7 @@ CTEST(cgemmt, xerbla_ldc_invalid)
17361744
ASSERT_EQUAL(TRUE, passed);
17371745
}
17381746

1747+
#ifndef NO_CBLAS
17391748
/**
17401749
* C API specific test.
17411750
* Test error function for an invalid param order.
@@ -2007,4 +2016,5 @@ CTEST(cgemmt, xerbla_c_api_rowmajor_ldc_invalid)
20072016
M, K, lda, ldb, ldc, expected_info);
20082017
ASSERT_EQUAL(TRUE, passed);
20092018
}
2010-
#endif
2019+
#endif
2020+
#endif

utest/test_extensions/test_cgemv_t.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static struct DATA_CGEMV_T data_cgemv_t;
6565
static void matrix_vector_product(blasint n, blasint m, blasint lda, blasint inc_x)
6666
{
6767
blasint i;
68+
blasint one=1;
6869
float *a_ptr = data_cgemv_t.a_verify;
6970
float *x_ptr = data_cgemv_t.x_test;
7071
float *x_res = data_cgemv_t.x_verify;
@@ -73,7 +74,7 @@ static void matrix_vector_product(blasint n, blasint m, blasint lda, blasint inc
7374

7475
for (i = 0; i < n * inc_x; i+= inc_x)
7576
{
76-
result = cblas_cdotu(lda, a_ptr, 1, x_ptr, inc_x);
77+
result = BLASFUNC(cdotu)(&lda, a_ptr, &one, x_ptr, &inc_x);
7778
x_res[0] = CREAL(result);
7879
x_res[1] = CIMAG(result);
7980
a_ptr += lda * 2;
@@ -153,6 +154,7 @@ static float check_cgemv(char api, char order, char trans, blasint m, blasint n,
153154
BLASFUNC(cgemv)(&trans, &m, &n, alpha, data_cgemv_t.a_test,
154155
&lda, data_cgemv_t.x_test, &inc_x, beta, data_cgemv_t.y_test, &inc_y);
155156
}
157+
#ifndef NO_CBLAS
156158
else {
157159
if (order == 'C') corder = CblasColMajor;
158160
if (order == 'R') corder = CblasRowMajor;
@@ -173,13 +175,14 @@ static float check_cgemv(char api, char order, char trans, blasint m, blasint n,
173175
cblas_cgemv(corder, ctrans, m, n, alpha, data_cgemv_t.a_test,
174176
lda, data_cgemv_t.x_test, inc_x, beta, data_cgemv_t.y_test, inc_y);
175177
}
178+
#endif
176179

177180
// Find the differences between output vector caculated by cgemv and reference funcs
178181
for (i = 0; i < m * inc_y * 2; i++)
179182
data_cgemv_t.y_test[i] -= data_cgemv_t.y_verify[i];
180183

181184
// Find the norm of differences
182-
return cblas_scnrm2(m, data_cgemv_t.y_test, inc_y);
185+
return BLASFUNC(scnrm2)(&m, data_cgemv_t.y_test, &inc_y);
183186
}
184187

185188
/**
@@ -213,6 +216,7 @@ static int check_badargs(char order, char trans, blasint m, blasint n,
213216
return check_error();
214217
}
215218

219+
#ifndef NO_CBLAS
216220
/**
217221
* C API specific function
218222
* Check if error function was called with expected function name
@@ -1130,3 +1134,4 @@ CTEST(cgemv, c_api_xerbla_invalid_order_col_major)
11301134
ASSERT_EQUAL(TRUE, passed);
11311135
}
11321136
#endif
1137+
#endif

utest/test_extensions/test_cimatcopy.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static float check_cimatcopy(char api, char order, char trans, blasint rows, bla
9898
BLASFUNC(cimatcopy)(&order, &trans, &rows, &cols, alpha, data_cimatcopy.a_test,
9999
&lda_src, &lda_dst);
100100
}
101+
#ifndef NO_CBLAS
101102
else {
102103
if (order == 'C') corder = CblasColMajor;
103104
if (order == 'R') corder = CblasRowMajor;
@@ -108,6 +109,7 @@ static float check_cimatcopy(char api, char order, char trans, blasint rows, bla
108109
cblas_cimatcopy(corder, ctrans, rows, cols, alpha, data_cimatcopy.a_test,
109110
lda_src, lda_dst);
110111
}
112+
#endif
111113

112114
// Find the differences between output matrix computed by cimatcopy and reference func
113115
return smatrix_difference(data_cimatcopy.a_test, data_cimatcopy.a_verify, cols_out, rows_out, 2*lda_dst);
@@ -502,6 +504,7 @@ CTEST(cimatcopy, rowmajor_conjtrans_col_50_row_100)
502504
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
503505
}
504506

507+
#ifndef NO_CBLAS
505508
/**
506509
* C API specific test
507510
* Test cimatcopy by comparing it against reference
@@ -681,6 +684,7 @@ CTEST(cimatcopy, c_api_rowmajor_conjtrans_col_100_row_100)
681684

682685
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
683686
}
687+
#endif
684688

685689
/**
686690
* Test error function for an invalid param order.
@@ -815,4 +819,4 @@ CTEST(cimatcopy, xerbla_colmajor_trans_invalid_ldb)
815819
int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
816820
ASSERT_EQUAL(TRUE, passed);
817821
}
818-
#endif
822+
#endif

utest/test_extensions/test_comatcopy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static float check_comatcopy(char api, char order, char trans, blasint rows, bla
9999
BLASFUNC(comatcopy)(&order, &trans, &rows, &cols, alpha, data_comatcopy.a_test,
100100
&lda, data_comatcopy.b_test, &ldb);
101101
}
102+
#ifndef NO_CBLAS
102103
else {
103104
if (order == 'C') corder = CblasColMajor;
104105
if (order == 'R') corder = CblasRowMajor;
@@ -109,6 +110,7 @@ static float check_comatcopy(char api, char order, char trans, blasint rows, bla
109110
cblas_comatcopy(corder, ctrans, rows, cols, alpha, data_comatcopy.a_test,
110111
lda, data_comatcopy.b_test, ldb);
111112
}
113+
#endif
112114

113115
return smatrix_difference(data_comatcopy.b_test, data_comatcopy.b_verify, b_cols, b_rows, ldb*2);
114116
}
@@ -316,6 +318,7 @@ CTEST(comatcopy, rowmajor_conjtrans_col_100_row_100)
316318
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
317319
}
318320

321+
#ifndef NO_CBLAS
319322
/**
320323
* C API specific test
321324
* Test comatcopy by comparing it against refernce
@@ -491,6 +494,7 @@ CTEST(comatcopy, c_api_rowmajor_conjtrans_col_100_row_100)
491494

492495
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
493496
}
497+
#endif
494498

495499
/**
496500
* Test error function for an invalid param order.

utest/test_extensions/test_crot.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static float check_csrot(blasint n, blasint inc_x, blasint inc_y, float *c, floa
107107
return (norm / 2);
108108
}
109109

110+
#ifndef NO_CBLAS
110111
/**
111112
* C API specific function
112113
* Comapare results computed by csrot and caxpby
@@ -789,4 +790,5 @@ CTEST(crot, c_api_check_n_zero)
789790
float norm = c_api_check_csrot(n, inc_x, inc_y, c, s);
790791
ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
791792
}
792-
#endif
793+
#endif
794+
#endif

0 commit comments

Comments
 (0)