t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_shmem.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 
27 #ifndef T8_SHMEM_H
28 #define T8_SHMEM_H
29 
30 #include <t8.h>
31 #include <sc_shmem.h>
32 
33 typedef struct t8_shmem_array *t8_shmem_array_t;
34 
39 /* TODO: Change it as soon as we do not always need basic */
40 #if defined(__bgq__)
41 #define T8_SHMEM_BEST_TYPE SC_SHMEM_BGQ
42 #elif defined(SC_ENABLE_MPIWINSHARED)
43 #define T8_SHMEM_BEST_TYPE SC_SHMEM_WINDOW
44 #else
45 #define T8_SHMEM_BEST_TYPE SC_SHMEM_BASIC
46 #endif
47 
48 T8_EXTERN_C_BEGIN ();
49 
57 void
58 t8_shmem_init (sc_MPI_Comm comm);
59 
60 #if T8_ENABLE_DEBUG
61 /* If you need this function outside of debugging mode, feel free
62  * to remove the macro protection. */
67 int
69 #endif
70 
79 void
80 t8_shmem_finalize (sc_MPI_Comm comm);
81 
87 void
88 t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type);
89 
98 void
99 t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm);
100 
107 int
109 
115 void
117 
124 void
125 t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value);
126 
133 void
135 
146 void
147 t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray,
148  int recvcount, sc_MPI_Datatype recvtype);
149 
166 void
167 t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray,
168  sc_MPI_Datatype recvtype, sc_MPI_Comm comm);
169 
187 void
188 t8_shmem_array_prefix (const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type,
189  sc_MPI_Op op, sc_MPI_Comm comm);
190 
195 sc_MPI_Comm
197 
202 size_t
204 
209 size_t
211 
218 const t8_gloidx_t *
220 
227 t8_gloidx_t *
229 
238 
244 const void *
246 
254 const void *
255 t8_shmem_array_index (t8_shmem_array_t array, size_t index);
256 
264 void *
266 
267 /* TODO: implement and comment */
268 /* returns true if arrays are equal
269  * \note Writing mode must be disabled for \a array_a and \a array_b.
270  */
271 int
272 t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b);
273 
278 void
280 
281 T8_EXTERN_C_END ();
282 
283 #endif /* !T8_SHMEM_H */
Shared memory array structure.
Definition: t8_shmem.c:35
This is the administrative header file for t8code.
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:100
void t8_shmem_array_allgather(const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype)
Fill a t8_shmem array with an allgather.
Definition: t8_shmem.c:195
void * t8_shmem_array_index_for_writing(t8_shmem_array_t array, size_t index)
Return a pointer to an element in a t8_shmem_array in writing mode.
Definition: t8_shmem.c:474
const void * t8_shmem_array_get_array(t8_shmem_array_t array)
Return a pointer to the data array of a t8_shmem_array.
Definition: t8_shmem.c:456
int t8_shmem_array_is_initialized(const t8_shmem_array_t array)
Check whether a shared memory array was properly initialized.
Definition: t8_shmem.c:57
void t8_shmem_array_destroy(t8_shmem_array_t *parray)
Free all memory associated with a t8_shmem_array.
Definition: t8_shmem.c:517
void t8_shmem_array_init(t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm)
Initialize and allocate a shared memory array structure.
Definition: t8_shmem.c:114
int t8_shmem_array_start_writing(t8_shmem_array_t array)
Enable writing mode for a shmem array.
Definition: t8_shmem.c:150
const void * t8_shmem_array_index(t8_shmem_array_t array, size_t index)
Return a read-only pointer to an element in a t8_shmem_array.
Definition: t8_shmem.c:464
void t8_shmem_array_end_writing(t8_shmem_array_t array)
Disable writing mode for a shmem array.
Definition: t8_shmem.c:165
void t8_shmem_init(sc_MPI_Comm comm)
Initialize shared memory usage for a communicator.
Definition: t8_shmem.c:65
void t8_shmem_array_set_gloidx(t8_shmem_array_t array, int index, t8_gloidx_t value)
Set an entry of a t8_shmem array that is used to store t8_gloidx_t.
Definition: t8_shmem.c:444
void t8_shmem_set_type(sc_MPI_Comm comm, sc_shmem_type_t type)
Set a shared memory type of a communicator.
Definition: t8_shmem.c:96
t8_gloidx_t t8_shmem_array_get_gloidx(t8_shmem_array_t array, int index)
Return an entry of a shared memory array that stores t8_gloidx_t.
Definition: t8_shmem.c:433
void t8_shmem_array_copy(t8_shmem_array_t dest, t8_shmem_array_t source)
Copy the contents of one t8_shmem array into another.
Definition: t8_shmem.c:177
const t8_gloidx_t * t8_shmem_array_get_gloidx_array(t8_shmem_array_t array)
Return a read-only pointer to the data of a shared memory array interpreted as an t8_gloidx_t array.
Definition: t8_shmem.c:415
t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing(t8_shmem_array_t array)
Return a pointer to the data of a shared memory array interpreted as an t8_gloidx_t array.
Definition: t8_shmem.c:424
void t8_shmem_array_prefix(const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm)
Fill a t8_shmem array with an Allgather of the prefix operation over all processes.
Definition: t8_shmem.c:205
void t8_shmem_array_allgatherv(void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, sc_MPI_Comm comm)
Fill a t8_shmem array with an Allgatherv Computes the recvcount-array and displacement-array for each...
Definition: t8_shmem.c:347
size_t t8_shmem_array_get_elem_count(t8_shmem_array_t array)
Get the number of elements of a t8_shmem_array.
Definition: t8_shmem.c:408
void t8_shmem_finalize(sc_MPI_Comm comm)
Finalize shared memory usage for a communicator.
Definition: t8_shmem.c:82
size_t t8_shmem_array_get_elem_size(t8_shmem_array_t array)
Get the element size of a t8_shmem_array.
Definition: t8_shmem.c:401
sc_MPI_Comm t8_shmem_array_get_comm(t8_shmem_array_t array)
Return the MPI communicator associated with a shmem array.
Definition: t8_shmem.c:394