Skip to content

Commit

Permalink
In LAPACKE tgsen, allocate iwork when ijob = 0. Resolves issue Refere…
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Dec 1, 2022
1 parent 690e111 commit 420a81b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
14 changes: 5 additions & 9 deletions LAPACKE/src/lapacke_ctgsen.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ lapack_int LAPACKE_ctgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query;
lwork = LAPACK_C2INT( work_query );
/* Allocate memory for work arrays */
if( ijob != 0 ) {
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
work = (lapack_complex_float*)
LAPACKE_malloc( sizeof(lapack_complex_float) * lwork );
Expand All @@ -106,9 +104,7 @@ lapack_int LAPACKE_ctgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */
LAPACKE_free( work );
exit_level_1:
if( ijob != 0 ) {
LAPACKE_free( iwork );
}
LAPACKE_free( iwork );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_ctgsen", info );
Expand Down
14 changes: 5 additions & 9 deletions LAPACKE/src/lapacke_dtgsen.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ lapack_int LAPACKE_dtgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query;
lwork = (lapack_int)work_query;
/* Allocate memory for work arrays */
if( ijob != 0 ) {
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
if( work == NULL ) {
Expand All @@ -103,9 +101,7 @@ lapack_int LAPACKE_dtgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */
LAPACKE_free( work );
exit_level_1:
if( ijob != 0 ) {
LAPACKE_free( iwork );
}
LAPACKE_free( iwork );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_dtgsen", info );
Expand Down
14 changes: 5 additions & 9 deletions LAPACKE/src/lapacke_stgsen.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ lapack_int LAPACKE_stgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query;
lwork = (lapack_int)work_query;
/* Allocate memory for work arrays */
if( ijob != 0 ) {
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
if( work == NULL ) {
Expand All @@ -103,9 +101,7 @@ lapack_int LAPACKE_stgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */
LAPACKE_free( work );
exit_level_1:
if( ijob != 0 ) {
LAPACKE_free( iwork );
}
LAPACKE_free( iwork );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_stgsen", info );
Expand Down
14 changes: 5 additions & 9 deletions LAPACKE/src/lapacke_ztgsen.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ lapack_int LAPACKE_ztgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query;
lwork = LAPACK_Z2INT( work_query );
/* Allocate memory for work arrays */
if( ijob != 0 ) {
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
work = (lapack_complex_double*)
LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
Expand All @@ -106,9 +104,7 @@ lapack_int LAPACKE_ztgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */
LAPACKE_free( work );
exit_level_1:
if( ijob != 0 ) {
LAPACKE_free( iwork );
}
LAPACKE_free( iwork );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_ztgsen", info );
Expand Down

0 comments on commit 420a81b

Please sign in to comment.