Skip to content

Commit 9eb9443

Browse files
authored
Changed XERBLA Error Message
XERBLA gives out DGESVD error message since DGESDD internally uses DGESVD. Corrected it by returning only info without XERBLA error message in DGESVD.
1 parent e3b6e6d commit 9eb9443

3 files changed

Lines changed: 38 additions & 8 deletions

File tree

src/lapack/dec/svd/ext/flamec/lapack_dgesvd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
the command line, as in cc *.o -lf2c -lm Source for libf2c is in
66
/netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */
77
/*
8-
* Modifications Copyright (c) 2021-2024 Advanced Micro Devices, Inc.  All
8+
* Modifications Copyright (c) 2021-2025 Advanced Micro Devices, Inc.  All
99
* rights reserved.
1010
*/
1111
#include "FLAME.h"
@@ -1646,8 +1646,6 @@ int lapack_dgesvd(char *jobu, char *jobvt, integer *m, integer *n,
16461646
}
16471647
#endif
16481648
if (*info != 0) {
1649-
i__2 = -(*info);
1650-
xerbla_("DGESVD", &i__2, (ftnlen)6);
16511649
return 0;
16521650
} else if (lquery) {
16531651
return 0;

src/map/lapack2flamec/FLA_gesdd.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
At this moment, this routine is redirected to GESVD.
3939
*/
4040

41+
extern void xerbla_(const char *srname, const integer *info, ftnlen srname_len);
42+
extern int lapack_sgesvd(char *jobu, char *jobvt, integer *m, integer *n, real *a, integer *lda,
43+
real *s, real *u, integer *ldu, real *vt, integer *ldvt, real *work,
44+
integer *lwork, integer *info);
45+
extern int lapack_dgesvd(char *jobu, char *jobvt, integer *m, integer *n, doublereal *a,
46+
integer *lda, doublereal *s, doublereal *u, integer *ldu, doublereal *vt,
47+
integer *ldvt, doublereal *work, integer *lwork, integer *info);
48+
4149
#define LAPACK_gesdd_real(prefix) \
4250
void F77_##prefix##gesdd( \
4351
char *jobz, integer *m, integer *n, PREFIX2LAPACK_TYPEDEF(prefix) * buff_A, \
@@ -55,10 +63,10 @@
5563
PREFIX2LAPACK_TYPEDEF(prefix) * buff_w, integer * lwork, \
5664
PREFIX2LAPACK_REALDEF(prefix) * buff_r, integer * buff_i, integer * info)
5765

58-
#define LAPACK_gesdd_real_body(prefix) \
59-
\
60-
F77_##prefix##gesvd(jobu, jobv, m, n, buff_A, ldim_A, buff_s, buff_U, ldim_U, buff_Vh, \
61-
ldim_Vh, buff_w, lwork, info);
66+
#define LAPACK_gesdd_real_body(prefix) \
67+
\
68+
lapack_##prefix##gesvd(jobu, jobv, m, n, buff_A, ldim_A, buff_s, buff_U, ldim_U, buff_Vh, \
69+
ldim_Vh, buff_w, lwork, info);
6270

6371
#define LAPACK_gesdd_complex_body(prefix) \
6472
char jobu[1], jobv[1]; \
@@ -158,11 +166,13 @@ LAPACK_gesdd_real(d)
158166
if(*m < FLA_SVD_SMALL_SIZE_THRESH2 && *n < FLA_SVD_SMALL_SIZE_THRESH2)
159167
{
160168
/* Path for small sizes making use of optimized DGESVD */
169+
integer i__1;
161170
char jobu[1], jobv[1];
162171
doublereal anrm;
163172
extern doublereal dlange_(char *norm, integer *m, integer *n,
164173
doublereal *a, integer *lda, doublereal *work);
165174

175+
*info = 0;
166176
if(lsame_(jobz, "O", 1, 1))
167177
{
168178
if(*m >= *n)
@@ -211,6 +221,8 @@ LAPACK_gesdd_real(d)
211221
{
212222
/* If the info is set to a negative value, it means that the
213223
* input parameters are invalid, so return. */
224+
i__1 = -(*info);
225+
xerbla_("DGESDD", &i__1, (ftnlen)6);
214226
AOCL_DTL_TRACE_LOG_EXIT
215227
return;
216228
}
@@ -232,6 +244,16 @@ LAPACK_gesdd_real(d)
232244
*info += 1;
233245
}
234246
}
247+
248+
if(*info < 0)
249+
{
250+
/* If the info is set to a negative value, it means that the
251+
* input parameters are invalid, so return. */
252+
i__1 = -(*info);
253+
xerbla_("DGESDD", &i__1, (ftnlen)6);
254+
AOCL_DTL_TRACE_LOG_EXIT
255+
return;
256+
}
235257
}
236258
else
237259
{

src/map/lapack2flamec/FLA_gesvd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
/*
12-
Copyright (c) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.
12+
Copyright (c) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
1313
*/
1414

1515
#include "FLAME.h"
@@ -35,6 +35,7 @@
3535
Note that the routine returns V**T, not V.
3636
*/
3737

38+
extern void xerbla_(const char *srname, const integer *info, ftnlen srname_len);
3839
extern int lapack_sgesvd(char *jobu, char *jobvt, integer *m, integer *n, real *a, integer *lda,
3940
real *s, real *u, integer *ldu, real *vt, integer *ldvt, real *work,
4041
integer *lwork, integer *info);
@@ -181,11 +182,20 @@ LAPACK_gesvd_real(d)
181182
*jobu, *jobv, *m, *n, *ldim_A, *ldim_U, *ldim_Vh);
182183
#if FLA_ENABLE_AMD_OPT
183184
{
185+
integer i__1;
184186
/* Initialize global context data */
185187
aocl_fla_init();
186188

187189
lapack_dgesvd(jobu, jobv, m, n, buff_A, ldim_A, buff_s, buff_U, ldim_U, buff_Vh, ldim_Vh,
188190
buff_w, lwork, info);
191+
192+
if(*info < 0)
193+
{
194+
/* If the info is set to a negative value, it means that the
195+
* input parameters are invalid, so return. */
196+
i__1 = -(*info);
197+
xerbla_("DGESVD", &i__1, (ftnlen)6);
198+
}
189199
}
190200
AOCL_DTL_TRACE_LOG_EXIT
191201
return;

0 commit comments

Comments
 (0)