libsc 2.8.5.210-64a7
The SC library provides support for parallel scientific applications.
sc_shmem.h
Go to the documentation of this file.
1/*
2 This file is part of the SC Library.
3 The SC Library provides support for parallel scientific applications.
4
5 Copyright (C) 2010 The University of Texas System
6 Additional copyright (C) 2011 individual authors
7
8 The SC Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The SC Library 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 GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the SC Library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef SC_SHMEM_H
25#define SC_SHMEM_H
26
27#include <sc.h>
28
29SC_EXTERN_C_BEGIN;
30
33/* sc_shmem: an interface for arrays that are redundant on each mpi
34 * process */
35
36typedef enum
37{
40#if defined(SC_ENABLE_MPIWINSHARED)
41 SC_SHMEM_WINDOW,
42 SC_SHMEM_WINDOW_PRESCAN,
43#endif
44#if defined(__bgq__)
45 SC_SHMEM_BGQ,
47 SC_SHMEM_BGQ_PRESCAN,
49#endif
50 SC_SHMEM_NUM_TYPES,
51 SC_SHMEM_NOT_SET
52}
54
55extern const char *sc_shmem_type_to_string[SC_SHMEM_NUM_TYPES];
56
57extern sc_shmem_type_t sc_shmem_default_type;
58
59/* ALL sc_shmem routines should be considered collective: called on
60 * every process in the communicator */
61
68 sc_shmem_type_t type);
69
77
87void *sc_shmem_malloc (int package, size_t elem_size,
88 size_t elem_count, sc_MPI_Comm comm);
89
90#define SC_SHMEM_ALLOC(t,e,c) (t *) sc_shmem_malloc(sc_package_id,sizeof(t),e,c)
91
99void sc_shmem_free (int package, void *array,
100 sc_MPI_Comm comm);
101
102#define SC_SHMEM_FREE(a,c) sc_shmem_free (sc_package_id,a,c)
103
112int sc_shmem_write_start (void *array, sc_MPI_Comm comm);
113
119void sc_shmem_write_end (void *array, sc_MPI_Comm comm);
120
128void sc_shmem_memcpy (void *destarray, void *srcarray,
129 size_t bytes, sc_MPI_Comm comm);
130
141void sc_shmem_allgather (void *sendbuf, int sendcount,
142 sc_MPI_Datatype sendtype,
143 void *recvbuf, int recvcount,
144 sc_MPI_Datatype recvtype,
145 sc_MPI_Comm comm);
146
163void sc_shmem_prefix (void *sendbuf, void *recvbuf,
164 int count, sc_MPI_Datatype type,
165 sc_MPI_Op op, sc_MPI_Comm comm);
166SC_EXTERN_C_END;
167
168#endif /* SC_SHMEM_H */
Support for process management (memory allocation, logging, etc.)
sc3_MPI_Datatype_t sc_MPI_Datatype
Emulate MPI datatypes.
Definition: sc_mpi.h:393
sc3_MPI_Comm_t sc_MPI_Comm
Emulate an MPI communicator.
Definition: sc_mpi.h:391
sc3_MPI_Op_t sc_MPI_Op
Emulate MPI operations.
Definition: sc_mpi.h:394
void sc_shmem_set_type(sc_MPI_Comm comm, sc_shmem_type_t type)
Set the type of shared memory arrays to use on this mpi communicator.
sc_shmem_type_t sc_shmem_get_type(sc_MPI_Comm comm)
Get the type of shared memory arrays to use on this mpi communicator.
void * sc_shmem_malloc(int package, size_t elem_size, size_t elem_count, sc_MPI_Comm comm)
Allocate a shmem array: an array that is redundant on every process.
sc_shmem_type_t
Definition: sc_shmem.h:37
@ SC_SHMEM_BASIC
use allgathers, then sum to simulate scan
Definition: sc_shmem.h:38
@ SC_SHMEM_PRESCAN
mpi_scan, then allgather
Definition: sc_shmem.h:39
void sc_shmem_prefix(void *sendbuf, void *recvbuf, int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm)
Fill a shmem array with an allgather of the prefix op over all processes.
void sc_shmem_write_end(void *array, sc_MPI_Comm comm)
End a write window for a shared array.
int sc_shmem_write_start(void *array, sc_MPI_Comm comm)
Start a write window for a shared array.
void sc_shmem_free(int package, void *array, sc_MPI_Comm comm)
Destroy a shmem array created with sc_shmem_alloc()
void sc_shmem_memcpy(void *destarray, void *srcarray, size_t bytes, sc_MPI_Comm comm)
Copy a shmem array.
void sc_shmem_allgather(void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, void *recvbuf, int recvcount, sc_MPI_Datatype recvtype, sc_MPI_Comm comm)
Fill a shmem array with an allgather.