Skip to content

Commit ce89398

Browse files
authored
Make tests for individual variable types conditional on the respective BUILD_ option
1 parent 593ce9e commit ce89398

File tree

8 files changed

+78
-12
lines changed

8 files changed

+78
-12
lines changed

utest/test_amax.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
#include "openblas_utest.h"
3535

36+
#ifdef BUILD_SINGLE
3637
CTEST(amax, samax){
3738
blasint N=3, inc=1;
3839
float te_max=0.0, tr_max=0.0;
@@ -43,7 +44,8 @@ CTEST(amax, samax){
4344

4445
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
4546
}
46-
47+
#endif
48+
#ifdef BUILD_DOUBLE
4749
CTEST(amax, damax){
4850
blasint N=3, inc=1;
4951
double te_max=0.0, tr_max=0.0;
@@ -54,3 +56,5 @@ CTEST(amax, damax){
5456

5557
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
5658
}
59+
#endif
60+

utest/test_axpy.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
#include "openblas_utest.h"
3535

36+
#ifdef BUILD_DOUBLE
3637
CTEST(axpy,daxpy_inc_0)
3738
{
3839
blasint i;
@@ -52,7 +53,9 @@ CTEST(axpy,daxpy_inc_0)
5253
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
5354
}
5455
}
56+
#endif
5557

58+
#ifdef BUILD_COMPLEX16
5659
CTEST(axpy,zaxpy_inc_0)
5760
{
5861
blasint i;
@@ -71,7 +74,9 @@ CTEST(axpy,zaxpy_inc_0)
7174
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
7275
}
7376
}
77+
#endif
7478

79+
#ifdef BUILD_SINGLE
7580
CTEST(axpy,saxpy_inc_0)
7681
{
7782
blasint i;
@@ -90,7 +95,9 @@ CTEST(axpy,saxpy_inc_0)
9095
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
9196
}
9297
}
98+
#endif
9399

100+
#ifdef BUILD_COMPLEX
94101
CTEST(axpy,caxpy_inc_0)
95102
{
96103
blasint i;
@@ -109,3 +116,5 @@ CTEST(axpy,caxpy_inc_0)
109116
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
110117
}
111118
}
119+
#endif
120+

utest/test_dotu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
#include "openblas_utest.h"
3535

36+
#ifdef BUILD_COMPLEX16
3637
CTEST( zdotu,zdotu_n_1)
3738
{
3839
blasint N=1,incX=1,incY=1;
@@ -80,3 +81,5 @@ CTEST(zdotu, zdotu_offset_1)
8081
#endif
8182

8283
}
84+
#endif
85+

utest/test_ismin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
#define ELEMENTS 50
3737
#define INCREMENT 2
3838

39+
#ifdef BUILD_SINGLE
3940
CTEST(ismin, positive_step_2){
4041
blasint i;
4142
blasint N = ELEMENTS, inc = INCREMENT;
@@ -87,3 +88,4 @@ CTEST(ismax, negative_step_2){
8788
blasint index = BLASFUNC(ismax)(&N, x, &inc);
8889
ASSERT_EQUAL(9, index);
8990
}
91+
#endif

utest/test_min.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
**********************************************************************************/
3333

3434
#include "openblas_utest.h"
35-
35+
#ifdef BUILD_SINGLE
3636
CTEST(min, smin_negative){
3737
blasint N=3, inc=1;
3838
float te_min=0.0, tr_min=0.0;
@@ -43,7 +43,9 @@ CTEST(min, smin_negative){
4343

4444
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
4545
}
46+
#endif
4647

48+
#ifdef BUILD_DOUBLE
4749
CTEST(min, dmin_positive){
4850
blasint N=3, inc=1;
4951
double te_min=0.0, tr_min=0.0;
@@ -54,7 +56,9 @@ CTEST(min, dmin_positive){
5456

5557
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS);
5658
}
59+
#endif
5760

61+
#ifdef BUILD_SINGLE
5862
CTEST(min, smin_zero){
5963
blasint N=3, inc=1;
6064
float te_min=0.0, tr_min=0.0;
@@ -76,7 +80,9 @@ CTEST(max, smax_negative){
7680

7781
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
7882
}
83+
#endif
7984

85+
#ifdef BUILD_DOUBLE
8086
CTEST(max, dmax_positive){
8187
blasint N=3, inc=1;
8288
double te_max=0.0, tr_max=0.0;
@@ -87,7 +93,8 @@ CTEST(max, dmax_positive){
8793

8894
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
8995
}
90-
96+
#endif
97+
#ifdef BUILD_SINGLE
9198
CTEST(max, smax_zero){
9299
blasint N=3, inc=1;
93100
float te_max=0.0, tr_max=0.0;
@@ -98,3 +105,5 @@ CTEST(max, smax_zero){
98105

99106
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
100107
}
108+
#endif
109+

utest/test_potrs.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ void BLASFUNC(zpotrs_(char*, BLASINT*, BLASINT*, complex double*,
3939
BLASINT*, complex double*, BLASINT*, BLASINT*);
4040
*/
4141

42-
4342
//https://github.com/xianyi/OpenBLAS/issues/695
4443
CTEST(potrf, bug_695){
4544

45+
#ifdef BUILD_COMPLEX
4646
openblas_complex_float A1[100] =
4747
{
4848
openblas_make_complex_float(5.8525753, +0.0),
@@ -153,7 +153,9 @@ CTEST(potrf, bug_695){
153153
blasint info[1];
154154
BLASFUNC(cpotrf)(&up, &n, (float*)(A1), &n, info);
155155
//printf("%g+%g*I\n", creal(A1[91]), cimag(A1[91]));
156+
#endif
156157

158+
#ifdef BUILD_COMPLEX16
157159
openblas_complex_double A2[100] =
158160
{
159161
openblas_make_complex_double(3.0607147216796875, +0.0),
@@ -283,7 +285,8 @@ CTEST(potrf, bug_695){
283285
char lo = 'L';
284286
blasint nrhs = 2;
285287
BLASFUNC(zpotrs)(&lo, &n, &nrhs, (double*)(A2), &n, (double*)(B), &n, info);
286-
288+
#endif
289+
#ifdef BUILD_COMPLEX
287290
// note that this is exactly equal to A1
288291
openblas_complex_float A3[100] =
289292
{
@@ -393,9 +396,9 @@ CTEST(potrf, bug_695){
393396
if(isnan(CREAL(A3[91])) || isnan(CIMAG(A3[91]))) {
394397
CTEST_ERR("%s:%d got NaN", __FILE__, __LINE__);
395398
}
399+
#endif
396400
}
397401

398-
399402
// Check potrf factorizes a small problem correctly
400403
CTEST(potrf, smoketest_trivial){
401404
float A1s[4] = {2, 0.3, 0.3, 3};
@@ -439,31 +442,43 @@ CTEST(potrf, smoketest_trivial){
439442
uplo = 'U';
440443
}
441444

445+
#ifdef BUILD_SINGLE
442446
BLASFUNC(scopy)(&nv, A1s, &inc, As, &inc);
447+
#endif
448+
#ifdef BUILD_DOUBLE
443449
BLASFUNC(dcopy)(&nv, A1d, &inc, Ad, &inc);
450+
#endif
451+
#ifdef BUILD_COMPLEX
444452
BLASFUNC(ccopy)(&nv, (float *)A1c, &inc, (float *)Ac, &inc);
453+
#endif
454+
#ifdef BUILD_COMPLEX16
445455
BLASFUNC(zcopy)(&nv, (double *)A1z, &inc, (double *)Az, &inc);
456+
#endif
446457

458+
#ifdef BUILD_SINGLE
447459
BLASFUNC(spotrf)(&uplo, &n, As, &n, &info);
448460
if (info != 0) {
449461
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
450462
}
451-
463+
#endif
464+
#ifdef BUILD_DOUBLE
452465
BLASFUNC(dpotrf)(&uplo, &n, Ad, &n, &info);
453466
if (info != 0) {
454467
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
455468
}
456-
469+
#endif
470+
#ifdef BUILD_COMPLEX
457471
BLASFUNC(cpotrf)(&uplo, &n, (float *)Ac, &n, &info);
458472
if (info != 0) {
459473
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
460474
}
461-
475+
#endif
476+
#ifdef BUILD_COMPLEX16
462477
BLASFUNC(zpotrf)(&uplo, &n, (double *)Az, &n, &info);
463478
if (info != 0) {
464479
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
465480
}
466-
481+
#endif
467482
/* Fill the other triangle */
468483
if (uplo == 'L') {
469484
for (i = 0; i < n; ++i) {
@@ -495,14 +510,20 @@ CTEST(potrf, smoketest_trivial){
495510
trans1 = 'C';
496511
trans2 = 'N';
497512
}
498-
513+
#ifdef BUILD_SINGLE
499514
BLASFUNC(sgemm)(&trans1, &trans2, &n, &n, &n, &ones, As, &n, As, &n, &zeros, Bs, &n);
515+
#endif
516+
#ifdef BUILD_DOUBLE
500517
BLASFUNC(dgemm)(&trans1, &trans2, &n, &n, &n, &oned, Ad, &n, Ad, &n, &zerod, Bd, &n);
518+
#endif
519+
#ifdef BUILD_COMPLEX
501520
BLASFUNC(cgemm)(&trans1, &trans2, &n, &n, &n, (float *)&onec,
502521
(float *)Ac, &n, (float *)Ac, &n, (float *)&zeroc, (float *)Bc, &n);
522+
#endif
523+
#ifdef BUILD_COMPLEX16
503524
BLASFUNC(zgemm)(&trans1, &trans2, &n, &n, &n, (double *)&onez,
504525
(double *)Az, &n, (double *)Az, &n, (double *)&zeroz, (double *)Bz, &n);
505-
526+
#endif
506527
/* Check result is close to original */
507528
for (i = 0; i < n; ++i) {
508529
for (j = 0; j < n; ++j) {

utest/test_rot.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
#include "openblas_utest.h"
3535

36+
#ifdef BUILD_DOUBLE
3637
CTEST(rot,drot_inc_0)
3738
{
3839
blasint i=0;
@@ -52,7 +53,9 @@ CTEST(rot,drot_inc_0)
5253
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
5354
}
5455
}
56+
#endif
5557

58+
#ifdef BUILD_COMPLEX16
5659
CTEST(rot,zdrot_inc_0)
5760
{
5861
blasint i=0;
@@ -72,7 +75,9 @@ CTEST(rot,zdrot_inc_0)
7275
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
7376
}
7477
}
78+
#endif
7579

80+
#ifdef BUILD_SINGLE
7681
CTEST(rot,srot_inc_0)
7782
{
7883
blasint i=0;
@@ -91,7 +96,9 @@ CTEST(rot,srot_inc_0)
9196
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
9297
}
9398
}
99+
#endif
94100

101+
#ifdef BUILD_COMPLEX
95102
CTEST(rot, csrot_inc_0)
96103
{
97104
blasint i=0;
@@ -110,3 +117,5 @@ CTEST(rot, csrot_inc_0)
110117
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
111118
}
112119
}
120+
#endif
121+

utest/test_swap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
#include "openblas_utest.h"
3535

36+
#ifdef BUILD_DOUBLE
3637
CTEST(swap,dswap_inc_0)
3738
{
3839
blasint i=0;
@@ -50,7 +51,9 @@ CTEST(swap,dswap_inc_0)
5051
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
5152
}
5253
}
54+
#endif
5355

56+
#ifdef BUILD_COMPLEX16
5457
CTEST(swap,zswap_inc_0)
5558
{
5659
blasint i=0;
@@ -68,7 +71,9 @@ CTEST(swap,zswap_inc_0)
6871
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
6972
}
7073
}
74+
#endif
7175

76+
#ifdef BUILD_SINGLE
7277
CTEST(swap,sswap_inc_0)
7378
{
7479
blasint i=0;
@@ -86,7 +91,9 @@ CTEST(swap,sswap_inc_0)
8691
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
8792
}
8893
}
94+
#endif
8995

96+
#ifdef BUILD_COMPLEX
9097
CTEST(swap,cswap_inc_0)
9198
{
9299
blasint i=0;
@@ -104,3 +111,5 @@ CTEST(swap,cswap_inc_0)
104111
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
105112
}
106113
}
114+
#endif
115+

0 commit comments

Comments
 (0)