Merge pull request #2833 from martin-frbg/issue2830

Make building the tests for individual data types conditional on the respective BUILD option
This commit is contained in:
Martin Kroeker 2020-09-14 07:24:23 +02:00 committed by GitHub
commit 1ee1e7b495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 143 additions and 58 deletions

View File

@ -277,5 +277,10 @@ COMMON_PROF = -pg
# 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
#

View File

@ -295,6 +295,7 @@ endif
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)
@ -593,35 +594,33 @@ endif
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)
# 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 ($(or $(ZARCH_CC_SUPPORTS_ARCH11), $(ZARCH_CC_SUPPORTS_Z13)), 1)
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
@ -1223,6 +1222,18 @@ endif
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)\"

View File

@ -393,6 +393,18 @@ set(REVISION "-r${OpenBLAS_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()

View File

@ -74,16 +74,6 @@ void F77_dswap( const int *N, double *X, const int *incX,
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);

View File

@ -21,16 +21,6 @@ void F77_saxpy(blasint *N, const float *alpha, OPENBLAS_CONST float *X,
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)
{

View File

@ -3,11 +3,18 @@ include_directories(${PROJECT_BINARY_DIR})
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)

View File

@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "openblas_utest.h"
#ifdef BUILD_SINGLE
CTEST(amax, samax){
blasint N=3, inc=1;
float te_max=0.0, tr_max=0.0;
@ -43,7 +44,8 @@ CTEST(amax, samax){
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;
@ -54,3 +56,5 @@ CTEST(amax, damax){
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
}
#endif

View File

@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "openblas_utest.h"
#ifdef BUILD_DOUBLE
CTEST(axpy,daxpy_inc_0)
{
blasint i;
@ -52,7 +53,9 @@ CTEST(axpy,daxpy_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_COMPLEX16
CTEST(axpy,zaxpy_inc_0)
{
blasint i;
@ -71,7 +74,9 @@ CTEST(axpy,zaxpy_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_SINGLE
CTEST(axpy,saxpy_inc_0)
{
blasint i;
@ -90,7 +95,9 @@ CTEST(axpy,saxpy_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_COMPLEX
CTEST(axpy,caxpy_inc_0)
{
blasint i;
@ -109,3 +116,5 @@ CTEST(axpy,caxpy_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif

View File

@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "openblas_utest.h"
#ifdef BUILD_COMPLEX16
CTEST( zdotu,zdotu_n_1)
{
blasint N=1,incX=1,incY=1;
@ -80,3 +81,5 @@ CTEST(zdotu, zdotu_offset_1)
#endif
}
#endif

View File

@ -36,6 +36,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define ELEMENTS 50
#define INCREMENT 2
#ifdef BUILD_SINGLE
CTEST(ismin, positive_step_2){
blasint i;
blasint N = ELEMENTS, inc = INCREMENT;
@ -87,3 +88,4 @@ CTEST(ismax, negative_step_2){
blasint index = BLASFUNC(ismax)(&N, x, &inc);
ASSERT_EQUAL(9, index);
}
#endif

View File

@ -22,6 +22,7 @@ double m[DATASIZE*DATASIZE];
CTEST(kernel_regress,skx_avx)
{
#ifdef BUILD_DOUBLE
double norm;
int i, j, info;
srand(0);
@ -47,4 +48,5 @@ CTEST(kernel_regress,skx_avx)
norm = cblas_dnrm2(DATASIZE*DATASIZE, X, 1);
ASSERT_DBL_NEAR_TOL(0.0, norm, 1e-10);
#endif
}

View File

@ -32,7 +32,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#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;
@ -43,7 +43,9 @@ CTEST(min, smin_negative){
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;
@ -54,7 +56,9 @@ CTEST(min, dmin_positive){
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;
@ -76,7 +80,9 @@ CTEST(max, smax_negative){
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;
@ -87,7 +93,8 @@ CTEST(max, dmax_positive){
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;
@ -98,3 +105,5 @@ CTEST(max, smax_zero){
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
}
#endif

View File

@ -39,7 +39,6 @@ void BLASFUNC(zpotrs_(char*, BLASINT*, BLASINT*, complex double*,
BLASINT*, complex double*, BLASINT*, BLASINT*);
*/
//https://github.com/xianyi/OpenBLAS/issues/695
CTEST(potrf, bug_695){
@ -151,8 +150,10 @@ 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] =
{
@ -282,8 +283,9 @@ CTEST(potrf, bug_695){
};
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] =
{
@ -388,14 +390,15 @@ CTEST(potrf, bug_695){
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};
@ -439,31 +442,43 @@ CTEST(potrf, smoketest_trivial){
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) {
@ -495,14 +510,20 @@ CTEST(potrf, smoketest_trivial){
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) {

View File

@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "openblas_utest.h"
#ifdef BUILD_DOUBLE
CTEST(rot,drot_inc_0)
{
blasint i=0;
@ -52,7 +53,9 @@ CTEST(rot,drot_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_COMPLEX16
CTEST(rot,zdrot_inc_0)
{
blasint i=0;
@ -72,7 +75,9 @@ CTEST(rot,zdrot_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_SINGLE
CTEST(rot,srot_inc_0)
{
blasint i=0;
@ -91,7 +96,9 @@ CTEST(rot,srot_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
#endif
#ifdef BUILD_COMPLEX
CTEST(rot, csrot_inc_0)
{
blasint i=0;
@ -110,3 +117,5 @@ CTEST(rot, csrot_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
#endif

View File

@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "openblas_utest.h"
#ifdef BUILD_DOUBLE
CTEST (drotmg,rotmg)
{
double te_d1, tr_d1;
@ -204,3 +205,4 @@ CTEST(drotmg, drotmg_D1_big_D2_big_flag_zero)
ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
}
}
#endif

View File

@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "openblas_utest.h"
#ifdef BUILD_DOUBLE
CTEST(swap,dswap_inc_0)
{
blasint i=0;
@ -50,7 +51,9 @@ CTEST(swap,dswap_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_COMPLEX16
CTEST(swap,zswap_inc_0)
{
blasint i=0;
@ -68,7 +71,9 @@ CTEST(swap,zswap_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
}
}
#endif
#ifdef BUILD_SINGLE
CTEST(swap,sswap_inc_0)
{
blasint i=0;
@ -86,7 +91,9 @@ CTEST(swap,sswap_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
#endif
#ifdef BUILD_COMPLEX
CTEST(swap,cswap_inc_0)
{
blasint i=0;
@ -104,3 +111,5 @@ CTEST(swap,cswap_inc_0)
ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
}
}
#endif