Make building the tests for individual data types conditional on the respective BUILD option
# If you want to enable the experimental BFLOAT16 support
# BUILD_HALF = 1
#
+# the below is not yet configurable, use cmake if you need to build only select types
+BUILD_SINGLE = 1
+BUILD_DOUBLE = 1
+BUILD_COMPLEX = 1
+BUILD_COMPLEX16 = 1
# End of user configuration
#
ifeq ($(C_COMPILER), GCC)
GCCVERSIONGTEQ4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 4)
GCCVERSIONGT4 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 4)
+GCCVERSIONEQ5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` = 5)
GCCVERSIONGT5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 5)
GCCVERSIONGTEQ7 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 7)
GCCVERSIONGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9)
ifeq ($(ARCH), zarch)
DYNAMIC_CORE = ZARCH_GENERIC
-# if the compiler accepts -march=arch11 or -march=z13 and can compile a file
-# with z13-specific inline assembly, then we can include support for Z13.
-# note: -march=z13 is equivalent to -march=arch11 yet some compiler releases
-# only support one or the other.
-# note: LLVM version 6.x supported -march=z13 yet could not handle vector
-# registers in inline assembly, so the check for supporting the -march flag is
-# not enough.
-ZARCH_TEST_COMPILE=-c $(TOPDIR)/kernel/zarch/damin_z13.c -I$(TOPDIR) -o /dev/null > /dev/null 2> /dev/null
-ZARCH_CC_SUPPORTS_ARCH11=$(shell $(CC) -march=arch11 $(ZARCH_TEST_COMPILE) && echo 1)
-ZARCH_CC_SUPPORTS_Z13=$(shell $(CC) -march=z13 $(ZARCH_TEST_COMPILE) && echo 1)
-
-ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH11), $(ZARCH_CC_SUPPORTS_Z13)), 1)
+# Z13 is supported since gcc-5.2, gcc-6, and in RHEL 7.3 and newer
+ifeq ($(GCCVERSIONGT5), 1)
+ ZARCH_SUPPORT_Z13 := 1
+else ifeq ($(GCCVERSIONEQ5), 1)
+ifeq ($(GCCMINORVERSIONGTEQ2), 1)
+ ZARCH_SUPPORT_Z13 := 1
+endif
+endif
+
+ifeq ($(wildcard /etc/redhat-release), /etc/redhat-release)
+ifeq ($(shell source /etc/os-release ; expr $$VERSION_ID \>= "7.3"), 1)
+ ZARCH_SUPPORT_Z13 := 1
+endif
+endif
+
+ifeq ($(ZARCH_SUPPORT_Z13), 1)
DYNAMIC_CORE += Z13
-CCOMMON_OPT += -DDYN_Z13
else
-$(info OpenBLAS: Not building Z13 kernels because the compiler $(CC) does not support it)
+$(info OpenBLAS: Not building Z13 kernels because gcc is older than 5.2 or 6.x)
endif
-# as above for z13, check for -march=arch12 and z14 support in the compiler.
-ZARCH_CC_SUPPORTS_ARCH12=$(shell $(CC) -march=arch12 $(ZARCH_TEST_COMPILE) && echo 1)
-ZARCH_CC_SUPPORTS_Z14=$(shell $(CC) -march=z14 $(ZARCH_TEST_COMPILE) && echo 1)
-ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH12), $(ZARCH_CC_SUPPORTS_Z14)), 1)
+ifeq ($(GCCVERSIONGTEQ7), 1)
DYNAMIC_CORE += Z14
-CCOMMON_OPT += -DDYN_Z14
else
-$(info OpenBLAS: Not building Z14 kernels because the compiler $(CC) does not support it)
+$(info OpenBLAS: Not building Z14 kernels because gcc is older than 7.x)
+endif
endif
-
-endif # ARCH zarch
ifeq ($(ARCH), power)
DYNAMIC_CORE = POWER6
ifeq ($(BUILD_HALF), 1)
CCOMMON_OPT += -DBUILD_HALF
endif
+ifeq ($(BUILD_SINGLE), 1)
+CCOMMON_OPT += -DBUILD_SINGLE
+endif
+ifeq ($(BUILD_DOUBLE), 1)
+CCOMMON_OPT += -DBUILD_DOUBLE
+endif
+ifeq ($(BUILD_COMPLEX), 1)
+CCOMMON_OPT += -DBUILD_COMPLEX
+endif
+ifeq ($(BUILD_COMPLEX16), 1)
+CCOMMON_OPT += -DBUILD_COMPLEX16
+endif
CCOMMON_OPT += -DVERSION=\"$(VERSION)\"
set(MAJOR_VERSION ${OpenBLAS_MAJOR_VERSION})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CCOMMON_OPT}")
+if (BUILD_SINGLE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_SINGLE")
+endif()
+if (BUILD_DOUBLE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_DOUBLE")
+endif()
+if (BUILD_COMPLEX)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_COMPLEX")
+endif()
+if (BUILD_COMPLEX16)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_COMPLEX16")
+endif()
if(NOT MSVC)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${CCOMMON_OPT}")
endif()
return;
}
-double F77_dzasum(const int *N, void *X, const int *incX)
-{
- return cblas_dzasum(*N, X, *incX);
-}
-
-double F77_dznrm2(const int *N, OPENBLAS_CONST void *X, const int *incX)
-{
- return cblas_dznrm2(*N, X, *incX);
-}
-
int F77_idamax(const int *N, OPENBLAS_CONST double *X, const int *incX)
{
if (*N < 1 || *incX < 1) return(0);
return;
}
-float F77_scasum(blasint *N, float *X, blasint *incX)
-{
- return cblas_scasum(*N, X, *incX);
-}
-
-float F77_scnrm2(blasint *N, OPENBLAS_CONST float *X, blasint *incX)
-{
- return cblas_scnrm2(*N, X, *incX);
-}
-
void F77_scopy(blasint *N, OPENBLAS_CONST float *X, blasint *incX,
float *Y, blasint *incY)
{
enable_language(Fortran)
-set(OpenBLAS_Tests
- sblat1 sblat2 sblat3
- dblat1 dblat2 dblat3
- cblat1 cblat2 cblat3
- zblat1 zblat2 zblat3)
+if (BUILD_SINGLE)
+ list( APPEND OpenBLAS_Tests sblat1 sblat2 sblat3)
+endif()
+if (BUILD_DOUBLE)
+ list (APPEND OpenBLAS_Tests dblat1 dblat2 dblat3)
+endif()
+if (BUILD_COMPLEX)
+ list (APPEND OpenBLAS_Tests cblat1 cblat2 cblat3)
+endif()
+if (BUILD_COMPLEX16)
+ list (APPEND OpenBLAS_Tests zblat1 zblat2 zblat3)
+endif()
foreach(test_bin ${OpenBLAS_Tests})
add_executable(${test_bin} ${test_bin}.f)
#include "openblas_utest.h"
+#ifdef BUILD_SINGLE
CTEST(amax, samax){
blasint N=3, inc=1;
float te_max=0.0, tr_max=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
}
-
+#endif
+#ifdef BUILD_DOUBLE
CTEST(amax, damax){
blasint N=3, inc=1;
double te_max=0.0, tr_max=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
}
+#endif
+
#include "openblas_utest.h"
+#ifdef BUILD_DOUBLE
CTEST(axpy,daxpy_inc_0)
{
blasint i;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_COMPLEX16
CTEST(axpy,zaxpy_inc_0)
{
blasint i;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_SINGLE
CTEST(axpy,saxpy_inc_0)
{
blasint i;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_COMPLEX
CTEST(axpy,caxpy_inc_0)
{
blasint i;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+
#include "openblas_utest.h"
+#ifdef BUILD_COMPLEX16
CTEST( zdotu,zdotu_n_1)
{
blasint N=1,incX=1,incY=1;
#endif
}
+#endif
+
#define ELEMENTS 50
#define INCREMENT 2
+#ifdef BUILD_SINGLE
CTEST(ismin, positive_step_2){
blasint i;
blasint N = ELEMENTS, inc = INCREMENT;
blasint index = BLASFUNC(ismax)(&N, x, &inc);
ASSERT_EQUAL(9, index);
}
+#endif
CTEST(kernel_regress,skx_avx)
{
+#ifdef BUILD_DOUBLE
double norm;
int i, j, info;
srand(0);
norm = cblas_dnrm2(DATASIZE*DATASIZE, X, 1);
ASSERT_DBL_NEAR_TOL(0.0, norm, 1e-10);
+#endif
}
**********************************************************************************/
#include "openblas_utest.h"
-
+#ifdef BUILD_SINGLE
CTEST(min, smin_negative){
blasint N=3, inc=1;
float te_min=0.0, tr_min=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
}
+#endif
+#ifdef BUILD_DOUBLE
CTEST(min, dmin_positive){
blasint N=3, inc=1;
double te_min=0.0, tr_min=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS);
}
+#endif
+#ifdef BUILD_SINGLE
CTEST(min, smin_zero){
blasint N=3, inc=1;
float te_min=0.0, tr_min=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
}
+#endif
+#ifdef BUILD_DOUBLE
CTEST(max, dmax_positive){
blasint N=3, inc=1;
double te_max=0.0, tr_max=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
}
-
+#endif
+#ifdef BUILD_SINGLE
CTEST(max, smax_zero){
blasint N=3, inc=1;
float te_max=0.0, tr_max=0.0;
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
}
+#endif
+
BLASINT*, complex double*, BLASINT*, BLASINT*);
*/
-
//https://github.com/xianyi/OpenBLAS/issues/695
CTEST(potrf, bug_695){
blasint n=10;
blasint info[1];
+#ifdef BUILD_COMPLEX
BLASFUNC(cpotrf)(&up, &n, (float*)(A1), &n, info);
//printf("%g+%g*I\n", creal(A1[91]), cimag(A1[91]));
+#endif
openblas_complex_double A2[100] =
{
};
char lo = 'L';
blasint nrhs = 2;
+#ifdef BUILD_COMPLEX16
BLASFUNC(zpotrs)(&lo, &n, &nrhs, (double*)(A2), &n, (double*)(B), &n, info);
-
+#endif
// note that this is exactly equal to A1
openblas_complex_float A3[100] =
{
openblas_make_complex_float(-0.9617417, -1.2486815),
openblas_make_complex_float(3.4629636, +0.0)
};
+#ifdef BUILD_COMPLEX
BLASFUNC(cpotrf)(&up, &n, (float*)(A3), &n, info);
// printf("%g+%g*I\n", creal(A3[91]), cimag(A3[91]));
if(isnan(CREAL(A3[91])) || isnan(CIMAG(A3[91]))) {
CTEST_ERR("%s:%d got NaN", __FILE__, __LINE__);
}
+#endif
}
-
// Check potrf factorizes a small problem correctly
CTEST(potrf, smoketest_trivial){
float A1s[4] = {2, 0.3, 0.3, 3};
uplo = 'U';
}
+#ifdef BUILD_SINGLE
BLASFUNC(scopy)(&nv, A1s, &inc, As, &inc);
+#endif
+#ifdef BUILD_DOUBLE
BLASFUNC(dcopy)(&nv, A1d, &inc, Ad, &inc);
+#endif
+#ifdef BUILD_COMPLEX
BLASFUNC(ccopy)(&nv, (float *)A1c, &inc, (float *)Ac, &inc);
+#endif
+#ifdef BUILD_COMPLEX16
BLASFUNC(zcopy)(&nv, (double *)A1z, &inc, (double *)Az, &inc);
+#endif
+#ifdef BUILD_SINGLE
BLASFUNC(spotrf)(&uplo, &n, As, &n, &info);
if (info != 0) {
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
}
-
+#endif
+#ifdef BUILD_DOUBLE
BLASFUNC(dpotrf)(&uplo, &n, Ad, &n, &info);
if (info != 0) {
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
}
-
+#endif
+#ifdef BUILD_COMPLEX
BLASFUNC(cpotrf)(&uplo, &n, (float *)Ac, &n, &info);
if (info != 0) {
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
}
-
+#endif
+#ifdef BUILD_COMPLEX16
BLASFUNC(zpotrf)(&uplo, &n, (double *)Az, &n, &info);
if (info != 0) {
CTEST_ERR("%s:%d info != 0", __FILE__, __LINE__);
}
-
+#endif
/* Fill the other triangle */
if (uplo == 'L') {
for (i = 0; i < n; ++i) {
trans1 = 'C';
trans2 = 'N';
}
-
+#ifdef BUILD_SINGLE
BLASFUNC(sgemm)(&trans1, &trans2, &n, &n, &n, &ones, As, &n, As, &n, &zeros, Bs, &n);
+#endif
+#ifdef BUILD_DOUBLE
BLASFUNC(dgemm)(&trans1, &trans2, &n, &n, &n, &oned, Ad, &n, Ad, &n, &zerod, Bd, &n);
+#endif
+#ifdef BUILD_COMPLEX
BLASFUNC(cgemm)(&trans1, &trans2, &n, &n, &n, (float *)&onec,
(float *)Ac, &n, (float *)Ac, &n, (float *)&zeroc, (float *)Bc, &n);
+#endif
+#ifdef BUILD_COMPLEX16
BLASFUNC(zgemm)(&trans1, &trans2, &n, &n, &n, (double *)&onez,
(double *)Az, &n, (double *)Az, &n, (double *)&zeroz, (double *)Bz, &n);
-
+#endif
/* Check result is close to original */
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
#include "openblas_utest.h"
+#ifdef BUILD_DOUBLE
CTEST(rot,drot_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_COMPLEX16
CTEST(rot,zdrot_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_SINGLE
CTEST(rot,srot_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
+#endif
+#ifdef BUILD_COMPLEX
CTEST(rot, csrot_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
+#endif
+
#include "openblas_utest.h"
+#ifdef BUILD_DOUBLE
CTEST (drotmg,rotmg)
{
double te_d1, tr_d1;
ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
}
}
+#endif
#include "openblas_utest.h"
+#ifdef BUILD_DOUBLE
CTEST(swap,dswap_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_COMPLEX16
CTEST(swap,zswap_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
+#endif
+#ifdef BUILD_SINGLE
CTEST(swap,sswap_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
+#endif
+#ifdef BUILD_COMPLEX
CTEST(swap,cswap_inc_0)
{
blasint i=0;
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
+#endif
+