Skip to content

Commit

Permalink
fix segfault problem when executing with row major Reference-LAPACK#766
Browse files Browse the repository at this point in the history
  • Loading branch information
sbite0138 committed Nov 28, 2022
1 parent a72090a commit 9764e5c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions LAPACKE/src/lapacke_cgeqrt_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lapack_int LAPACKE_cgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
lapack_int lda_t = MAX(1,m);
lapack_int ldt_t = MAX(1,ldt);
lapack_int ldt_t = MAX(1,nb);
lapack_complex_float* a_t = NULL;
lapack_complex_float* t_t = NULL;
/* Check leading dimension(s) */
Expand Down Expand Up @@ -76,14 +76,15 @@ lapack_int LAPACKE_cgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
/* Transpose input matrices */
LAPACKE_cge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
LAPACKE_cge_trans( matrix_layout, nb, MIN(m,n), t, ldt, t_t, ldt_t );
/* Call LAPACK function and adjust info */
LAPACK_cgeqrt( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, work, &info );
if( info < 0 ) {
info = info - 1;
}
/* Transpose output matrices */
LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
LAPACKE_cge_trans( LAPACK_COL_MAJOR, ldt, MIN(m,n), t_t, ldt_t, t,
LAPACKE_cge_trans( LAPACK_COL_MAJOR, nb, MIN(m,n), t_t, ldt_t, t,
ldt );
/* Release memory and exit */
LAPACKE_free( t_t );
Expand Down
5 changes: 3 additions & 2 deletions LAPACKE/src/lapacke_dgeqrt_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lapack_int LAPACKE_dgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
lapack_int lda_t = MAX(1,m);
lapack_int ldt_t = MAX(1,ldt);
lapack_int ldt_t = MAX(1,nb);
double* a_t = NULL;
double* t_t = NULL;
/* Check leading dimension(s) */
Expand Down Expand Up @@ -73,14 +73,15 @@ lapack_int LAPACKE_dgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
/* Transpose input matrices */
LAPACKE_dge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
LAPACKE_dge_trans( matrix_layout, nb, MIN(m,n), t, ldt, t_t, ldt_t );
/* Call LAPACK function and adjust info */
LAPACK_dgeqrt( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, work, &info );
if( info < 0 ) {
info = info - 1;
}
/* Transpose output matrices */
LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
LAPACKE_dge_trans( LAPACK_COL_MAJOR, ldt, MIN(m,n), t_t, ldt_t, t,
LAPACKE_dge_trans( LAPACK_COL_MAJOR, nb, MIN(m,n), t_t, ldt_t, t,
ldt );
/* Release memory and exit */
LAPACKE_free( t_t );
Expand Down
5 changes: 3 additions & 2 deletions LAPACKE/src/lapacke_sgeqrt_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lapack_int LAPACKE_sgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
lapack_int lda_t = MAX(1,m);
lapack_int ldt_t = MAX(1,ldt);
lapack_int ldt_t = MAX(1,nb);
float* a_t = NULL;
float* t_t = NULL;
/* Check leading dimension(s) */
Expand All @@ -72,14 +72,15 @@ lapack_int LAPACKE_sgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
/* Transpose input matrices */
LAPACKE_sge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
LAPACKE_sge_trans( matrix_layout, nb, MIN(m,n), t, ldt, t_t, ldt_t );
/* Call LAPACK function and adjust info */
LAPACK_sgeqrt( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, work, &info );
if( info < 0 ) {
info = info - 1;
}
/* Transpose output matrices */
LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
LAPACKE_sge_trans( LAPACK_COL_MAJOR, ldt, MIN(m,n), t_t, ldt_t, t,
LAPACKE_sge_trans( LAPACK_COL_MAJOR, nb, MIN(m,n), t_t, ldt_t, t,
ldt );
/* Release memory and exit */
LAPACKE_free( t_t );
Expand Down
5 changes: 3 additions & 2 deletions LAPACKE/src/lapacke_zgeqrt_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lapack_int LAPACKE_zgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
lapack_int lda_t = MAX(1,m);
lapack_int ldt_t = MAX(1,ldt);
lapack_int ldt_t = MAX(1,nb);
lapack_complex_double* a_t = NULL;
lapack_complex_double* t_t = NULL;
/* Check leading dimension(s) */
Expand Down Expand Up @@ -76,14 +76,15 @@ lapack_int LAPACKE_zgeqrt_work( int matrix_layout, lapack_int m, lapack_int n,
}
/* Transpose input matrices */
LAPACKE_zge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
LAPACKE_zge_trans( matrix_layout, nb, MIN(m,n), t, ldt, t_t, ldt_t );
/* Call LAPACK function and adjust info */
LAPACK_zgeqrt( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, work, &info );
if( info < 0 ) {
info = info - 1;
}
/* Transpose output matrices */
LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
LAPACKE_zge_trans( LAPACK_COL_MAJOR, ldt, MIN(m,n), t_t, ldt_t, t,
LAPACKE_zge_trans( LAPACK_COL_MAJOR, nb, MIN(m,n), t_t, ldt_t, t,
ldt );
/* Release memory and exit */
LAPACKE_free( t_t );
Expand Down

0 comments on commit 9764e5c

Please sign in to comment.