| 1 |
/* { dg-additional-options "-Wno-analyzer-too-complex" } */ |
| 2 |
|
| 3 |
#include "pr104434.h" |
| 4 |
|
| 5 |
/* Declare LAPACKE_lsame *without* __attribute__((const)). */ |
| 6 |
int LAPACKE_lsame( char ca, char cb ); |
| 7 |
|
| 8 |
/* Testcase adapted/reduced from |
| 9 |
https://github.com/xianyi/OpenBLAS/blob/c5f280a7f0e875d83833d895b2b8b0e341efabf4/lapack-netlib/LAPACKE/src/lapacke_cgbbrd_work.c |
| 10 |
which has this license text. */ |
| 11 |
|
| 12 |
/***************************************************************************** |
| 13 |
Copyright (c) 2014, Intel Corp. |
| 14 |
All rights reserved. |
| 15 |
|
| 16 |
Redistribution and use in source and binary forms, with or without |
| 17 |
modification, are permitted provided that the following conditions are met: |
| 18 |
|
| 19 |
* Redistributions of source code must retain the above copyright notice, |
| 20 |
this list of conditions and the following disclaimer. |
| 21 |
* Redistributions in binary form must reproduce the above copyright |
| 22 |
notice, this list of conditions and the following disclaimer in the |
| 23 |
documentation and/or other materials provided with the distribution. |
| 24 |
* Neither the name of Intel Corporation nor the names of its contributors |
| 25 |
may be used to endorse or promote products derived from this software |
| 26 |
without specific prior written permission. |
| 27 |
|
| 28 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 29 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 30 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 31 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 32 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 33 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 34 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 35 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 36 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 37 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 38 |
THE POSSIBILITY OF SUCH DAMAGE. |
| 39 |
***************************************************************************** |
| 40 |
* Contents: Native middle-level C interface to LAPACK function cgbbrd |
| 41 |
* Author: Intel Corporation |
| 42 |
* Generated November 2015 |
| 43 |
*****************************************************************************/ |
| 44 |
|
| 45 |
lapack_int LAPACKE_cgbbrd_work( int matrix_layout, char vect, lapack_int m, |
| 46 |
lapack_int n, lapack_int ncc, lapack_int kl, |
| 47 |
lapack_int ku, lapack_complex_float* ab, |
| 48 |
lapack_int ldab, float* d, float* e, |
| 49 |
lapack_complex_float* q, lapack_int ldq, |
| 50 |
lapack_complex_float* pt, lapack_int ldpt, |
| 51 |
lapack_complex_float* c, lapack_int ldc, |
| 52 |
lapack_complex_float* work, float* rwork ) |
| 53 |
{ |
| 54 |
lapack_int info = 0; |
| 55 |
if( matrix_layout == LAPACK_COL_MAJOR ) { |
| 56 |
/* Call LAPACK function and adjust info */ |
| 57 |
LAPACK_cgbbrd( &vect, &m, &n, &ncc, &kl, &ku, ab, &ldab, d, e, q, &ldq, |
| 58 |
pt, &ldpt, c, &ldc, work, rwork, &info ); |
| 59 |
if( info < 0 ) { |
| 60 |
info = info - 1; |
| 61 |
} |
| 62 |
} else if( matrix_layout == LAPACK_ROW_MAJOR ) { |
| 63 |
lapack_int ldab_t = MAX(1,kl+ku+1); |
| 64 |
lapack_int ldc_t = MAX(1,m); |
| 65 |
lapack_int ldpt_t = MAX(1,n); |
| 66 |
lapack_int ldq_t = MAX(1,m); |
| 67 |
lapack_complex_float* ab_t = NULL; |
| 68 |
lapack_complex_float* q_t = NULL; |
| 69 |
lapack_complex_float* pt_t = NULL; |
| 70 |
lapack_complex_float* c_t = NULL; |
| 71 |
/* Check leading dimension(s) */ |
| 72 |
if( ldab < n ) { |
| 73 |
info = -9; |
| 74 |
LAPACKE_xerbla( "LAPACKE_cgbbrd_work", info ); |
| 75 |
return info; |
| 76 |
} |
| 77 |
if( ldc < ncc ) { |
| 78 |
info = -17; |
| 79 |
LAPACKE_xerbla( "LAPACKE_cgbbrd_work", info ); |
| 80 |
return info; |
| 81 |
} |
| 82 |
if( ldpt < n ) { |
| 83 |
info = -15; |
| 84 |
LAPACKE_xerbla( "LAPACKE_cgbbrd_work", info ); |
| 85 |
return info; |
| 86 |
} |
| 87 |
if( ldq < m ) { |
| 88 |
info = -13; |
| 89 |
LAPACKE_xerbla( "LAPACKE_cgbbrd_work", info ); |
| 90 |
return info; |
| 91 |
} |
| 92 |
/* Allocate memory for temporary array(s) */ |
| 93 |
ab_t = (lapack_complex_float*) |
| 94 |
LAPACKE_malloc( sizeof(lapack_complex_float) * ldab_t * MAX(1,n) ); |
| 95 |
if( ab_t == NULL ) { |
| 96 |
info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 97 |
goto exit_level_0; |
| 98 |
} |
| 99 |
if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) { |
| 100 |
q_t = (lapack_complex_float*) |
| 101 |
LAPACKE_malloc( sizeof(lapack_complex_float) * |
| 102 |
ldq_t * MAX(1,m) ); |
| 103 |
if( q_t == NULL ) { |
| 104 |
info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 105 |
goto exit_level_1; |
| 106 |
} |
| 107 |
} |
| 108 |
if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) { |
| 109 |
pt_t = (lapack_complex_float*) |
| 110 |
LAPACKE_malloc( sizeof(lapack_complex_float) * |
| 111 |
ldpt_t * MAX(1,n) ); |
| 112 |
if( pt_t == NULL ) { |
| 113 |
info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 114 |
goto exit_level_2; |
| 115 |
} |
| 116 |
} |
| 117 |
if( ncc != 0 ) { |
| 118 |
c_t = (lapack_complex_float*) |
| 119 |
LAPACKE_malloc( sizeof(lapack_complex_float) * |
| 120 |
ldc_t * MAX(1,ncc) ); |
| 121 |
if( c_t == NULL ) { |
| 122 |
info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 123 |
goto exit_level_3; |
| 124 |
} |
| 125 |
} |
| 126 |
/* Transpose input matrices */ |
| 127 |
LAPACKE_cgb_trans( matrix_layout, m, n, kl, ku, ab, ldab, ab_t, ldab_t ); |
| 128 |
if( ncc != 0 ) { |
| 129 |
LAPACKE_cge_trans( matrix_layout, m, ncc, c, ldc, c_t, ldc_t ); |
| 130 |
} |
| 131 |
/* Call LAPACK function and adjust info */ |
| 132 |
LAPACK_cgbbrd( &vect, &m, &n, &ncc, &kl, &ku, ab_t, &ldab_t, d, e, q_t, |
| 133 |
&ldq_t, pt_t, &ldpt_t, c_t, &ldc_t, work, rwork, &info ); |
| 134 |
if( info < 0 ) { |
| 135 |
info = info - 1; |
| 136 |
} |
| 137 |
/* Transpose output matrices */ |
| 138 |
LAPACKE_cgb_trans( LAPACK_COL_MAJOR, m, n, kl, ku, ab_t, ldab_t, ab, |
| 139 |
ldab ); |
| 140 |
if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) { |
| 141 |
LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, m, q_t, ldq_t, q, ldq ); |
| 142 |
} |
| 143 |
if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) { |
| 144 |
LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, pt_t, ldpt_t, pt, ldpt ); |
| 145 |
} |
| 146 |
if( ncc != 0 ) { |
| 147 |
LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, ncc, c_t, ldc_t, c, ldc ); |
| 148 |
} |
| 149 |
/* Release memory and exit */ |
| 150 |
if( ncc != 0 ) { |
| 151 |
LAPACKE_free( c_t ); |
| 152 |
} |
| 153 |
exit_level_3: |
| 154 |
if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) { |
| 155 |
LAPACKE_free( pt_t ); |
| 156 |
} |
| 157 |
exit_level_2: |
| 158 |
if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) { |
| 159 |
LAPACKE_free( q_t ); |
| 160 |
} |
| 161 |
exit_level_1: |
| 162 |
LAPACKE_free( ab_t ); |
| 163 |
exit_level_0: |
| 164 |
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { |
| 165 |
LAPACKE_xerbla( "LAPACKE_cgbbrd_work", info ); |
| 166 |
} |
| 167 |
} else { |
| 168 |
info = -1; |
| 169 |
LAPACKE_xerbla( "LAPACKE_cgbbrd_work", info ); |
| 170 |
} |
| 171 |
return info; /* { dg-warning "leak of 'q_t'" "leak of q_t" } */ |
| 172 |
/* { dg-warning "leak of 'pt_t'" "leak of pt_t" { target *-*-* } .-1 } */ |
| 173 |
} |