programmer's documentation
cs_numbering.h
Go to the documentation of this file.
1 #ifndef __CS_NUMBERING_H__
2 #define __CS_NUMBERING_H__
3 
4 /*============================================================================
5  * Numbering information for vectorization or multithreading
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2015 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 #include "cs_base.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /* SIMD unit length */
46 /*------------------*/
47 
48 #if defined(__uxpvp__) /* For Fujitsu VPP5000 (or possibly successors) */
49 
50 # define CS_NUMBERING_SIMD_SIZE 1024 /* Use register 16 */
51 
52 #elif defined(SX) && defined(_SX) /* For NEC SX series */
53 
54 # define CS_NUMBERING_SIMD_SIZE 256 /* At least for NEC SX-9 */
55 
56 #else
57 
58 # define CS_NUMBERING_SIMD_SIZE 4 /* Most current platforms */
59 
60 #endif
61 
62 /*============================================================================
63  * Type definitions
64  *============================================================================*/
65 
66 /* Renumbering types */
67 
68 typedef enum {
69 
70  CS_NUMBERING_DEFAULT, /* Default numbering */
71  CS_NUMBERING_VECTORIZE, /* Numbered for vectorization */
72  CS_NUMBERING_THREADS /* Numbered for threads */
73 
75 
76 /* Renumbering structure */
77 
78 typedef struct {
79 
80  cs_numbering_type_t type; /* Numbering type */
81 
82  int vector_size; /* Vector size if vectorized, 1 otherwise */
83 
84  int n_threads; /* Number of threads */
85  int n_groups; /* Number of associated groups */
86 
87  int n_no_adj_halo_groups; /* number of groups for which only non-ghost
88  entities are adjacent */
89 
90  cs_lnum_t n_no_adj_halo_elts; /* Number of elements not adjacent to
91  halo elements */
92 
93  cs_lnum_t *group_index; /* For thread t and group g, the start and
94  past-the-end ids for entities in a given
95  group and thread are respectively:
96  group_index[t*n_groups*2 + g] and
97  group_index[t*n_groups*2 + g + 1].
98  (size: n_groups * n_threads * 2) */
99 
101 
102 /*=============================================================================
103  * Global variable definitions
104  *============================================================================*/
105 
106 /* Names for numbering types */
107 
108 extern const char *cs_numbering_type_name[];
109 
110 /*============================================================================
111  * Public function prototypes for Fortran API
112  *============================================================================*/
113 
114 /*=============================================================================
115  * Public function prototypes
116  *============================================================================*/
117 
118 /*----------------------------------------------------------------------------
119  * Create a default numbering information structure.
120  *
121  * parameters:
122  * n_elts <-- number of associated elements
123  *
124  * returns:
125  * pointer to created cs_numbering_t structure
126  *---------------------------------------------------------------------------*/
127 
130 
131 /*----------------------------------------------------------------------------
132  * Create a numbering information structure in case of vectorization.
133  *
134  * parameters:
135  * n_elts <-- number of associated elements
136  * vector_size <-- vector size used for this vectorization
137  *
138  * returns:
139  * pointer to created cs_numbering_t structure
140  *---------------------------------------------------------------------------*/
141 
144  int vector_size);
145 
146 /*----------------------------------------------------------------------------
147  * Create a numbering information structure in case of threading.
148  *
149  * parameters:
150  * n_threads <-- number of threads
151  * n_groups <-- number of groups
152  * group_index <-- group_index[thread_id*group_id*2 + group_id*2] and
153  * group_index[thread_id*group_id*2 + group_id*2 +1] define
154  * the start and end ids for entities in a given group and
155  * thread; (size: n_groups *2 * n_threads)
156  *
157  * returns:
158  * pointer to created cs_numbering_t structure
159  *---------------------------------------------------------------------------*/
160 
162 cs_numbering_create_threaded(int n_threads,
163  int n_groups,
164  cs_lnum_t group_index[]);
165 
166 /*----------------------------------------------------------------------------
167  * Destroy a numbering information structure.
168  *
169  * parameters:
170  * numbering <-> pointer to cs_numbering_t structure pointer (or NULL)
171  *---------------------------------------------------------------------------*/
172 
173 void
175 
176 /*----------------------------------------------------------------------------
177  * Dump a cs_numbering_t structure.
178  *
179  * parameters:
180  * numbering <-- pointer to cs_numbering_t structure (or NULL)
181  *---------------------------------------------------------------------------*/
182 
183 void
184 cs_numbering_dump(const cs_numbering_t *numbering);
185 
186 /*----------------------------------------------------------------------------*/
187 
189 
190 #endif /* __CS_NUMBERING_H__ */
cs_numbering_type_t type
Definition: cs_numbering.h:80
const char * cs_numbering_type_name[]
Definition: cs_numbering.c:65
int n_no_adj_halo_groups
Definition: cs_numbering.h:87
void cs_numbering_destroy(cs_numbering_t **numbering)
Definition: cs_numbering.c:196
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
Definition: cs_numbering.h:72
cs_numbering_t * cs_numbering_create_threaded(int n_threads, int n_groups, cs_lnum_t group_index[])
Definition: cs_numbering.c:164
cs_numbering_t * cs_numbering_create_vectorized(cs_lnum_t n_elts, int vector_size)
Definition: cs_numbering.c:127
Definition: cs_numbering.h:71
cs_lnum_t * group_index
Definition: cs_numbering.h:93
int vector_size
Definition: cs_numbering.h:82
Definition: cs_numbering.h:70
int n_groups
Definition: cs_numbering.h:85
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
void cs_numbering_dump(const cs_numbering_t *numbering)
Definition: cs_numbering.c:216
#define END_C_DECLS
Definition: cs_defs.h:430
int n_threads
Definition: cs_numbering.h:84
cs_numbering_type_t
Definition: cs_numbering.h:68
cs_lnum_t n_no_adj_halo_elts
Definition: cs_numbering.h:90
cs_numbering_t * cs_numbering_create_default(cs_lnum_t n_elts)
Definition: cs_numbering.c:92
Definition: cs_numbering.h:78