Octopus
operate.c
Go to the documentation of this file.
1/*
2 Copyright (C) 2006 X. Andrade
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18
19*/
20
21#include <config.h>
23#include <stddef.h>
24
25#include <assert.h>
26#include <vectors.h>
27
28#include <string.h>
29
42void FC_FUNC_(doperate_ri_vec,
43 DOPERATE_RI_VEC)(const int *opn, const double *restrict w,
44 const int *opnri, const int *opri,
45 const int *rimap_inv, const int *rimap_inv_max,
46 const double *restrict fi, const int *ldfp,
47 double *restrict fo) {
48 const size_t ldf = ldfp[0];
49
50 /* check whether we got aligned vectors or not */
51 int aligned = 1;
52 aligned = aligned && (((long long)fi) % (8 * VEC_SIZE) == 0);
53 aligned = aligned && (((long long)fo) % (8 * VEC_SIZE) == 0);
54 aligned = aligned && ((1 << ldf) % VEC_SIZE == 0);
55
56 if (aligned) {
57#define ALIGNED
58#include "operate_inc.c"
59#undef ALIGNED
60
61 } else {
62 /* not aligned */
63#include "operate_inc.c"
64 }
65}
67/* the same as doperate_ri_vec, but allows giving each an appropriate Fortan
68 interface in which fi and fo are actually complex in Fortran Could be inline,
69 but in that case pgcc will not put it in the symbol table. */
70void FC_FUNC_(zoperate_ri_vec,
71 ZOPERATE_RI_VEC)(const int *opn, const double *restrict w,
72 const int *opnri, const int *opri,
73 const int *rimap_inv, const int *rimap_inv_max,
74 const double *restrict fi, const int *ldfp,
75 double *restrict fo) {
76 FC_FUNC_(doperate_ri_vec, DOPERATE_RI_VEC)
77 (opn, w, opnri, opri, rimap_inv, rimap_inv_max, fi, ldfp, fo);
78}
79
80void FC_FUNC_(dgauss_seidel,
81 DGAUSS_SEIDEL)(const int *opn, const double *restrict w,
82 const int *opnri, const int *opri,
83 const int *rimap_inv, const int *rimap_inv_max,
84 const double *restrict factor, double *pot,
85 const double *restrict rho) {
86
87 const int n = opn[0];
88 const int nri = opnri[0];
89
90 int l, i, j;
91 const int *index;
92 register double a0;
93 register const double fac = *factor;
94
95 for (l = 0; l < nri; l++) {
96 index = opri + n * l;
97 i = rimap_inv[l];
99 for (; i < rimap_inv_max[l]; i++) {
100 a0 = w[0] * pot[i + index[0]];
101 for (j = 1; j < n; j++)
102 a0 += w[j] * pot[i + index[j]];
103 pot[i] += fac * (a0 - rho[i]);
104 }
105 }
106}
107
108
109// Returns the compile-time vectorization level
110void get_vectorization_level(char * level) {
111 char * vector = VECTORIZATION_LEVEL;
112 size_t len = strlen(vector) + 1;
113 strncpy(level, vector, len);
114}
115
void FC_FUNC_(zoperate_ri_vec, ZOPERATE_RI_VEC) const
Definition: operate.c:693
void get_vectorization_level(char *level)
Definition: operate.c:733
const ptrdiff_t nri
Definition: operate_inc.c:10
ptrdiff_t l
Definition: operate_inc.c:12
ptrdiff_t i
Definition: operate_inc.c:12
ptrdiff_t j
Definition: operate_inc.c:12
const int *restrict index
Definition: operate_inc.c:13