cannon.c 10.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//    This file is part of ELPA.
//
//    The ELPA library was originally created by the ELPA consortium,
//    consisting of the following organizations:
//
//    - Max Planck Computing and Data Facility (MPCDF), formerly known as
//      Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
//    - Bergische Universität Wuppertal, Lehrstuhl für angewandte
//      Informatik,
//    - Technische Universität München, Lehrstuhl für Informatik mit
//      Schwerpunkt Wissenschaftliches Rechnen ,
//    - Fritz-Haber-Institut, Berlin, Abt. Theorie,
//    - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
//      Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
//      and
//    - IBM Deutschland GmbH
//
//    This particular source code file has been developed within the ELPA-AEO //
//    project, which has been a joint effort of
//
//    - Max Planck Computing and Data Facility (MPCDF), formerly known as
//      Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
//    - Bergische Universität Wuppertal, Lehrstuhl für angewandte
//      Informatik,
//    - Technische Universität München, Lehrstuhl für Informatik mit
//      Schwerpunkt Wissenschaftliches Rechnen ,
//    - Technische Universität München, Lehrstuhl für Theoretische Chemie,
//    - Fritz-Haber-Institut, Berlin, Abt. Theorie,

//    More information can be found here:
//    http://elpa.mpcdf.mpg.de/ and
//    http://elpa-aeo.mpcdf.mpg.de
//
//    ELPA is free software: you can redistribute it and/or modify
//    it under the terms of the version 3 of the license of the
//    GNU Lesser General Public License as published by the Free
//    Software Foundation.
//
//    ELPA is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with ELPA.  If not, see <http://www.gnu.org/licenses/>
//
//    ELPA reflects a substantial effort on the part of the original
//    ELPA consortium, and we ask you to respect the spirit of the
//    license that we chose: i.e., please contribute any changes you
//    may have back to the original ELPA library distribution, and keep
//    any derivatives of ELPA under the same license that we chose for
//    the original distribution, the GNU Lesser General Public License.
//
// Author: Valeriy Manin (Bergische Universität Wuppertal)
// integreated into the ELPA library Pavel Kus, Andeas Marek (MPCDF)

57
58
59
60
#include "config-f90.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
61
#include <complex.h>
62
63
64
65
66
67
68

// most of the file is not compiled if not using MPI
#ifdef WITH_MPI
#include <mpi.h>

int numroc_(int*, int*, int*, int*, int*);

69
70
//***********************************************************************************************************

71
72
73
74
#define REALCASE 1
#define DOUBLE_PRECISION 1
#include "../general/precision_macros.h"
#include "cannon_forw_template.c"
75
#include "cannon_back_template.c"
76
77
78
79
80
#undef DOUBLE_PRECISION
#undef REALCASE

/*
!f> interface
81
!f>   subroutine cannons_reduction_d(A, U, local_rows, local_cols, a_desc, Res, toStore, row_comm, col_comm) &
82
83
84
85
86
87
88
89
90
91
92
93
94
!f>                             bind(C, name="cannons_reduction_c_d")
!f>     use, intrinsic :: iso_c_binding
!f>     real(c_double)                        :: A(local_rows, local_cols), U(local_rows, local_cols), Res(local_rows, local_cols)
!f>     !type(c_ptr), value                   :: A, U, Res
!f>     integer(kind=c_int)                   :: a_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value     ::  row_comm, col_comm, ToStore
!f>   end subroutine
!f> end interface
*/
void cannons_reduction_c_d(double* A, double* U, int local_rows, int local_cols, int* a_desc,
                         double *Res, int ToStore, int row_comm, int col_comm);

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
!f> interface
!f>   subroutine cannons_triang_rectangular_d(U, B, local_rows, local_cols, u_desc, b_desc, Res, row_comm, col_comm) &
!f>                             bind(C, name="cannons_triang_rectangular_c_d")
!f>     use, intrinsic :: iso_c_binding
!f>     real(c_double)                        :: U(local_rows, local_cols), B(local_rows, local_cols), Res(local_rows, local_cols)
!f>     integer(kind=c_int)                   :: u_desc(9), b_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value             :: row_comm, col_comm
!f>   end subroutine
!f> end interface
*/
void cannons_triang_rectangular_c_d(double* U, double* B, int local_rows, int local_cols,
                                    int* u_desc, int* b_desc, double *Res, int row_comm, int col_comm);

//***********************************************************************************************************

112
113
114
115
#define REALCASE 1
#define SINGLE_PRECISION 1
#include "../general/precision_macros.h"
#include "cannon_forw_template.c"
116
#include "cannon_back_template.c"
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#undef SINGLE_PRECISION
#undef REALCASE

/*
!f> interface
!f>   subroutine cannons_reduction_f(A, U, local_rows, local_cols, a_desc, Res, toStore, row_comm, col_comm) &
!f>                             bind(C, name="cannons_reduction_c_f")
!f>     use, intrinsic :: iso_c_binding
!f>     real(c_float)                        :: A(local_rows, local_cols), U(local_rows, local_cols), Res(local_rows, local_cols)
!f>     !type(c_ptr), value                   :: A, U, Res
!f>     integer(kind=c_int)                   :: a_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value     ::  row_comm, col_comm, ToStore
!f>   end subroutine
!f> end interface
*/
void cannons_reduction_c_f(float* A, float* U, int local_rows, int local_cols, int* a_desc,
                         float *Res, int ToStore, int row_comm, int col_comm);

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
!f> interface
!f>   subroutine cannons_triang_rectangular_f(U, B, local_rows, local_cols, u_desc, b_desc, Res, row_comm, col_comm) &
!f>                             bind(C, name="cannons_triang_rectangular_c_f")
!f>     use, intrinsic :: iso_c_binding
!f>     real(c_float)                        :: U(local_rows, local_cols), B(local_rows, local_cols), Res(local_rows, local_cols)
!f>     integer(kind=c_int)                   :: u_desc(9), b_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value             :: row_comm, col_comm
!f>   end subroutine
!f> end interface
*/
void cannons_triang_rectangular_c_f(float* U, float* B, int local_rows, int local_cols,
                                    int* u_desc, int* b_desc, float *Res, int row_comm, int col_comm);

//***********************************************************************************************************

153
154
155
156
#define COMPLEXCASE 1
#define DOUBLE_PRECISION 1
#include "../general/precision_macros.h"
#include "cannon_forw_template.c"
157
#include "cannon_back_template.c"
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#undef DOUBLE_PRECISION
#undef COMPLEXCASE

/*
!f> interface
!f>   subroutine cannons_reduction_dc(A, U, local_rows, local_cols, a_desc, Res, toStore, row_comm, col_comm) &
!f>                             bind(C, name="cannons_reduction_c_dc")
!f>     use, intrinsic :: iso_c_binding
!f>     complex(c_double)                     :: A(local_rows, local_cols), U(local_rows, local_cols), Res(local_rows, local_cols)
!f>     !type(c_ptr), value                   :: A, U, Res
!f>     integer(kind=c_int)                   :: a_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value     ::  row_comm, col_comm, ToStore
!f>   end subroutine
!f> end interface
*/
void cannons_reduction_c_dc(double complex* A, double complex* U, int local_rows, int local_cols, int* a_desc,
                         double complex *Res, int ToStore, int row_comm, int col_comm);

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
!f> interface
!f>   subroutine cannons_triang_rectangular_dc(U, B, local_rows, local_cols, u_desc, b_desc, Res, row_comm, col_comm) &
!f>                             bind(C, name="cannons_triang_rectangular_c_dc")
!f>     use, intrinsic :: iso_c_binding
!f>     complex(c_double)                        :: U(local_rows, local_cols), B(local_rows, local_cols), Res(local_rows, local_cols)
!f>     integer(kind=c_int)                   :: u_desc(9), b_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value             :: row_comm, col_comm
!f>   end subroutine
!f> end interface
*/
void cannons_triang_rectangular_c_dc(double complex* U, double complex* B, int local_rows, int local_cols,
                                    int* u_desc, int* b_desc, double complex *Res, int row_comm, int col_comm);
//***********************************************************************************************************

193
194
195
196
#define COMPLEXCASE 1
#define SINGLE_PRECISION 1
#include "../general/precision_macros.h"
#include "cannon_forw_template.c"
197
#include "cannon_back_template.c"
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#undef SINGLE_PRECISION
#undef COMPLEXCASE

/*
!f> interface
!f>   subroutine cannons_reduction_fc(A, U, local_rows, local_cols, a_desc, Res, toStore, row_comm, col_comm) &
!f>                             bind(C, name="cannons_reduction_c_fc")
!f>     use, intrinsic :: iso_c_binding
!f>     complex(c_float)                      :: A(local_rows, local_cols), U(local_rows, local_cols), Res(local_rows, local_cols)
!f>     !type(c_ptr), value                   :: A, U, Res
!f>     integer(kind=c_int)                   :: a_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value     ::  row_comm, col_comm, ToStore
!f>   end subroutine
!f> end interface
*/
void cannons_reduction_c_fc(float complex* A, float complex* U, int local_rows, int local_cols, int* a_desc,
                         float complex *Res, int ToStore, int row_comm, int col_comm);

217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*
!f> interface
!f>   subroutine cannons_triang_rectangular_fc(U, B, local_rows, local_cols, u_desc, b_desc, Res, row_comm, col_comm) &
!f>                             bind(C, name="cannons_triang_rectangular_c_fc")
!f>     use, intrinsic :: iso_c_binding
!f>     complex(c_float)                      :: U(local_rows, local_cols), B(local_rows, local_cols), Res(local_rows, local_cols)
!f>     integer(kind=c_int)                   :: u_desc(9), b_desc(9)
!f>     integer(kind=c_int),value             :: local_rows, local_cols
!f>     integer(kind=c_int),value             :: row_comm, col_comm
!f>   end subroutine
!f> end interface
*/
void cannons_triang_rectangular_c_fc(float complex* U, float complex* B, int local_rows, int local_cols,
                                    int* u_desc, int* b_desc, float complex *Res, int row_comm, int col_comm);
231
#endif