Skip to content

Tests for BLAS-like and BLAS API #4499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ config_last.h
getarch
getarch_2nd
utest/openblas_utest
utest/openblas_utest_ext
ctest/xccblat1
ctest/xccblat2
ctest/xccblat3
Expand Down
4 changes: 2 additions & 2 deletions interface/geadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ void CNAME(enum CBLAS_ORDER order,

if (ldc < MAX(1, m)) info = 8;
if (lda < MAX(1, m)) info = 5;
if (n < 0) info = 2;
if (m < 0) info = 1;
if (n < 0) info = 1;
if (m < 0) info = 2;
}

if (info >= 0) {
Expand Down
20 changes: 20 additions & 0 deletions interface/max.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@

#ifdef USE_ABS

#if defined(DOUBLE)
#define ABS fabs
#else
#define ABS fabsf
#endif

#ifndef USE_MIN

/* ABS & MAX */
Expand Down Expand Up @@ -92,6 +98,8 @@

#else

#define ABS

#ifndef USE_MIN

/* MAX */
Expand Down Expand Up @@ -130,6 +138,12 @@ FLOATRET NAME(blasint *N, FLOAT *x, blasint *INCX){

if (n <= 0) return 0;

#ifndef COMPLEX
if (incx == 0) return (ABS(*x));
#else
if (incx == 0) return (ABS(*x) + ABS(*(x+1)));
#endif

IDEBUG_START;

FUNCTION_PROFILE_START();
Expand Down Expand Up @@ -158,6 +172,12 @@ FLOAT CNAME(blasint n, FLOAT *x, blasint incx){

if (n <= 0) return 0;

#ifndef COMPLEX
if (incx == 0) return (ABS(*x));
#else
if (incx == 0) return (ABS(*x) + ABS(*(x+1)));
#endif

IDEBUG_START;

FUNCTION_PROFILE_START();
Expand Down
6 changes: 3 additions & 3 deletions interface/zgeadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void NAME(blasint *M, blasint *N, FLOAT *ALPHA, FLOAT *a, blasint *LDA,
info = 0;


if (lda < MAX(1, m)) info = 6;
if (lda < MAX(1, m)) info = 5;
if (ldc < MAX(1, m)) info = 8;

if (n < 0) info = 2;
Expand Down Expand Up @@ -115,8 +115,8 @@ void CNAME(enum CBLAS_ORDER order,

if (ldc < MAX(1, m)) info = 8;
if (lda < MAX(1, m)) info = 5;
if (n < 0) info = 2;
if (m < 0) info = 1;
if (n < 0) info = 1;
if (m < 0) info = 2;
}

if (info >= 0) {
Expand Down
4 changes: 2 additions & 2 deletions interface/zrotg.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void CNAME(void *VDA, void *VDB, FLOAT *C, void *VS) {
if (ada >= h *safmin) {
*C = sqrt(ada/h);
*R = *DA / *C;
*(R+1) = *(DA+1) / *(C+1);
*(R+1) = *(DA+1) / *C;
rtmax *= 2.;
if ( ada > rtmin && h < rtmax) { // no risk of intermediate overflow
*S = *S1 * (*DA / adahsq) - *(S1+1)* (*(DA+1)/adahsq);
Expand All @@ -115,7 +115,7 @@ void CNAME(void *VDA, void *VDB, FLOAT *C, void *VS) {
*C = ada / adahsq;
if (*C >= safmin) {
*R = *DA / *C;
*(R+1) = *(DA+1) / *(C+1);
*(R+1) = *(DA+1) / *C;
} else {
*R = *DA * (h / adahsq);
*(R+1) = *(DA+1) * (h / adahsq);
Expand Down
76 changes: 76 additions & 0 deletions utest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,70 @@ else ()
)
endif ()


set(DIR_EXT test_extensions)
set(OpenBLAS_utest_ext_src
utest_main.c
${DIR_EXT}/common.c
${DIR_EXT}/xerbla.c
${DIR_EXT}/test_isamin.c
${DIR_EXT}/test_idamin.c
${DIR_EXT}/test_icamin.c
${DIR_EXT}/test_izamin.c
${DIR_EXT}/test_ssum.c
${DIR_EXT}/test_dsum.c
${DIR_EXT}/test_scsum.c
${DIR_EXT}/test_dzsum.c
${DIR_EXT}/test_samin.c
${DIR_EXT}/test_damin.c
${DIR_EXT}/test_scamin.c
${DIR_EXT}/test_dzamin.c
${DIR_EXT}/test_scamax.c
${DIR_EXT}/test_dzamax.c
${DIR_EXT}/test_zrotg.c
${DIR_EXT}/test_crotg.c
${DIR_EXT}/test_drotmg.c
${DIR_EXT}/test_srotmg.c
${DIR_EXT}/test_zscal.c
${DIR_EXT}/test_cscal.c
${DIR_EXT}/test_domatcopy.c
${DIR_EXT}/test_somatcopy.c
${DIR_EXT}/test_zomatcopy.c
${DIR_EXT}/test_comatcopy.c
${DIR_EXT}/test_simatcopy.c
${DIR_EXT}/test_dimatcopy.c
${DIR_EXT}/test_cimatcopy.c
${DIR_EXT}/test_zimatcopy.c
${DIR_EXT}/test_sgeadd.c
${DIR_EXT}/test_dgeadd.c
${DIR_EXT}/test_cgeadd.c
${DIR_EXT}/test_zgeadd.c
${DIR_EXT}/test_saxpby.c
${DIR_EXT}/test_daxpby.c
${DIR_EXT}/test_caxpby.c
${DIR_EXT}/test_zaxpby.c
${DIR_EXT}/test_caxpyc.c
${DIR_EXT}/test_zaxpyc.c
${DIR_EXT}/test_cgemv_t.c
${DIR_EXT}/test_zgemv_t.c
${DIR_EXT}/test_cgemv_n.c
${DIR_EXT}/test_zgemv_n.c
${DIR_EXT}/test_crot.c
${DIR_EXT}/test_zrot.c
${DIR_EXT}/test_cgbmv.c
${DIR_EXT}/test_zgbmv.c
${DIR_EXT}/test_dgemmt.c
${DIR_EXT}/test_sgemmt.c
${DIR_EXT}/test_cgemmt.c
${DIR_EXT}/test_zgemmt.c
${DIR_EXT}/test_ztrmv.c
${DIR_EXT}/test_ctrmv.c
${DIR_EXT}/test_ztrsv.c
${DIR_EXT}/test_ctrsv.c
${DIR_EXT}/test_zgemm.c
${DIR_EXT}/test_cgemm.c
)

# crashing on travis cl with an error code suggesting resource not found
if (NOT MSVC)
set(OpenBLAS_utest_src
Expand Down Expand Up @@ -49,6 +113,13 @@ set(OpenBLAS_utest_src
${OpenBLAS_utest_src}
test_potrs.c
)
set(OpenBLAS_utest_ext_src
${OpenBLAS_utest_ext_src}
${DIR_EXT}/test_cspmv.c
${DIR_EXT}/test_zspmv.c
${DIR_EXT}/test_csbmv.c
${DIR_EXT}/test_zsbmv.c
)
if (NOT NO_CBLAS AND NOT NO_LAPACKE)
set(OpenBLAS_utest_src
${OpenBLAS_utest_src}
Expand All @@ -60,7 +131,11 @@ endif()
set(OpenBLAS_utest_bin openblas_utest)
add_executable(${OpenBLAS_utest_bin} ${OpenBLAS_utest_src})

set(OpenBLAS_utest_ext_bin openblas_utest_ext)
add_executable(${OpenBLAS_utest_ext_bin} ${OpenBLAS_utest_ext_src})

target_link_libraries(${OpenBLAS_utest_bin} ${OpenBLAS_LIBNAME})
target_link_libraries(${OpenBLAS_utest_ext_bin} ${OpenBLAS_LIBNAME})

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX" )
target_link_libraries(${OpenBLAS_utest_bin} m)
Expand All @@ -85,3 +160,4 @@ add_custom_command(TARGET ${OpenBLAS_utest_bin}
endif()

add_test(${OpenBLAS_utest_bin} ${CMAKE_CURRENT_BINARY_DIR}/${OpenBLAS_utest_bin})
add_test(${OpenBLAS_utest_ext_bin} ${CMAKE_CURRENT_BINARY_DIR}/${OpenBLAS_utest_bin})
30 changes: 26 additions & 4 deletions utest/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
UTEST_CHECK = 1
TOPDIR = ..
DIR_EXT=test_extensions

override TARGET_ARCH=
override TARGET_MACH=

UTESTBIN=openblas_utest
UTESTEXTBIN=openblas_utest_ext

.PHONY : all
.NOTPARALLEL : all run_test $(UTESTBIN)
.NOTPARALLEL : all run_test $(UTESTBIN) $(UTESTEXTBIN)

include $(TOPDIR)/Makefile.system

OBJS=utest_main.o test_min.o test_amax.o test_ismin.o test_rotmg.o test_axpy.o test_dotu.o test_dsdot.o test_swap.o test_rot.o test_dnrm2.o test_zscal.o \
test_amin.o test_axpby.o
#test_rot.o test_swap.o test_axpy.o test_dotu.o test_dsdot.o test_fork.o
OBJS_EXT=utest_main.o $(DIR_EXT)/xerbla.o $(DIR_EXT)/common.o
OBJS_EXT+=$(DIR_EXT)/test_isamin.o $(DIR_EXT)/test_idamin.o $(DIR_EXT)/test_icamin.o $(DIR_EXT)/test_izamin.o
OBJS_EXT+=$(DIR_EXT)/test_ssum.o $(DIR_EXT)/test_dsum.o $(DIR_EXT)/test_scsum.o $(DIR_EXT)/test_dzsum.o
OBJS_EXT+=$(DIR_EXT)/test_saxpby.o $(DIR_EXT)/test_daxpby.o $(DIR_EXT)/test_caxpby.o $(DIR_EXT)/test_zaxpby.o $(DIR_EXT)/test_zaxpyc.o $(DIR_EXT)/test_caxpyc.o
OBJS_EXT+=$(DIR_EXT)/test_samin.o $(DIR_EXT)/test_damin.o $(DIR_EXT)/test_scamin.o $(DIR_EXT)/test_dzamin.o $(DIR_EXT)/test_scamax.o $(DIR_EXT)/test_dzamax.o
OBJS_EXT+=$(DIR_EXT)/test_drotmg.o $(DIR_EXT)/test_srotmg.o $(DIR_EXT)/test_zrotg.o $(DIR_EXT)/test_crotg.o $(DIR_EXT)/test_crot.o $(DIR_EXT)/test_zrot.o
OBJS_EXT+=$(DIR_EXT)/test_zscal.o $(DIR_EXT)/test_cscal.o
OBJS_EXT+=$(DIR_EXT)/test_domatcopy.o $(DIR_EXT)/test_somatcopy.o $(DIR_EXT)/test_zomatcopy.o $(DIR_EXT)/test_comatcopy.o
OBJS_EXT+=$(DIR_EXT)/test_simatcopy.o $(DIR_EXT)/test_dimatcopy.o $(DIR_EXT)/test_cimatcopy.o $(DIR_EXT)/test_zimatcopy.o
OBJS_EXT+=$(DIR_EXT)/test_sgeadd.o $(DIR_EXT)/test_dgeadd.o $(DIR_EXT)/test_cgeadd.o $(DIR_EXT)/test_zgeadd.o
OBJS_EXT+=$(DIR_EXT)/test_cgemv_t.o $(DIR_EXT)/test_zgemv_t.o $(DIR_EXT)/test_cgemv_n.o $(DIR_EXT)/test_zgemv_n.o
OBJS_EXT+=$(DIR_EXT)/test_sgemmt.o $(DIR_EXT)/test_dgemmt.o $(DIR_EXT)/test_cgemmt.o $(DIR_EXT)/test_zgemmt.o
OBJS_EXT+=$(DIR_EXT)/test_ztrmv.o $(DIR_EXT)/test_ctrmv.o $(DIR_EXT)/test_ztrsv.o $(DIR_EXT)/test_ctrsv.o
OBJS_EXT+=$(DIR_EXT)/test_zgemm.o $(DIR_EXT)/test_cgemm.o $(DIR_EXT)/test_zgbmv.o $(DIR_EXT)/test_cgbmv.o

ifneq ($(NO_LAPACK), 1)
OBJS += test_potrs.o
OBJS_EXT += $(DIR_EXT)/test_zspmv.o $(DIR_EXT)/test_cspmv.o $(DIR_EXT)/test_zsbmv.o $(DIR_EXT)/test_csbmv.o
ifneq ($(NO_CBLAS), 1)
ifneq ($(NO_LAPACKE), 1)
OBJS += test_kernel_regress.o
Expand Down Expand Up @@ -58,12 +75,17 @@ $(UTESTBIN): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ ../$(LIBNAME) $(EXTRALIB) $(FEXTRALIB)
endif

run_test: $(UTESTBIN)
$(UTESTEXTBIN): $(OBJS_EXT)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ ../$(LIBNAME) $(EXTRALIB) $(FEXTRALIB)

run_test: $(UTESTBIN) $(UTESTEXTBIN)
ifneq ($(CROSS), 1)
./$(UTESTBIN)
./$(UTESTEXTBIN)
endif

clean:
-rm -f *.o $(UTESTBIN)
-rm -f *.o $(UTESTBIN) $(UTESTEXTBIN)
-rm -f $(DIR_EXT)/*.o

libs:
libs:
Loading