Skip to content

Commit

Permalink
Add CBLAS for AXPBY
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Köhler committed Aug 26, 2024
1 parent c571921 commit 4b9693f
Show file tree
Hide file tree
Showing 15 changed files with 332 additions and 34 deletions.
10 changes: 5 additions & 5 deletions CBLAS/include/cblas_f77.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
#define F77_sswap(...) F77_sswap_base(__VA_ARGS__)
#define F77_scopy(...) F77_scopy_base(__VA_ARGS__)
#define F77_saxpy(...) F77_saxpy_base(__VA_ARGS__)
#define F77_saxpby(...) F77_saxpby_base(__VA_ARGS__)
#define F77_saxpby(...) F77_saxpby_base(__VA_ARGS__)
#define F77_sdot_sub(...) F77_sdot_sub_base(__VA_ARGS__)
#define F77_sdsdot_sub(...) F77_sdsdot_sub_base(__VA_ARGS__)
#define F77_sscal(...) F77_sscal_base(__VA_ARGS__)
Expand Down Expand Up @@ -610,7 +610,7 @@ void F77_srotmg_base(float *,float *,float *,const float *, float *);
void F77_sswap_base(FINT, float *, FINT, float *, FINT);
void F77_scopy_base(FINT, const float *, FINT, float *, FINT);
void F77_saxpy_base(FINT, const float *, const float *, FINT, float *, FINT);
void F77_saxpy_base(FINT, const float *, const float *, FINT, float *, float *, FINT);
void F77_saxpby_base(FINT, const float *, const float *, FINT, const float *, float *, FINT);
void F77_sdot_sub_base(FINT, const float *, FINT, const float *, FINT, float *);
void F77_sdsdot_sub_base(FINT, const float *, const float *, FINT, const float *, FINT, float *);
void F77_sscal_base(FINT, const float *, float *, FINT);
Expand All @@ -627,7 +627,7 @@ void F77_drotmg_base(double *,double *,double *,const double *, double *);
void F77_dswap_base(FINT, double *, FINT, double *, FINT);
void F77_dcopy_base(FINT, const double *, FINT, double *, FINT);
void F77_daxpy_base(FINT, const double *, const double *, FINT, double *, FINT);
void F77_daxpby_base(FINT, const double *, const double *, FINT, double *, double *, FINT);
void F77_daxpby_base(FINT, const double *, const double *, FINT, const double *, double *, FINT);
void F77_dswap_base(FINT, double *, FINT, double *, FINT);
void F77_dsdot_sub_base(FINT, const float *, FINT, const float *, FINT, double *);
void F77_ddot_sub_base(FINT, const double *, FINT, const double *, FINT, double *);
Expand All @@ -643,7 +643,7 @@ void F77_csrot_base(FINT, void *X, FINT, void *, FINT, const float *, const floa
void F77_cswap_base(FINT, void *, FINT, void *, FINT);
void F77_ccopy_base(FINT, const void *, FINT, void *, FINT);
void F77_caxpy_base(FINT, const void *, const void *, FINT, void *, FINT);
void F77_caxpby_base(FINT, const void *, const void *, FINT, void *, void *, FINT);
void F77_caxpby_base(FINT, const void *, const void *, FINT, const void *, void *, FINT);
void F77_cswap_base(FINT, void *, FINT, void *, FINT);
void F77_cdotc_sub_base(FINT, const void *, FINT, const void *, FINT, void *);
void F77_cdotu_sub_base(FINT, const void *, FINT, const void *, FINT, void *);
Expand All @@ -661,7 +661,7 @@ void F77_zdrot_base(FINT, void *X, FINT, void *, FINT, const double *, const dou
void F77_zswap_base(FINT, void *, FINT, void *, FINT);
void F77_zcopy_base(FINT, const void *, FINT, void *, FINT);
void F77_zaxpy_base(FINT, const void *, const void *, FINT, void *, FINT);
void F77_zaxpby_base(FINT, const void *, const void *, FINT, void*, void *, FINT);
void F77_zaxpby_base(FINT, const void *, const void *, FINT, const void*, void *, FINT);
void F77_zswap_base(FINT, void *, FINT, void *, FINT);
void F77_zdotc_sub_base(FINT, const void *, FINT, const void *, FINT, void *);
void F77_zdotu_sub_base(FINT, const void *, FINT, const void *, FINT, void *);
Expand Down
8 changes: 4 additions & 4 deletions CBLAS/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ set(SLEV1 cblas_srotg.c cblas_srotmg.c cblas_srot.c cblas_srotm.c
cblas_sswap.c cblas_sscal.c cblas_scopy.c cblas_saxpy.c
cblas_sdot.c cblas_sdsdot.c cblas_snrm2.c cblas_sasum.c
cblas_isamax.c sdotsub.f sdsdotsub.f snrm2sub.f sasumsub.f
isamaxsub.f)
isamaxsub.f cblas_saxpby.c)

# Files for level 1 double precision real
set(DLEV1 cblas_drotg.c cblas_drotmg.c cblas_drot.c cblas_drotm.c
cblas_dswap.c cblas_dscal.c cblas_dcopy.c cblas_daxpy.c
cblas_ddot.c cblas_dsdot.c cblas_dnrm2.c cblas_dasum.c
cblas_idamax.c ddotsub.f dsdotsub.f dnrm2sub.f
dasumsub.f idamaxsub.f)
dasumsub.f idamaxsub.f cblas_daxpby.c)

# Files for level 1 single precision complex
set(CLEV1 cblas_crotg.c cblas_csrot.c
cblas_cswap.c cblas_cscal.c cblas_csscal.c cblas_ccopy.c
cblas_caxpy.c cblas_cdotu_sub.c cblas_cdotc_sub.c
cblas_icamax.c cdotcsub.f cdotusub.f icamaxsub.f
cblas_scabs1.c scabs1sub.f )
cblas_scabs1.c scabs1sub.f cblas_caxpby.c)

# Files for level 1 double precision complex
set(ZLEV1 cblas_zrotg.c cblas_zdrot.c
cblas_zswap.c cblas_zscal.c cblas_zdscal.c cblas_zcopy.c
cblas_zaxpy.c cblas_zdotu_sub.c cblas_zdotc_sub.c cblas_dznrm2.c
cblas_dzasum.c cblas_izamax.c zdotcsub.f zdotusub.f
dzasumsub.f dznrm2sub.f izamaxsub.f
cblas_dcabs1.c dcabs1sub.f)
cblas_dcabs1.c dcabs1sub.f cblas_zaxpby.c)

# Common files for level 1 single precision
set(SCLEV1 cblas_scasum.c scasumsub.f cblas_scnrm2.c scnrm2sub.f)
Expand Down
8 changes: 4 additions & 4 deletions CBLAS/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ slev1 = cblas_srotg.o cblas_srotmg.o cblas_srot.o cblas_srotm.o \
cblas_sswap.o cblas_sscal.o cblas_scopy.o cblas_saxpy.o \
cblas_sdot.o cblas_sdsdot.o cblas_snrm2.o cblas_sasum.o \
cblas_isamax.o sdotsub.o sdsdotsub.o snrm2sub.o sasumsub.o \
isamaxsub.o
isamaxsub.o cblas_saxpby.o

# Files for level 1 double precision real
dlev1 = cblas_drotg.o cblas_drotmg.o cblas_drot.o cblas_drotm.o \
cblas_dswap.o cblas_dscal.o cblas_dcopy.o cblas_daxpy.o \
cblas_ddot.o cblas_dsdot.o cblas_dnrm2.o cblas_dasum.o \
cblas_idamax.o ddotsub.o dsdotsub.o dnrm2sub.o \
dasumsub.o idamaxsub.o
dasumsub.o idamaxsub.o cblas_daxpby.o

# Files for level 1 single precision complex
clev1 = cblas_crotg.o cblas_csrot.o \
cblas_cswap.o cblas_cscal.o cblas_csscal.o cblas_ccopy.o \
cblas_caxpy.o cblas_cdotu_sub.o cblas_cdotc_sub.o \
cblas_icamax.o cdotcsub.o cdotusub.o icamaxsub.o \
cblas_scabs1.o scabs1sub.o
cblas_scabs1.o scabs1sub.o cblas_caxpby.o

# Files for level 1 double precision complex
zlev1 = cblas_zrotg.o cblas_zdrot.o \
cblas_zswap.o cblas_zscal.o cblas_zdscal.o cblas_zcopy.o \
cblas_zaxpy.o cblas_zdotu_sub.o cblas_zdotc_sub.o cblas_dznrm2.o \
cblas_dzasum.o cblas_izamax.o zdotcsub.o zdotusub.o \
dzasumsub.o dznrm2sub.o izamaxsub.o \
cblas_dcabs1.o dcabs1sub.o
cblas_dcabs1.o dcabs1sub.o cblas_zaxpby.o

# Common files for level 1 single precision
sclev1 = cblas_scasum.o scasumsub.o cblas_scnrm2.o scnrm2sub.o
Expand Down
22 changes: 22 additions & 0 deletions CBLAS/src/cblas_caxpby.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* cblas_caxpby.c
*
* The program is a C interface to caxpby.
*
* Written by Martin Koehler. 08/26/2024
*
*/
#include "cblas.h"
#include "cblas_f77.h"
void API_SUFFIX(cblas_caxpby)( const CBLAS_INT N, const void *alpha, const void *X,
const CBLAS_INT incX, const void *beta, void *Y, const CBLAS_INT incY)
{
#ifdef F77_INT
F77_INT F77_N=N, F77_incX=incX, F77_incY=incY;
#else
#define F77_N N
#define F77_incX incX
#define F77_incY incY
#endif
F77_caxpby( &F77_N, alpha, X, &F77_incX, beta, Y, &F77_incY);
}
22 changes: 22 additions & 0 deletions CBLAS/src/cblas_daxpby.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* cblas_daxpby.c
*
* The program is a C interface to daxpby.
*
* Written by Martin Koehler. 08/26/2024
*
*/
#include "cblas.h"
#include "cblas_f77.h"
void API_SUFFIX(cblas_daxpby)( const CBLAS_INT N, const double alpha, const double *X,
const CBLAS_INT incX, const double beta, double *Y, const CBLAS_INT incY)
{
#ifdef F77_INT
F77_INT F77_N=N, F77_incX=incX, F77_incY=incY;
#else
#define F77_N N
#define F77_incX incX
#define F77_incY incY
#endif
F77_daxpby( &F77_N, &alpha, X, &F77_incX, &beta, Y, &F77_incY);
}
23 changes: 23 additions & 0 deletions CBLAS/src/cblas_saxpby.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* cblas_saxpby.c
*
* The program is a C interface to saxpby.
* It calls the fortran wrapper before calling saxpby.
*
* Written by Martin Koehler, 08/24/2024
*
*/
#include "cblas.h"
#include "cblas_f77.h"
void API_SUFFIX(cblas_saxpby)( const CBLAS_INT N, const float alpha, const float *X,
const CBLAS_INT incX, const float beta, float *Y, const CBLAS_INT incY)
{
#ifdef F77_INT
F77_INT F77_N=N, F77_incX=incX, F77_incY=incY;
#else
#define F77_N N
#define F77_incX incX
#define F77_incY incY
#endif
F77_saxpby( &F77_N, &alpha, X, &F77_incX, &beta, Y, &F77_incY);
}
22 changes: 22 additions & 0 deletions CBLAS/src/cblas_zaxpby.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* cblas_zaxpby.c
*
* The program is a C interface to zaxpby.
*
* Written by Martin Koehler, 08/26/2024
*
*/
#include "cblas.h"
#include "cblas_f77.h"
void API_SUFFIX(cblas_zaxpby)( const CBLAS_INT N, const void *alpha, const void *X,
const CBLAS_INT incX, const void *beta, void *Y, const CBLAS_INT incY)
{
#ifdef F77_INT
F77_INT F77_N=N, F77_incX=incX, F77_incY=incY;
#else
#define F77_N N
#define F77_incX incX
#define F77_incY incY
#endif
F77_zaxpby( &F77_N, alpha, X, &F77_incX, beta, Y, &F77_incY);
}
8 changes: 8 additions & 0 deletions CBLAS/testing/c_cblas1.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ void F77_caxpy(const CBLAS_INT *N, const void *alpha, void *X,
return;
}

void F77_caxpby(const CBLAS_INT *N, const void *alpha, void *X,
const CBLAS_INT *incX, const void *beta, void *Y, const CBLAS_INT *incY)
{
cblas_caxpby(*N, alpha, X, *incX, beta, Y, *incY);
return;
}


void F77_ccopy(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
void *Y, const CBLAS_INT *incY)
{
Expand Down
69 changes: 63 additions & 6 deletions CBLAS/testing/c_cblat1.f
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PROGRAM CCBLAT1
DATA SFAC/9.765625E-4/
* .. Executable Statements ..
WRITE (NOUT,99999)
DO 20 IC = 1, 10
DO 20 IC = 1, 11
ICASE = IC
CALL HEADER
*
Expand All @@ -32,7 +32,7 @@ PROGRAM CCBLAT1
INCX = 9999
INCY = 9999
MODE = 9999
IF (ICASE.LE.5) THEN
IF (ICASE.LE.5 .OR. ICASE.EQ.11) THEN
CALL CHECK2(SFAC)
ELSE IF (ICASE.GE.6) THEN
CALL CHECK1(SFAC)
Expand All @@ -53,7 +53,7 @@ SUBROUTINE HEADER
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Arrays ..
CHARACTER*15 L(10)
CHARACTER*15 L(11)
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Data statements ..
Expand All @@ -67,6 +67,8 @@ SUBROUTINE HEADER
DATA L(8)/'CBLAS_CSCAL'/
DATA L(9)/'CBLAS_CSSCAL'/
DATA L(10)/'CBLAS_ICAMAX'/
DATA L(11)/'CBLAS_CAXPBY'/

* .. Executable Statements ..
WRITE (NOUT,99999) ICASE, L(ICASE)
RETURN
Expand Down Expand Up @@ -284,23 +286,26 @@ SUBROUTINE CHECK2(SFAC)
INTEGER ICASE, INCX, INCY, MODE, N
LOGICAL PASS
* .. Local Scalars ..
COMPLEX CA,CTEMP
COMPLEX CA,CB,CTEMP
INTEGER I, J, KI, KN, KSIZE, LENX, LENY, MX, MY
* .. Local Arrays ..
COMPLEX CDOT(1), CSIZE1(4), CSIZE2(7,2), CSIZE3(14),
+ CT10X(7,4,4), CT10Y(7,4,4), CT6(4,4), CT7(4,4),
+ CT8(7,4,4), CX(7), CX1(7), CY(7), CY1(7)
+ CT8(7,4,4), CX(7), CX1(7), CY(7), CY1(7),
+ CT11(7,4,4)
INTEGER INCXS(4), INCYS(4), LENS(4,2), NS(4)
* .. External Functions ..
EXTERNAL CDOTCTEST, CDOTUTEST
* .. External Subroutines ..
EXTERNAL CAXPYTEST, CCOPYTEST, CSWAPTEST, CTEST
EXTERNAL CAXPYTEST, CCOPYTEST, CSWAPTEST, CTEST,
+ CAXPBYTEST
* .. Intrinsic Functions ..
INTRINSIC ABS, MIN
* .. Common blocks ..
COMMON /COMBLA/ICASE, N, INCX, INCY, MODE, PASS
* .. Data statements ..
DATA CA/(0.4E0,-0.7E0)/
DATA CB/(0.7E0,-0.4E0)/
DATA INCXS/1, 2, -2, -1/
DATA INCYS/1, -2, 1, -2/
DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/
Expand Down Expand Up @@ -470,6 +475,54 @@ SUBROUTINE CHECK2(SFAC)
+ (1.54E0,1.54E0), (1.54E0,1.54E0),
+ (1.54E0,1.54E0), (1.54E0,1.54E0),
+ (1.54E0,1.54E0), (1.54E0,1.54E0)/

DATA ((CT11(I,J,1),I=1,7),J=1,4)/(0.6E0,-0.6E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (-0.1E0,-1.47E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (-0.1E0,-1.47E0),
+ (-1.08E0,0.71E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (-0.1E0,-1.47E0), (-1.08E0,0.71E0),
+ (-0.42E0,-0.99E0), (-0.61E0,-0.85E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0)/
DATA ((CT11(I,J,2),I=1,7),J=1,4)/(0.6E0,-0.6E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (-0.1E0,-1.47E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (-0.49E0,-0.95E0),
+ (-0.9E0,0.5E0),(-0.03E0,-1.51E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.36E0,0.00E0), (-0.9E0,0.5E0),
+ (-0.39E0,-0.23E0), (0.1E0,-0.5E0),
+ (-0.82E0,-0.39E0), (-0.5E0,-0.3E0),
+ (0.0E0,-1.62E0)/
DATA ((CT11(I,J,3),I=1,7),J=1,4)/(0.6E0,-0.6E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (-0.1E0,-1.47E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (-0.49E0,-0.95E0),
+ (-0.71E0,-0.1E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.36E0,0.00E0), (-1.07E0,1.18E0),
+ (-0.42E0,-0.99E0), (-0.41E0,-1.2E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0)/
DATA ((CT11(I,J,4),I=1,7),J=1,4)/(0.6E0,-0.6E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (-0.1E0,-1.47E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (-0.1E0,-1.47E0), (-0.9E0,0.5E0),
+ (-0.4E0,-0.7E0), (0.0E0,0.0E0), (0.0E0,0.0E0),
+ (0.0E0,0.0E0), (0.0E0,0.0E0), (-0.1E0,-1.47E0),
+ (-0.9E0,0.5E0),(-0.4E0,-0.7E0), (0.1E0,-0.5E0),
+ (-0.82E0,-0.39E0), (-0.5E0,-0.3E0),
+ (-0.2E0,-1.27E0)/


* .. Executable Statements ..
DO 60 KI = 1, 4
INCX = INCXS(KI)
Expand Down Expand Up @@ -510,6 +563,10 @@ SUBROUTINE CHECK2(SFAC)
CALL CSWAPTEST(N,CX,INCX,CY,INCY)
CALL CTEST(LENX,CX,CT10X(1,KN,KI),CSIZE3,1.0E0)
CALL CTEST(LENY,CY,CT10Y(1,KN,KI),CSIZE3,1.0E0)
ELSE IF (ICASE.EQ.11) THEN
* .. CAXPBYTEST ..
CALL CAXPBYTEST(N,CA,CX,INCX,CB,CY,INCY)
CALL CTEST(LENY,CY,CT11(1,KN,KI),CSIZE2(1,KSIZE),SFAC)
ELSE
WRITE (NOUT,*) ' Shouldn''t be here in CHECK2'
STOP
Expand Down
8 changes: 8 additions & 0 deletions CBLAS/testing/c_dblas1.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ void F77_daxpy(const CBLAS_INT *N, const double *alpha, const double *X,
return;
}

void F77_daxpby(const CBLAS_INT *N, const double *alpha, const double *X,
const CBLAS_INT *incX, const double *beta, double *Y, const CBLAS_INT *incY)
{
cblas_daxpby(*N, *alpha, X, *incX, *beta, Y, *incY);
return;
}


void F77_dcopy(const CBLAS_INT *N, double *X, const CBLAS_INT *incX,
double *Y, const CBLAS_INT *incY)
{
Expand Down
Loading

0 comments on commit 4b9693f

Please sign in to comment.