Allocate work array when ijob is zero (Reference-LAPACK PR 733)

This commit is contained in:
Martin Kroeker 2022-12-04 11:43:24 +01:00 committed by GitHub
parent 14aef9400d
commit d59dcd7b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 36 deletions

View File

@ -86,12 +86,10 @@ lapack_int LAPACKE_ctgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query; liwork = iwork_query;
lwork = LAPACK_C2INT( work_query ); lwork = LAPACK_C2INT( work_query );
/* Allocate memory for work arrays */ /* Allocate memory for work arrays */
if( ijob != 0 ) { iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) {
if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR;
info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0;
goto exit_level_0;
}
} }
work = (lapack_complex_float*) work = (lapack_complex_float*)
LAPACKE_malloc( sizeof(lapack_complex_float) * lwork ); LAPACKE_malloc( sizeof(lapack_complex_float) * lwork );
@ -106,9 +104,7 @@ lapack_int LAPACKE_ctgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */ /* Release memory and exit */
LAPACKE_free( work ); LAPACKE_free( work );
exit_level_1: exit_level_1:
if( ijob != 0 ) { LAPACKE_free( iwork );
LAPACKE_free( iwork );
}
exit_level_0: exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) { if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_ctgsen", info ); LAPACKE_xerbla( "LAPACKE_ctgsen", info );

View File

@ -83,12 +83,10 @@ lapack_int LAPACKE_dtgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query; liwork = iwork_query;
lwork = (lapack_int)work_query; lwork = (lapack_int)work_query;
/* Allocate memory for work arrays */ /* Allocate memory for work arrays */
if( ijob != 0 ) { iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) {
if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR;
info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0;
goto exit_level_0;
}
} }
work = (double*)LAPACKE_malloc( sizeof(double) * lwork ); work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
if( work == NULL ) { if( work == NULL ) {
@ -103,9 +101,7 @@ lapack_int LAPACKE_dtgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */ /* Release memory and exit */
LAPACKE_free( work ); LAPACKE_free( work );
exit_level_1: exit_level_1:
if( ijob != 0 ) { LAPACKE_free( iwork );
LAPACKE_free( iwork );
}
exit_level_0: exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) { if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_dtgsen", info ); LAPACKE_xerbla( "LAPACKE_dtgsen", info );

View File

@ -83,12 +83,10 @@ lapack_int LAPACKE_stgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query; liwork = iwork_query;
lwork = (lapack_int)work_query; lwork = (lapack_int)work_query;
/* Allocate memory for work arrays */ /* Allocate memory for work arrays */
if( ijob != 0 ) { iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) {
if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR;
info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0;
goto exit_level_0;
}
} }
work = (float*)LAPACKE_malloc( sizeof(float) * lwork ); work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
if( work == NULL ) { if( work == NULL ) {
@ -103,9 +101,7 @@ lapack_int LAPACKE_stgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */ /* Release memory and exit */
LAPACKE_free( work ); LAPACKE_free( work );
exit_level_1: exit_level_1:
if( ijob != 0 ) { LAPACKE_free( iwork );
LAPACKE_free( iwork );
}
exit_level_0: exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) { if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_stgsen", info ); LAPACKE_xerbla( "LAPACKE_stgsen", info );

View File

@ -86,12 +86,10 @@ lapack_int LAPACKE_ztgsen( int matrix_layout, lapack_int ijob,
liwork = iwork_query; liwork = iwork_query;
lwork = LAPACK_Z2INT( work_query ); lwork = LAPACK_Z2INT( work_query );
/* Allocate memory for work arrays */ /* Allocate memory for work arrays */
if( ijob != 0 ) { iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork ); if( iwork == NULL ) {
if( iwork == NULL ) { info = LAPACK_WORK_MEMORY_ERROR;
info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0;
goto exit_level_0;
}
} }
work = (lapack_complex_double*) work = (lapack_complex_double*)
LAPACKE_malloc( sizeof(lapack_complex_double) * lwork ); LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
@ -106,9 +104,7 @@ lapack_int LAPACKE_ztgsen( int matrix_layout, lapack_int ijob,
/* Release memory and exit */ /* Release memory and exit */
LAPACKE_free( work ); LAPACKE_free( work );
exit_level_1: exit_level_1:
if( ijob != 0 ) { LAPACKE_free( iwork );
LAPACKE_free( iwork );
}
exit_level_0: exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) { if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_ztgsen", info ); LAPACKE_xerbla( "LAPACKE_ztgsen", info );