My Project
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-2019 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 #else
62 
63 # define CS_NUMBERING_SIMD_SIZE 4 /* Most current platforms */
64 
65 #endif
66 
67 /*============================================================================
68  * Type definitions
69  *============================================================================*/
70 
71 /* Renumbering types */
72 
73 typedef enum {
74 
75  CS_NUMBERING_DEFAULT, /* Default numbering */
76  CS_NUMBERING_VECTORIZE, /* Numbered for vectorization */
77  CS_NUMBERING_THREADS /* Numbered for threads */
78 
80 
81 /* Renumbering structure */
82 
83 typedef struct {
84 
85  cs_numbering_type_t type; /* Numbering type */
86 
87  int vector_size; /* Vector size if vectorized, 1 otherwise */
88 
89  int n_threads; /* Number of threads */
90  int n_groups; /* Number of associated groups */
91 
92  int n_no_adj_halo_groups; /* number of groups for which only non-ghost
93  entities are adjacent */
94 
95  cs_lnum_t n_no_adj_halo_elts; /* Number of elements not adjacent to
96  halo elements */
97 
98  cs_lnum_t *group_index; /* For thread t and group g, the start and
99  past-the-end ids for entities in a given
100  group and thread are respectively:
101  group_index[t*n_groups*2 + g] and
102  group_index[t*n_groups*2 + g + 1].
103  (size: n_groups * n_threads * 2) */
104 
106 
107 /*=============================================================================
108  * Global variable definitions
109  *============================================================================*/
110 
111 /* Names for numbering types */
112 
113 extern const char *cs_numbering_type_name[];
114 
115 /*============================================================================
116  * Public function prototypes for Fortran API
117  *============================================================================*/
118 
119 /*=============================================================================
120  * Public function prototypes
121  *============================================================================*/
122 
123 /*----------------------------------------------------------------------------*/
131 /*----------------------------------------------------------------------------*/
132 
135 
136 /*----------------------------------------------------------------------------*/
146 /*----------------------------------------------------------------------------*/
147 
150  int vector_size);
151 
152 /*----------------------------------------------------------------------------*/
166 /*----------------------------------------------------------------------------*/
167 
169 cs_numbering_create_threaded(int n_threads,
170  int n_groups,
171  cs_lnum_t group_index[]);
172 
173 /*----------------------------------------------------------------------------*/
180 /*----------------------------------------------------------------------------*/
181 
182 void
184 
185 /*----------------------------------------------------------------------------*/
193 /*----------------------------------------------------------------------------*/
194 
195 void
197  const char *description,
198  const cs_numbering_t *numbering);
199 
200 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
208 void
209 cs_numbering_dump(const cs_numbering_t *numbering);
210 
211 /*----------------------------------------------------------------------------*/
212 
214 
215 #endif /* __CS_NUMBERING_H__ */
cs_numbering_t::n_no_adj_halo_elts
cs_lnum_t n_no_adj_halo_elts
Definition: cs_numbering.h:95
cs_numbering_create_default
cs_numbering_t * cs_numbering_create_default(cs_lnum_t n_elts)
Create a default numbering information structure.
Definition: cs_numbering.c:520
cs_defs.h
cs_log.h
cs_numbering_t::n_no_adj_halo_groups
int n_no_adj_halo_groups
Definition: cs_numbering.h:92
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_numbering_destroy
void cs_numbering_destroy(cs_numbering_t **numbering)
Destroy a numbering information structure.
Definition: cs_numbering.c:634
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
CS_NUMBERING_DEFAULT
Definition: cs_numbering.h:75
cs_numbering_t
Definition: cs_numbering.h:83
CS_NUMBERING_THREADS
Definition: cs_numbering.h:77
cs_numbering_create_threaded
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:597
CS_NUMBERING_VECTORIZE
Definition: cs_numbering.h:76
cs_numbering_t::group_index
cs_lnum_t * group_index
Definition: cs_numbering.h:98
cs_numbering_create_vectorized
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_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_numbering_t::vector_size
int vector_size
Definition: cs_numbering.h:87
cs_numbering_log_info
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:657
cs_log_t
cs_log_t
Definition: cs_log.h:48
cs_numbering_type_t
cs_numbering_type_t
Definition: cs_numbering.h:73
cs_numbering_dump
void cs_numbering_dump(const cs_numbering_t *numbering)
Dump a cs_numbering_t structure.
Definition: cs_numbering.c:745
cs_numbering_t::n_groups
int n_groups
Definition: cs_numbering.h:90
cs_numbering_type_name
const char * cs_numbering_type_name[]
Definition: cs_numbering.c:73
cs_base.h
cs_numbering_t::type
cs_numbering_type_t type
Definition: cs_numbering.h:85
cs_numbering_t::n_threads
int n_threads
Definition: cs_numbering.h:89