t8  1.2.0
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8.h
Go to the documentation of this file.
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
29 #ifndef T8_H
30 #define T8_H
31 
32 /* include config headers */
33 #include <t8_config.h>
34 #include <sc_config.h>
35 #if \
36  (defined (T8_ENABLE_MPI) && !defined (SC_ENABLE_MPI)) || \
37  (!defined (T8_ENABLE_MPI) && defined (SC_ENABLE_MPI))
38 #error "MPI configured differently in t8code and libsc"
39 #endif
40 #if \
41  (defined (T8_ENABLE_MPIIO) && !defined (SC_ENABLE_MPIIO)) || \
42  (!defined (T8_ENABLE_MPIIO) && defined (SC_ENABLE_MPIIO))
43 #error "MPI I/O configured differently in t8code and libsc"
44 #endif
45 
46 /* indirectly also include sc.h */
47 #include <sc_containers.h>
48 
51 #define T8_EXTERN_C_BEGIN() SC_EXTERN_C_BEGIN
52 
55 #define T8_EXTERN_C_END() SC_EXTERN_C_END
56 
57 /* call this after including all headers */
58 T8_EXTERN_C_BEGIN ();
59 
61 #define t8_const _sc_const
62 
64 #define t8_restrict _sc_restrict
65 
67 /* Note that we use the same definition as in sc.h. We are deliberately not using
68  * #define T8_ASSERT SC_ASSERT
69  * since then the assertion would not trigger if sc is not configured in debugging mode.
70  * However, we want it to trigger any time t8code is in debugging mode, independent of sc.
71  */
72 #ifdef T8_ENABLE_DEBUG
73 #define T8_ASSERT(c) SC_CHECK_ABORT ((c), "Assertion '" #c "'")
74 #else
75 #define T8_ASSERT(c) SC_NOOP ()
76 #endif
77 
79 #define T8_ALLOC(t,n) (t *) sc_malloc (t8_get_package_id(), \
80  (n) * sizeof(t))
81 
83 #define T8_ALLOC_ZERO(t,n) (t *) sc_calloc (t8_get_package_id(), \
84  (size_t) (n), sizeof(t))
85 
87 #define T8_FREE(p) sc_free (t8_get_package_id(), (p))
88 
90 #define T8_REALLOC(p,t,n) (t *) sc_realloc (t8_get_package_id(), \
91  (p), (n) * sizeof(t))
92 
94 typedef int32_t t8_locidx_t;
96 #define T8_MPI_LOCIDX sc_MPI_INT
98 #define T8_LOCIDX_ABS(x) ((t8_locidx_t) labs ((long) (x)))
100 #define T8_LOCIDX_MAX INT32_MAX
102 #define t8_compare_locidx(v,w) sc_int32_compare(v,w)
103 
105 typedef int64_t t8_gloidx_t;
107 #define T8_MPI_GLOIDX sc_MPI_LONG_LONG_INT
109 #define T8_GLOIDX_ABS(x) ((t8_gloidx_t) llabs ((long long) (x)))
111 #define t8_compare_gloidx(v,w) sc_int64_compare(v,w)
112 
114 typedef uint64_t t8_linearidx_t;
116 #define T8_MPI_LINEARIDX sc_MPI_UNSIGNED_LONG_LONG
117 
118 #define T8_PADDING_SIZE (sizeof (void*))
121 #define T8_ADD_PADDING(_x) \
122  ((T8_PADDING_SIZE - ((_x) % T8_PADDING_SIZE)) % T8_PADDING_SIZE)
123 
125 #define T8_PRECISION_EPS SC_EPS
126 
128 typedef enum
129 {
130  T8_MPI_TAG_FIRST = SC_TAG_FIRST,
131  T8_MPI_PARTITION_CMESH = SC_TAG_LAST,
135  T8_MPI_TAG_LAST
136 }
138 
143 int t8_get_package_id (void);
144 
152 void t8_logv (int category, int priority,
153  const char *fmt, va_list ap);
154 
155 /* *INDENT-OFF* */
162 void t8_logf (int category, int priority, const char *fmt, ...)
163 #ifndef T8_DOXYGEN
164  __attribute__ ((format (printf, 3, 4)))
165 #endif
166  ;
167 
169 void t8_log_indent_push (void);
170 
172 void t8_log_indent_pop (void);
173 
177 void t8_global_errorf (const char *fmt, ...)
178 #ifndef T8_DOXYGEN
179  __attribute__ ((format (printf, 1, 2)))
180 #endif
181  ;
182 
186 void t8_global_essentialf (const char *fmt, ...)
187 #ifndef T8_DOXYGEN
188  __attribute__ ((format (printf, 1, 2)))
189 #endif
190  ;
191 
195 void t8_global_productionf (const char *fmt, ...)
196 #ifndef T8_DOXYGEN
197  __attribute__ ((format (printf, 1, 2)))
198 #endif
199  ;
200 
204 void t8_global_infof (const char *fmt, ...)
205 #ifndef T8_DOXYGEN
206  __attribute__ ((format (printf, 1, 2)))
207 #endif
208  ;
209 
213 void t8_infof (const char *fmt, ...)
214 #ifndef T8_DOXYGEN
215  __attribute__ ((format (printf, 1, 2)))
216 #endif
217  ;
218 
222 void t8_productionf (const char *fmt, ...)
223 #ifndef T8_DOXYGEN
224  __attribute__ ((format (printf, 1, 2)))
225 #endif
226  ;
227 
233 void t8_debugf (const char *fmt, ...)
234 #ifndef T8_DOXYGEN
235  __attribute__ ((format (printf, 1, 2)))
236 #endif
237  ;
238 
242 void t8_errorf (const char *fmt, ...)
243 #ifndef T8_DOXYGEN
244  __attribute__ ((format (printf, 1, 2)))
245 #endif
246  ;
247 
248 /* *INDENT-ON* */
249 
254 void t8_init (int log_threshold);
255 
260 void *t8_sc_array_index_locidx (sc_array_t *array,
261  t8_locidx_t it);
262 
263 /* call this at the end of a header file to match T8_EXTERN_C_BEGIN (). */
264 T8_EXTERN_C_END ();
265 
266 #endif /* !T8_H */
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:105
void t8_errorf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_ERROR.
Definition: t8.c:135
void t8_infof(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_INFO.
Definition: t8.c:103
void t8_global_productionf(const char *fmt,...)
Log a message on the root rank with priority SC_LP_PRODUCTION.
Definition: t8.c:83
void t8_global_errorf(const char *fmt,...)
Log a message on the root rank with priority SC_LP_ERROR.
Definition: t8.c:63
void t8_logf(int category, int priority, const char *fmt,...)
Logging function parametrized by local/global category and priority.
Definition: t8.c:41
void t8_global_essentialf(const char *fmt,...)
Log a message on the root rank with priority SC_LP_ESSENTIAL.
Definition: t8.c:73
void t8_global_infof(const char *fmt,...)
Log a message on the root rank with priority SC_LP_INFO.
Definition: t8.c:93
int t8_get_package_id(void)
Query the package identity as registered in libsc.
Definition: t8.c:29
void t8_debugf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_DEBUG.
Definition: t8.c:123
void t8_log_indent_push(void)
Add one space to the start of t8's default log format.
Definition: t8.c:51
t8_MPI_tag_t
Communication tags used internal to t8code.
Definition: t8.h:129
@ T8_MPI_PARTITION_CMESH
Used for coarse mesh partitioning.
Definition: t8.h:131
@ T8_MPI_GHOST_FOREST
Used for for ghost layer creation.
Definition: t8.h:133
@ T8_MPI_PARTITION_FOREST
Used for forest partitioning.
Definition: t8.h:132
@ T8_MPI_GHOST_EXC_FOREST
Used for ghost data exchange.
Definition: t8.h:134
void t8_init(int log_threshold)
Register t8code with libsc and print version and variable information.
Definition: t8.c:145
void t8_log_indent_pop(void)
Remove one space from the start of a t8's default log format.
Definition: t8.c:57
uint64_t t8_linearidx_t
A type for storing SFC indices.
Definition: t8.h:114
void * t8_sc_array_index_locidx(sc_array_t *array, t8_locidx_t it)
Return a pointer to an array element indexed by a t8_locidx_t.
Definition: t8.c:163
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:94
void t8_logv(int category, int priority, const char *fmt, va_list ap)
Logging function parametrized by local/global category and priority.
Definition: t8.c:35
void t8_productionf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_PRODUCTION.
Definition: t8.c:113