Skip to content

Commit 535e112

Browse files
author
Kirana Bergstrom
committed
Added lapacke interfaces for lacrm and larcm
1 parent 9f7abc2 commit 535e112

8 files changed

Lines changed: 736 additions & 0 deletions

LAPACKE/src/lapacke_clacrm.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*****************************************************************************
2+
Copyright (c) 2017, Intel Corp.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Intel Corporation nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
THE POSSIBILITY OF SUCH DAMAGE.
28+
*****************************************************************************
29+
* Contents: Native high-level C interface to LAPACK function clacrm
30+
* Author: Intel Corporation
31+
* Generated June 2017
32+
*****************************************************************************/
33+
34+
#include "lapacke_utils.h"
35+
36+
lapack_int LAPACKE_clacrm(int matrix_layout, lapack_int m,
37+
lapack_int n, const lapack_complex_float* a,
38+
lapack_int lda, const float* b, lapack_int ldb,
39+
lapack_complex_float* c, lapack_int ldc)
40+
{
41+
lapack_int info = 0;
42+
float* rwork = NULL;
43+
44+
if (matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR) {
45+
LAPACKE_xerbla("LAPACKE_clacrm", -1);
46+
return -1;
47+
}
48+
#ifndef LAPACK_DISABLE_NAN_CHECK
49+
/* Optionally check input matrices for NaNs */
50+
if( LAPACKE_cge_nancheck( matrix_layout, m, n, a, lda ) ) {
51+
return -4;
52+
}
53+
if( LAPACKE_sge_nancheck( matrix_layout, n, n, b, ldb ) ) {
54+
return -6;
55+
}
56+
#endif
57+
/* Allocate memory for work array(s) */
58+
rwork = (float*)
59+
LAPACKE_malloc(sizeof(float) * MAX(1, 2 * m * n));
60+
if (rwork == NULL) {
61+
info = LAPACK_WORK_MEMORY_ERROR;
62+
goto exit_level_0;
63+
}
64+
/* Call middle-level interface */
65+
info = LAPACKE_clacrm_work(matrix_layout, m, n, a, lda, b, ldb,
66+
c, ldc, rwork);
67+
/* Release memory and exit */
68+
LAPACKE_free(rwork);
69+
exit_level_0:
70+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
71+
LAPACKE_xerbla( "LAPACKE_clacrm", info );
72+
}
73+
return info;
74+
}

LAPACKE/src/lapacke_clacrm_work.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*****************************************************************************
2+
Copyright (c) 2017, Intel Corp.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Intel Corporation nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
THE POSSIBILITY OF SUCH DAMAGE.
28+
*****************************************************************************
29+
* Contents: Native middle-level C interface to LAPACK function clacrm
30+
* Author: Intel Corporation
31+
* Generated June 2017
32+
*****************************************************************************/
33+
34+
#include "lapacke_utils.h"
35+
36+
lapack_int LAPACKE_clacrm_work(int matrix_layout, lapack_int m, lapack_int n,
37+
const lapack_complex_float* a, lapack_int lda,
38+
const float* b, lapack_int ldb,
39+
lapack_complex_float* c, lapack_int ldc,
40+
float* rwork)
41+
{
42+
lapack_int info = 0;
43+
if (matrix_layout == LAPACK_COL_MAJOR) {
44+
/* Call LAPACK function */
45+
LAPACK_clacrm(&m, &n, a, &lda, b, &ldb, c, &ldc, rwork);
46+
} else if (matrix_layout == LAPACK_ROW_MAJOR) {
47+
lapack_int lda_t = MAX(1,m);
48+
lapack_int ldb_t = MAX(1,n);
49+
lapack_int ldc_t = MAX(1,m);
50+
lapack_complex_float* a_t = NULL;
51+
float* b_t = NULL;
52+
lapack_complex_float* c_t = NULL;
53+
/* Check leading dimension(s) */
54+
if( lda < n ) {
55+
info = -5;
56+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
57+
return info;
58+
}
59+
if( ldb < n ) {
60+
info = -7;
61+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
62+
return info;
63+
}
64+
if( ldc < n ) {
65+
info = -9;
66+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
67+
return info;
68+
}
69+
/* Allocate memory for temporary array(s) */
70+
a_t = (lapack_complex_float*)
71+
LAPACKE_malloc(sizeof(lapack_complex_float) * lda_t * MAX(1,n));
72+
b_t = (float*)
73+
LAPACKE_malloc(sizeof(float) * ldb_t * MAX(1,n));
74+
c_t = (lapack_complex_float*)
75+
LAPACKE_malloc((sizeof(lapack_complex_float) * ldc_t * MAX(1,n)));
76+
if (a_t == NULL) {
77+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
78+
goto exit_level_0;
79+
}
80+
if (b_t == NULL) {
81+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
82+
goto exit_level_1;
83+
}
84+
if (c_t == NULL) {
85+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
86+
goto exit_level_2;
87+
}
88+
/* Transpose input matrices */
89+
LAPACKE_cge_trans(matrix_layout, m, n, a, lda, a_t, lda_t);
90+
LAPACKE_sge_trans(matrix_layout, n, n, b, ldb, b_t, ldb_t);
91+
/* Call LAPACK function */
92+
LAPACK_clacrm(&m, &n, a_t, &lda_t, b_t, &ldb_t, c_t, &ldc_t, rwork);
93+
/* Transpose output matrices */
94+
LAPACKE_cge_trans(LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc);
95+
/* Release memory and exit */
96+
LAPACKE_free(c_t);
97+
exit_level_2:
98+
LAPACKE_free(b_t);
99+
exit_level_1:
100+
LAPACKE_free(a_t);
101+
exit_level_0:
102+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
103+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
104+
}
105+
} else {
106+
info = -1;
107+
LAPACKE_xerbla("LAPACKE_clacrm_work", -1);
108+
}
109+
return info;
110+
}

LAPACKE/src/lapacke_clarcm.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*****************************************************************************
2+
Copyright (c) 2017, Intel Corp.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Intel Corporation nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
THE POSSIBILITY OF SUCH DAMAGE.
28+
*****************************************************************************
29+
* Contents: Native high-level C interface to LAPACK function clarcm
30+
* Author: Intel Corporation
31+
* Generated June 2017
32+
*****************************************************************************/
33+
34+
#include "lapacke_utils.h"
35+
36+
lapack_int LAPACKE_clarcm(int matrix_layout, lapack_int m,
37+
lapack_int n, const float* a, lapack_int lda,
38+
const lapack_complex_float* b, lapack_int ldb,
39+
lapack_complex_float* c, lapack_int ldc)
40+
{
41+
lapack_int info = 0;
42+
float* rwork = NULL;
43+
44+
if (matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR) {
45+
LAPACKE_xerbla("LAPACKE_clarcm", -1);
46+
return -1;
47+
}
48+
#ifndef LAPACK_DISABLE_NAN_CHECK
49+
/* Optionally check input matrices for NaNs */
50+
if( LAPACKE_sge_nancheck( matrix_layout, m, m, a, lda ) ) {
51+
return -4;
52+
}
53+
if( LAPACKE_cge_nancheck( matrix_layout, m, n, b, ldb ) ) {
54+
return -6;
55+
}
56+
#endif
57+
/* Allocate memory for work array(s) */
58+
rwork = (float*)
59+
LAPACKE_malloc(sizeof(float) * MAX(1, 2 * m * n));
60+
if (rwork == NULL) {
61+
info = LAPACK_WORK_MEMORY_ERROR;
62+
goto exit_level_0;
63+
}
64+
/* Call middle-level interface */
65+
info = LAPACKE_clarcm_work(matrix_layout, m, n, a, lda, b, ldb,
66+
c, ldc, rwork);
67+
/* Release memory and exit */
68+
LAPACKE_free(rwork);
69+
exit_level_0:
70+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
71+
LAPACKE_xerbla( "LAPACKE_clarcm", info );
72+
}
73+
return info;
74+
}

LAPACKE/src/lapacke_clarcm_work.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*****************************************************************************
2+
Copyright (c) 2017, Intel Corp.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Intel Corporation nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
THE POSSIBILITY OF SUCH DAMAGE.
28+
*****************************************************************************
29+
* Contents: Native middle-level C interface to LAPACK function clarcm
30+
* Author: Intel Corporation
31+
* Generated June 2017
32+
*****************************************************************************/
33+
34+
#include "lapacke_utils.h"
35+
36+
lapack_int LAPACKE_clarcm_work(int matrix_layout, lapack_int m, lapack_int n,
37+
const float* a, lapack_int lda,
38+
const lapack_complex_float* b, lapack_int ldb,
39+
lapack_complex_float* c, lapack_int ldc,
40+
float* rwork)
41+
{
42+
lapack_int info = 0;
43+
if (matrix_layout == LAPACK_COL_MAJOR) {
44+
/* Call LAPACK function */
45+
LAPACK_clarcm(&m, &n, a, &lda, b, &ldb, c, &ldc, rwork);
46+
} else if (matrix_layout == LAPACK_ROW_MAJOR) {
47+
lapack_int lda_t = MAX(1,m);
48+
lapack_int ldb_t = MAX(1,m);
49+
lapack_int ldc_t = MAX(1,m);
50+
float* a_t = NULL;
51+
lapack_complex_float* b_t = NULL;
52+
lapack_complex_float* c_t = NULL;
53+
/* Check leading dimension(s) */
54+
if( lda < m ) {
55+
info = -5;
56+
LAPACKE_xerbla( "LAPACKE_clarcm_work", info );
57+
return info;
58+
}
59+
if( ldb < n ) {
60+
info = -7;
61+
LAPACKE_xerbla( "LAPACKE_clarcm_work", info );
62+
return info;
63+
}
64+
if( ldc < n ) {
65+
info = -9;
66+
LAPACKE_xerbla( "LAPACKE_clarcm_work", info );
67+
return info;
68+
}
69+
/* Allocate memory for temporary array(s) */
70+
a_t = (float*)
71+
LAPACKE_malloc(sizeof(float) * lda_t * MAX(1,m));
72+
b_t = (lapack_complex_float*)
73+
LAPACKE_malloc(sizeof(lapack_complex_float) * ldb_t * MAX(1,n));
74+
c_t = (lapack_complex_float*)
75+
LAPACKE_malloc((sizeof(lapack_complex_float) * ldc_t * MAX(1,n)));
76+
if (a_t == NULL) {
77+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
78+
goto exit_level_0;
79+
}
80+
if (b_t == NULL) {
81+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
82+
goto exit_level_1;
83+
}
84+
if (c_t == NULL) {
85+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
86+
goto exit_level_2;
87+
}
88+
/* Transpose input matrices */
89+
LAPACKE_sge_trans(matrix_layout, m, m, a, lda, a_t, lda_t);
90+
LAPACKE_cge_trans(matrix_layout, m, n, b, ldb, b_t, ldb_t);
91+
/* Call LAPACK function */
92+
LAPACK_clarcm(&m, &n, a_t, &lda_t, b_t, &ldb_t, c_t, &ldc_t, rwork);
93+
/* Transpose output matrices */
94+
LAPACKE_cge_trans(LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc);
95+
/* Release memory and exit */
96+
LAPACKE_free(c_t);
97+
exit_level_2:
98+
LAPACKE_free(b_t);
99+
exit_level_1:
100+
LAPACKE_free(a_t);
101+
exit_level_0:
102+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
103+
LAPACKE_xerbla( "LAPACKE_clarcm_work", info );
104+
}
105+
} else {
106+
info = -1;
107+
LAPACKE_xerbla("LAPACKE_clarcm_work", -1);
108+
}
109+
return info;
110+
}

0 commit comments

Comments
 (0)