From e722f069375541f8aa5ecf1f57d4501f0ad73643 Mon Sep 17 00:00:00 2001 From: Edward Smyth Date: Mon, 30 Mar 2026 12:03:59 -0400 Subject: [PATCH] CBLAS interface for crotg, zrotg, zdrot and csrot Add CBLAS wrappers for missing complex rot APIs, as requested in #916 --- frame/compat/cblas/src/cblas.h | 11 ++++-- frame/compat/cblas/src/cblas_crotg.c | 50 ++++++++++++++++++++++++ frame/compat/cblas/src/cblas_csrot.c | 58 ++++++++++++++++++++++++++++ frame/compat/cblas/src/cblas_f77.h | 6 ++- frame/compat/cblas/src/cblas_zdrot.c | 58 ++++++++++++++++++++++++++++ frame/compat/cblas/src/cblas_zrotg.c | 50 ++++++++++++++++++++++++ 6 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 frame/compat/cblas/src/cblas_crotg.c create mode 100644 frame/compat/cblas/src/cblas_csrot.c create mode 100644 frame/compat/cblas/src/cblas_zdrot.c create mode 100644 frame/compat/cblas/src/cblas_zrotg.c diff --git a/frame/compat/cblas/src/cblas.h b/frame/compat/cblas/src/cblas.h index 0a29c91500..79f999f6d6 100644 --- a/frame/compat/cblas/src/cblas.h +++ b/frame/compat/cblas/src/cblas.h @@ -120,7 +120,7 @@ void BLIS_EXPORT_BLAS cblas_zaxpy(f77_int N, const void *alpha, const void *X, /* - * Routines with S and D prefix only + * Routines with S D C Z CS and ZD prefixes */ void BLIS_EXPORT_BLAS cblas_srotg(float *a, float *b, float *c, float *s); void BLIS_EXPORT_BLAS cblas_srotmg(float *d1, float *d2, float *b1, const float b2, float *P); @@ -136,10 +136,13 @@ void BLIS_EXPORT_BLAS cblas_drot(f77_int N, double *X, f77_int incX, void BLIS_EXPORT_BLAS cblas_drotm(f77_int N, double *X, f77_int incX, double *Y, f77_int incY, const double *P); +void BLIS_EXPORT_BLAS cblas_crotg(void *a, void *b, float *c, void *s); +void BLIS_EXPORT_BLAS cblas_csrot(f77_int N, void *X, f77_int incX, + void *Y, f77_int incY, const float c, const float s); +void BLIS_EXPORT_BLAS cblas_zrotg(void *a, void *b, double *c, void *s); +void BLIS_EXPORT_BLAS cblas_zdrot(f77_int N, void *X, f77_int incX, + void *Y, f77_int incY, const double c, const double s); -/* - * Routines with S D C Z CS and ZD prefixes - */ void BLIS_EXPORT_BLAS cblas_sscal(f77_int N, float alpha, float *X, f77_int incX); void BLIS_EXPORT_BLAS cblas_dscal(f77_int N, double alpha, double *X, f77_int incX); void BLIS_EXPORT_BLAS cblas_cscal(f77_int N, const void *alpha, void *X, f77_int incX); diff --git a/frame/compat/cblas/src/cblas_crotg.c b/frame/compat/cblas/src/cblas_crotg.c new file mode 100644 index 0000000000..00c6f02d9e --- /dev/null +++ b/frame/compat/cblas/src/cblas_crotg.c @@ -0,0 +1,50 @@ +/* + + BLIS + An object-based framework for developing high-performance BLAS-like + libraries. + + Copyright (C) 2024 - 2026, Advanced Micro Devices, Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name(s) of the copyright holder(s) nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "blis.h" +#ifdef BLIS_ENABLE_CBLAS +/* + * cblas_crotg.c + * + * The program is a C interface to crotg. + * + * + */ +#include "cblas.h" +#include "cblas_f77.h" +void cblas_crotg( void *a, void *b, float *c, void *s ) +{ + F77_crotg((scomplex*)a, (scomplex*)b, c, (scomplex*)s); +} +#endif diff --git a/frame/compat/cblas/src/cblas_csrot.c b/frame/compat/cblas/src/cblas_csrot.c new file mode 100644 index 0000000000..1fd98c2a7a --- /dev/null +++ b/frame/compat/cblas/src/cblas_csrot.c @@ -0,0 +1,58 @@ +/* + + BLIS + An object-based framework for developing high-performance BLAS-like + libraries. + + Copyright (C) 2024 - 2026, Advanced Micro Devices, Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name(s) of the copyright holder(s) nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "blis.h" +#ifdef BLIS_ENABLE_CBLAS +/* + * cblas_csrot.c + * + * The program is a C interface to csrot. + * + * + */ +#include "cblas.h" +#include "cblas_f77.h" +void cblas_csrot( f77_int N, void *X, f77_int incX, void *Y, + f77_int incY, const float c, const float s ) +{ +#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_csrot( &F77_N, (scomplex*)X, &F77_incX, (scomplex*)Y, &F77_incY, &c, &s ); +} +#endif diff --git a/frame/compat/cblas/src/cblas_f77.h b/frame/compat/cblas/src/cblas_f77.h index acb354aaf4..e7f4fd9097 100644 --- a/frame/compat/cblas/src/cblas_f77.h +++ b/frame/compat/cblas/src/cblas_f77.h @@ -14,7 +14,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2020 - 2026, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -57,6 +57,10 @@ #define F77_drotmg drotmg_ #define F77_drot drot_ #define F77_drotm drotm_ +#define F77_crotg crotg_ +#define F77_csrot csrot_ +#define F77_zrotg zrotg_ +#define F77_zdrot zdrot_ #define F77_sswap sswap_ #define F77_scopy scopy_ #define F77_saxpy saxpy_ diff --git a/frame/compat/cblas/src/cblas_zdrot.c b/frame/compat/cblas/src/cblas_zdrot.c new file mode 100644 index 0000000000..b20487ed17 --- /dev/null +++ b/frame/compat/cblas/src/cblas_zdrot.c @@ -0,0 +1,58 @@ +/* + + BLIS + An object-based framework for developing high-performance BLAS-like + libraries. + + Copyright (C) 2024 - 2026, Advanced Micro Devices, Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name(s) of the copyright holder(s) nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "blis.h" +#ifdef BLIS_ENABLE_CBLAS +/* + * cblas_zdrot.c + * + * The program is a C interface to zdrot. + * + * + */ +#include "cblas.h" +#include "cblas_f77.h" +void cblas_zdrot( f77_int N, void *X, f77_int incX, void *Y, + f77_int incY, const double c, const double s ) +{ +#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_zdrot( &F77_N, (dcomplex*)X, &F77_incX, (dcomplex*)Y, &F77_incY, &c, &s ); +} +#endif diff --git a/frame/compat/cblas/src/cblas_zrotg.c b/frame/compat/cblas/src/cblas_zrotg.c new file mode 100644 index 0000000000..30cfaa7211 --- /dev/null +++ b/frame/compat/cblas/src/cblas_zrotg.c @@ -0,0 +1,50 @@ +/* + + BLIS + An object-based framework for developing high-performance BLAS-like + libraries. + + Copyright (C) 2024 - 2026, Advanced Micro Devices, Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name(s) of the copyright holder(s) nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "blis.h" +#ifdef BLIS_ENABLE_CBLAS +/* + * cblas_zrotg.c + * + * The program is a C interface to zrotg. + * + * + */ +#include "cblas.h" +#include "cblas_f77.h" +void cblas_zrotg( void *a, void *b, double *c, void *s ) +{ + F77_zrotg((dcomplex*)a, (dcomplex*)b, c, (dcomplex*)s); +} +#endif