The LAPACK forum has moved to https://groups.google.com/a/icl.utk.edu/g/lapack.

lapacke_?lantr: unnecessary work array allocation

Post here if you want to report a bug to the LAPACK team

lapacke_?lantr: unnecessary work array allocation

Postby chereshnev » Thu Dec 17, 2015 6:19 am

From here:
http://www.netlib.org/lapack/explore-html-3.4.2/d2/d22/clantr_8f.html
WORK is REAL array, dimension (MAX(1,LWORK)), LWORK >= M when NORM = 'I'; otherwise, WORK is not.


So in LAPACKE interfaces work array should be allocated only when norm == 'I':

Code: Select all
float LAPACKE_clantr( int matrix_layout, char norm, char uplo, char diag,
     }
 #endif
     /* Allocate memory for working array(s) */
-    if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
-        LAPACKE_lsame( norm, 'O' ) ) {
+    if( LAPACKE_lsame( norm, 'i' ) ) {
         work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,MAX(m,n)) );
         if( work == NULL ) {
             info = LAPACK_WORK_MEMORY_ERROR;
@@ -63,8 +62,7 @@ float LAPACKE_clantr( int matrix_layout, char norm, char uplo, char diag,
     res = LAPACKE_clantr_work( matrix_layout, norm, uplo, diag, m, n, a, lda,
                                 work );
     /* Release memory and exit */
-    if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
-        LAPACKE_lsame( norm, 'O' ) ) {
+    if( LAPACKE_lsame( norm, 'i' ) ) {
         LAPACKE_free( work );
     }
 exit_level_0:
chereshnev
 
Posts: 14
Joined: Thu Oct 09, 2014 6:17 am
Location: Intel Corp., Russia, Novosibirsk

Re: lapacke_?lantr: unnecessary work array allocation

Postby Julien Langou » Thu Dec 17, 2015 12:59 pm

Hi Eugene,

(1) Thanks Eugene. You are correct. For ?LANTR, the WORK space is only needed for the "I" case. I have corrected the lapacke_?lantr subroutines. Thanks! (Commit #1670.)

(2) Also, I am wondering about this (in lapacke_?lantr subroutines)
Code: Select all
        work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,MAX(m,n)) );

It looks to me that it should be a
Code: Select all
        work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );


Anyone agrees? Disagrees?

(3) We will need to have a look at all these routines one day. Clearly the 1-norm in COL MAJOR is same as INF-norm in ROW MAJOR so there should be a possibility of skipping a bunch of steps (allocation, transposition, etc.). These are some optimizations we never seem to come around.

Julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Re: lapacke_?lantr: unnecessary work array allocation

Postby mkroeker » Sat Dec 19, 2015 5:55 pm

Wait, that code was the fix for 141...
mkroeker
 
Posts: 1
Joined: Sat Dec 19, 2015 3:54 pm


Return to Bug report

Who is online

Users browsing this forum: No registered users and 2 guests