Skip to content

Commit 1ee1e7b

Browse files
authored
Merge pull request #2833 from martin-frbg/issue2830
Make building the tests for individual data types conditional on the respective BUILD option
2 parents 6b52c7e + ba64437 commit 1ee1e7b

16 files changed

+144
-59
lines changed

Makefile.rule

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,10 @@ COMMON_PROF = -pg
277277
# If you want to enable the experimental BFLOAT16 support
278278
# BUILD_HALF = 1
279279
#
280+
# the below is not yet configurable, use cmake if you need to build only select types
281+
BUILD_SINGLE = 1
282+
BUILD_DOUBLE = 1
283+
BUILD_COMPLEX = 1
284+
BUILD_COMPLEX16 = 1
280285
# End of user configuration
281286
#

Makefile.system

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ endif
295295
ifeq ($(C_COMPILER), GCC)
296296
GCCVERSIONGTEQ4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 4)
297297
GCCVERSIONGT4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 4)
298+
GCCVERSIONEQ5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` = 5)
298299
GCCVERSIONGT5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 5)
299300
GCCVERSIONGTEQ7 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 7)
300301
GCCVERSIONGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9)
@@ -593,35 +594,33 @@ endif
593594
ifeq ($(ARCH), zarch)
594595
DYNAMIC_CORE = ZARCH_GENERIC
595596

596-
# if the compiler accepts -march=arch11 or -march=z13 and can compile a file
597-
# with z13-specific inline assembly, then we can include support for Z13.
598-
# note: -march=z13 is equivalent to -march=arch11 yet some compiler releases
599-
# only support one or the other.
600-
# note: LLVM version 6.x supported -march=z13 yet could not handle vector
601-
# registers in inline assembly, so the check for supporting the -march flag is
602-
# not enough.
603-
ZARCH_TEST_COMPILE=-c $(TOPDIR)/kernel/zarch/damin_z13.c -I$(TOPDIR) -o /dev/null > /dev/null 2> /dev/null
604-
ZARCH_CC_SUPPORTS_ARCH11=$(shell $(CC) -march=arch11 $(ZARCH_TEST_COMPILE) && echo 1)
605-
ZARCH_CC_SUPPORTS_Z13=$(shell $(CC) -march=z13 $(ZARCH_TEST_COMPILE) && echo 1)
606-
607-
ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH11), $(ZARCH_CC_SUPPORTS_Z13)), 1)
597+
# Z13 is supported since gcc-5.2, gcc-6, and in RHEL 7.3 and newer
598+
ifeq ($(GCCVERSIONGT5), 1)
599+
ZARCH_SUPPORT_Z13 := 1
600+
else ifeq ($(GCCVERSIONEQ5), 1)
601+
ifeq ($(GCCMINORVERSIONGTEQ2), 1)
602+
ZARCH_SUPPORT_Z13 := 1
603+
endif
604+
endif
605+
606+
ifeq ($(wildcard /etc/redhat-release), /etc/redhat-release)
607+
ifeq ($(shell source /etc/os-release ; expr $$VERSION_ID \>= "7.3"), 1)
608+
ZARCH_SUPPORT_Z13 := 1
609+
endif
610+
endif
611+
612+
ifeq ($(ZARCH_SUPPORT_Z13), 1)
608613
DYNAMIC_CORE += Z13
609-
CCOMMON_OPT += -DDYN_Z13
610614
else
611-
$(info OpenBLAS: Not building Z13 kernels because the compiler $(CC) does not support it)
615+
$(info OpenBLAS: Not building Z13 kernels because gcc is older than 5.2 or 6.x)
612616
endif
613617

614-
# as above for z13, check for -march=arch12 and z14 support in the compiler.
615-
ZARCH_CC_SUPPORTS_ARCH12=$(shell $(CC) -march=arch12 $(ZARCH_TEST_COMPILE) && echo 1)
616-
ZARCH_CC_SUPPORTS_Z14=$(shell $(CC) -march=z14 $(ZARCH_TEST_COMPILE) && echo 1)
617-
ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH12), $(ZARCH_CC_SUPPORTS_Z14)), 1)
618+
ifeq ($(GCCVERSIONGTEQ7), 1)
618619
DYNAMIC_CORE += Z14
619-
CCOMMON_OPT += -DDYN_Z14
620620
else
621-
$(info OpenBLAS: Not building Z14 kernels because the compiler $(CC) does not support it)
621+
$(info OpenBLAS: Not building Z14 kernels because gcc is older than 7.x)
622+
endif
622623
endif
623-
624-
endif # ARCH zarch
625624

626625
ifeq ($(ARCH), power)
627626
DYNAMIC_CORE = POWER6
@@ -1223,6 +1222,18 @@ endif
12231222
ifeq ($(BUILD_HALF), 1)
12241223
CCOMMON_OPT += -DBUILD_HALF
12251224
endif
1225+
ifeq ($(BUILD_SINGLE), 1)
1226+
CCOMMON_OPT += -DBUILD_SINGLE
1227+
endif
1228+
ifeq ($(BUILD_DOUBLE), 1)
1229+
CCOMMON_OPT += -DBUILD_DOUBLE
1230+
endif
1231+
ifeq ($(BUILD_COMPLEX), 1)
1232+
CCOMMON_OPT += -DBUILD_COMPLEX
1233+
endif
1234+
ifeq ($(BUILD_COMPLEX16), 1)
1235+
CCOMMON_OPT += -DBUILD_COMPLEX16
1236+
endif
12261237

12271238
CCOMMON_OPT += -DVERSION=\"$(VERSION)\"
12281239

cmake/system.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,18 @@ set(REVISION "-r${OpenBLAS_VERSION}")
393393
set(MAJOR_VERSION ${OpenBLAS_MAJOR_VERSION})
394394

395395
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CCOMMON_OPT}")
396+
if (BUILD_SINGLE)
397+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_SINGLE")
398+
endif()
399+
if (BUILD_DOUBLE)
400+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_DOUBLE")
401+
endif()
402+
if (BUILD_COMPLEX)
403+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_COMPLEX")
404+
endif()
405+
if (BUILD_COMPLEX16)
406+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_COMPLEX16")
407+
endif()
396408
if(NOT MSVC)
397409
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${CCOMMON_OPT}")
398410
endif()

ctest/c_dblas1.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ void F77_dswap( const int *N, double *X, const int *incX,
7474
return;
7575
}
7676

77-
double F77_dzasum(const int *N, void *X, const int *incX)
78-
{
79-
return cblas_dzasum(*N, X, *incX);
80-
}
81-
82-
double F77_dznrm2(const int *N, OPENBLAS_CONST void *X, const int *incX)
83-
{
84-
return cblas_dznrm2(*N, X, *incX);
85-
}
86-
8777
int F77_idamax(const int *N, OPENBLAS_CONST double *X, const int *incX)
8878
{
8979
if (*N < 1 || *incX < 1) return(0);

ctest/c_sblas1.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ void F77_saxpy(blasint *N, const float *alpha, OPENBLAS_CONST float *X,
2121
return;
2222
}
2323

24-
float F77_scasum(blasint *N, float *X, blasint *incX)
25-
{
26-
return cblas_scasum(*N, X, *incX);
27-
}
28-
29-
float F77_scnrm2(blasint *N, OPENBLAS_CONST float *X, blasint *incX)
30-
{
31-
return cblas_scnrm2(*N, X, *incX);
32-
}
33-
3424
void F77_scopy(blasint *N, OPENBLAS_CONST float *X, blasint *incX,
3525
float *Y, blasint *incY)
3626
{

test/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ include_directories(${PROJECT_BINARY_DIR})
33

44
enable_language(Fortran)
55

6-
set(OpenBLAS_Tests
7-
sblat1 sblat2 sblat3
8-
dblat1 dblat2 dblat3
9-
cblat1 cblat2 cblat3
10-
zblat1 zblat2 zblat3)
6+
if (BUILD_SINGLE)
7+
list( APPEND OpenBLAS_Tests sblat1 sblat2 sblat3)
8+
endif()
9+
if (BUILD_DOUBLE)
10+
list (APPEND OpenBLAS_Tests dblat1 dblat2 dblat3)
11+
endif()
12+
if (BUILD_COMPLEX)
13+
list (APPEND OpenBLAS_Tests cblat1 cblat2 cblat3)
14+
endif()
15+
if (BUILD_COMPLEX16)
16+
list (APPEND OpenBLAS_Tests zblat1 zblat2 zblat3)
17+
endif()
1118

1219
foreach(test_bin ${OpenBLAS_Tests})
1320
add_executable(${test_bin} ${test_bin}.f)

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

0 commit comments

Comments
 (0)