8.0
general 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-2023 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 #include "cs_log.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /* SIMD unit length */
47 /*------------------*/
48 
49 #if defined(__NEC__) && defined(__ve__) /* For NEC Aurora series */
50 
51 # define CS_NUMBERING_SIMD_SIZE 256
52 
53 #elif defined(SX) && defined(_SX) /* For NEC SX series (at least SX-9) */
54 
55 # define CS_NUMBERING_SIMD_SIZE 256
56 
57 #elif defined(__AVX512F__) /* For Intel with AVX 512 */
58 
59 # define CS_NUMBERING_SIMD_SIZE 64
60 
61 #elif defined(HAVE_CUDA) /* For CUDA devices (warp size) */
62 
63 # define CS_NUMBERING_SIMD_SIZE 32
64 
65 #else
66 
67 # define CS_NUMBERING_SIMD_SIZE 4 /* Most current platforms */
68 
69 #endif
70 
71 /*============================================================================
72  * Type definitions
73  *============================================================================*/
74 
75 /* Renumbering types */
76 
77 typedef enum {
78 
79  CS_NUMBERING_DEFAULT, /* Default numbering */
80  CS_NUMBERING_VECTORIZE, /* Numbered for vectorization */
81  CS_NUMBERING_THREADS /* Numbered for threads */
82 
84 
85 /* Renumbering structure */
86 
87 typedef struct {
88 
89  cs_numbering_type_t type; /* Numbering type */
90 
91  int vector_size; /* Vector size if vectorized, 1 otherwise */
92 
93  int n_threads; /* Number of threads */
94  int n_groups; /* Number of associated groups */
95 
96  int n_no_adj_halo_groups; /* number of groups for which only non-ghost
97  entities are adjacent */
98 
99  cs_lnum_t n_no_adj_halo_elts; /* Number of elements not adjacent to
100  halo elements */
101 
102  cs_lnum_t *group_index; /* For thread t and group g, the start and
103  past-the-end ids for entities in a given
104  group and thread are respectively:
105  group_index[t*n_groups*2 + g] and
106  group_index[t*n_groups*2 + g + 1].
107  (size: n_groups * n_threads * 2) */
108 
110 
111 /*=============================================================================
112  * Global variable definitions
113  *============================================================================*/
114 
115 /* Names for numbering types */
116 
117 extern const char *cs_numbering_type_name[];
118 
119 /*============================================================================
120  * Public function prototypes for Fortran API
121  *============================================================================*/
122 
123 /*=============================================================================
124  * Public function prototypes
125  *============================================================================*/
126 
127 /*----------------------------------------------------------------------------*/
135 /*----------------------------------------------------------------------------*/
136 
139 
140 /*----------------------------------------------------------------------------*/
150 /*----------------------------------------------------------------------------*/
151 
154  int vector_size);
155 
156 /*----------------------------------------------------------------------------*/
171 /*----------------------------------------------------------------------------*/
172 
174 cs_numbering_create_threaded(int n_threads,
175  int n_groups,
176  cs_lnum_t group_index[]);
177 
178 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 void
189 
190 /*----------------------------------------------------------------------------*/
198 /*----------------------------------------------------------------------------*/
199 
200 void
202  const char *description,
203  const cs_numbering_t *numbering);
204 
205 /*----------------------------------------------------------------------------*/
211 /*----------------------------------------------------------------------------*/
212 
213 void
214 cs_numbering_dump(const cs_numbering_t *numbering);
215 
216 /*----------------------------------------------------------------------------*/
217 
219 
220 #endif /* __CS_NUMBERING_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:509
#define END_C_DECLS
Definition: cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
cs_log_t
Definition: cs_log.h:48
cs_numbering_t * cs_numbering_create_vectorized(cs_lnum_t n_elts, int vector_size)
Create a default numbering information structure in case of vectorization.
Definition: cs_numbering.c:556
cs_numbering_t * cs_numbering_create_threaded(int n_threads, int n_groups, cs_lnum_t group_index[])
Create a default numbering information structure in case of threading.
Definition: cs_numbering.c:598
void cs_numbering_log_info(cs_log_t log, const char *description, const cs_numbering_t *numbering)
Log information relative to a cs_numbering_t structure.
Definition: cs_numbering.c:658
void cs_numbering_destroy(cs_numbering_t **numbering)
Destroy a numbering information structure.
Definition: cs_numbering.c:635
const char * cs_numbering_type_name[]
Definition: cs_numbering.c:73
cs_numbering_type_t
Definition: cs_numbering.h:77
@ CS_NUMBERING_THREADS
Definition: cs_numbering.h:81
@ CS_NUMBERING_VECTORIZE
Definition: cs_numbering.h:80
@ CS_NUMBERING_DEFAULT
Definition: cs_numbering.h:79
cs_numbering_t * cs_numbering_create_default(cs_lnum_t n_elts)
Create a default numbering information structure.
Definition: cs_numbering.c:520
void cs_numbering_dump(const cs_numbering_t *numbering)
Dump a cs_numbering_t structure.
Definition: cs_numbering.c:746
Definition: cs_numbering.h:87
cs_lnum_t * group_index
Definition: cs_numbering.h:102
int n_no_adj_halo_groups
Definition: cs_numbering.h:96
int vector_size
Definition: cs_numbering.h:91
cs_numbering_type_t type
Definition: cs_numbering.h:89
int n_threads
Definition: cs_numbering.h:93
int n_groups
Definition: cs_numbering.h:94
cs_lnum_t n_no_adj_halo_elts
Definition: cs_numbering.h:99