t8  1.2.0
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 t8_shmem_init (sc_MPI_Comm comm);
58 
59 #if T8_ENABLE_DEBUG
60 /* If you need this function outside of debugging mode, feel free
61  * to remove the macro protection. */
66 int t8_shmem_array_is_initialized (const t8_shmem_array_t
67  array);
68 #endif
69 
78 void t8_shmem_finalize (sc_MPI_Comm comm);
79 
85 void t8_shmem_set_type (sc_MPI_Comm comm,
86  sc_shmem_type_t type);
87 
97  size_t elem_size,
98  size_t elem_count, sc_MPI_Comm comm);
99 
107 
114 
122  int index, t8_gloidx_t value);
123 
131  t8_shmem_array_t source);
132 
143 void t8_shmem_array_allgather (const void *sendbuf,
144  int sendcount,
145  sc_MPI_Datatype sendtype,
146  t8_shmem_array_t recvarray,
147  int recvcount,
148  sc_MPI_Datatype recvtype);
149 
154 sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array);
155 
161 
167 
175 
182 /* *INDENT-OFF* */
184 /* *INDENT-ON* */
185 
193  int index);
194 
200 const void *t8_shmem_array_get_array (t8_shmem_array_t array);
201 
209 const void *t8_shmem_array_index (t8_shmem_array_t array,
210  size_t index);
211 
220  size_t index);
221 
222 /* TODO: implement and comment */
223 /* returns true if arrays are equal
224  * \note Writing mode must be disabled for \a array_a and \a array_b.
225  */
226 int t8_shmem_array_is_equal (t8_shmem_array_t array_a,
227  t8_shmem_array_t array_b);
228 
234 
235 T8_EXTERN_C_END ();
236 
237 #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:105
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:209
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:304
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:286
void t8_shmem_array_destroy(t8_shmem_array_t *parray)
Free all memory associated with a t8_shmem_array.
Definition: t8_shmem.c:349
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:118
int t8_shmem_array_start_writing(t8_shmem_array_t array)
Enable writing mode for a shmem array.
Definition: t8_shmem.c:159
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:294
void t8_shmem_array_end_writing(t8_shmem_array_t array)
Disable writing mode for a shmem array.
Definition: t8_shmem.c:174
void t8_shmem_init(sc_MPI_Comm comm)
Initialize shared memory usage for a communicator.
Definition: t8_shmem.c:66
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:273
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:98
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:262
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:186
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:243
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:252
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:236
void t8_shmem_finalize(sc_MPI_Comm comm)
Finalize shared memory usage for a communicator.
Definition: t8_shmem.c:84
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:229
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:222