| 1 |
#ifndef MUSIC_C_H |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of MUSIC. |
| 5 |
* Copyright (C) 2008, 2009 INCF |
| 6 |
* |
| 7 |
* MUSIC is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* MUSIC is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
#include "music/music-config.hh" |
| 21 |
|
| 22 |
#if MUSIC_USE_MPI |
| 23 |
#include <mpi.h> |
| 24 |
|
| 25 |
#if MUSIC_HAVE_SIZE_T |
| 26 |
#include <sys/types.h> |
| 27 |
#else |
| 28 |
typedef int size_t; |
| 29 |
#endif |
| 30 |
|
| 31 |
/* Setup */ |
| 32 |
|
| 33 |
typedef struct MUSIC_Setup MUSIC_Setup; |
| 34 |
|
| 35 |
MUSIC_Setup *MUSIC_createSetup (int *argc, char ***argv); |
| 36 |
MUSIC_Setup *MUSIC_createSetupThread (int *argc, |
| 37 |
char ***argv, |
| 38 |
int required, |
| 39 |
int* provided); |
| 40 |
|
| 41 |
/* Communicators */ |
| 42 |
|
| 43 |
#ifndef BUILDING_MUSIC_LIBRARY |
| 44 |
MPI_Comm MUSIC_setupCommunicator (MUSIC_Setup *setup); |
| 45 |
#endif |
| 46 |
|
| 47 |
/* Ports */ |
| 48 |
|
| 49 |
typedef struct MUSIC_ContOutputPort MUSIC_ContOutputPort; |
| 50 |
typedef struct MUSIC_ContInputPort MUSIC_ContInputPort; |
| 51 |
typedef struct MUSIC_EventOutputPort MUSIC_EventOutputPort; |
| 52 |
typedef struct MUSIC_EventInputPort MUSIC_EventInputPort; |
| 53 |
typedef struct MUSIC_MessageOutputPort MUSIC_MessageOutputPort; |
| 54 |
typedef struct MUSIC_MessageInputPort MUSIC_MessageInputPort; |
| 55 |
|
| 56 |
MUSIC_ContOutputPort *MUSIC_publishContOutput (MUSIC_Setup *setup, char *id); |
| 57 |
MUSIC_ContInputPort *MUSIC_publishContInput (MUSIC_Setup *setup, char *id); |
| 58 |
MUSIC_EventOutputPort *MUSIC_publishEventOutput (MUSIC_Setup *setup, char *id); |
| 59 |
MUSIC_EventInputPort *MUSIC_publishEventInput (MUSIC_Setup *setup, char *id); |
| 60 |
MUSIC_MessageOutputPort *MUSIC_publishMessageOutput (MUSIC_Setup *setup, char *id); |
| 61 |
MUSIC_MessageInputPort *MUSIC_publishMessageInput (MUSIC_Setup *setup, char *id); |
| 62 |
|
| 63 |
/* remedius |
| 64 |
* Free of the ports is done by the Runtime instance |
| 65 |
*/ |
| 66 |
/*void MUSIC_destroyContOutput (MUSIC_ContOutputPort* port); |
| 67 |
void MUSIC_destroyContInput (MUSIC_ContInputPort* port); |
| 68 |
void MUSIC_destroyEventOutput (MUSIC_EventOutputPort* port); |
| 69 |
void MUSIC_destroyEventInput (MUSIC_EventInputPort* port); |
| 70 |
void MUSIC_destroyMessageOutput (MUSIC_MessageOutputPort* port); |
| 71 |
void MUSIC_destroyMessageInput (MUSIC_MessageInputPort* port); |
| 72 |
*/ |
| 73 |
/* General port methods */ |
| 74 |
|
| 75 |
int MUSIC_ContOutputPort_isConnected (MUSIC_ContOutputPort *port); |
| 76 |
int MUSIC_ContInputPort_isConnected (MUSIC_ContInputPort *port); |
| 77 |
int MUSIC_EventOutputPort_isConnected (MUSIC_EventOutputPort *port); |
| 78 |
int MUSIC_EventInputPort_isConnected (MUSIC_EventInputPort *port); |
| 79 |
int MUSIC_MessageOutputPort_isConnected (MUSIC_MessageOutputPort *port); |
| 80 |
int MUSIC_MessageInputPort_isConnected (MUSIC_MessageInputPort *port); |
| 81 |
int MUSIC_ContOutputPort_hasWidth (MUSIC_ContOutputPort *port); |
| 82 |
int MUSIC_ContInputPort_hasWidth (MUSIC_ContInputPort *port); |
| 83 |
int MUSIC_EventOutputPort_hasWidth (MUSIC_EventOutputPort *port); |
| 84 |
int MUSIC_EventInputPort_hasWidth (MUSIC_EventInputPort *port); |
| 85 |
int MUSIC_ContOutputPort_width (MUSIC_ContOutputPort *port); |
| 86 |
int MUSIC_ContInputPort_width (MUSIC_ContInputPort *port); |
| 87 |
int MUSIC_EventOutputPort_width (MUSIC_EventOutputPort *port); |
| 88 |
int MUSIC_EventInputPort_width (MUSIC_EventInputPort *port); |
| 89 |
|
| 90 |
/* Mapping */ |
| 91 |
|
| 92 |
/* Data maps */ |
| 93 |
|
| 94 |
typedef struct MUSIC_DataMap MUSIC_DataMap; |
| 95 |
typedef struct MUSIC_ContData MUSIC_ContData; |
| 96 |
typedef struct MUSIC_ArrayData MUSIC_ArrayData; |
| 97 |
|
| 98 |
/* Index maps */ |
| 99 |
|
| 100 |
typedef struct MUSIC_IndexMap MUSIC_IndexMap; |
| 101 |
typedef struct MUSIC_PermutationIndex MUSIC_PermutationIndex; |
| 102 |
typedef struct MUSIC_LinearIndex MUSIC_LinearIndex; |
| 103 |
|
| 104 |
|
| 105 |
/* No arguments are optional. */ |
| 106 |
|
| 107 |
void MUSIC_ContOutputPort_map (MUSIC_ContOutputPort *port, |
| 108 |
MUSIC_ContData *dmap, |
| 109 |
int maxBuffered); |
| 110 |
|
| 111 |
void MUSIC_ContInputPort_map (MUSIC_ContInputPort *port, |
| 112 |
MUSIC_ContData *dmap, |
| 113 |
double delay, |
| 114 |
int maxBuffered, |
| 115 |
int interpolate); |
| 116 |
|
| 117 |
void MUSIC_EventOutputPort_mapGlobalIndex (MUSIC_EventOutputPort *Port, |
| 118 |
MUSIC_IndexMap *indices, |
| 119 |
int maxBuffered); |
| 120 |
|
| 121 |
void MUSIC_EventOutputPort_mapLocalIndex (MUSIC_EventOutputPort *Port, |
| 122 |
MUSIC_IndexMap *indices, |
| 123 |
int maxBuffered); |
| 124 |
|
| 125 |
typedef void MUSIC_EventHandler (double t, int id); |
| 126 |
|
| 127 |
void MUSIC_EventInputPort_mapGlobalIndex (MUSIC_EventInputPort *port, |
| 128 |
MUSIC_IndexMap *indices, |
| 129 |
MUSIC_EventHandler *handleEvent, |
| 130 |
double accLatency, |
| 131 |
int maxBuffered); |
| 132 |
|
| 133 |
void MUSIC_EventInputPort_mapLocalIndex (MUSIC_EventInputPort *port, |
| 134 |
MUSIC_IndexMap *indices, |
| 135 |
MUSIC_EventHandler *handleEvent, |
| 136 |
double accLatency, |
| 137 |
int maxBuffered); |
| 138 |
|
| 139 |
void MUSIC_MessageOutputPort_map_no_handler (MUSIC_MessageOutputPort *port); |
| 140 |
|
| 141 |
void MUSIC_MessageOutputPort_map (MUSIC_MessageOutputPort *port, |
| 142 |
int maxBuffered); |
| 143 |
|
| 144 |
typedef void MUSIC_MessageHandler (double t, void *msg, size_t size); |
| 145 |
|
| 146 |
void MUSIC_MessageInputPort_map (MUSIC_MessageInputPort *port, |
| 147 |
MUSIC_MessageHandler *handleMessage, |
| 148 |
double accLatency, |
| 149 |
int maxBuffered); |
| 150 |
|
| 151 |
/* Index maps */ |
| 152 |
|
| 153 |
MUSIC_PermutationIndex *MUSIC_createPermutationIndex (int *indices, |
| 154 |
int size); |
| 155 |
|
| 156 |
void MUSIC_destroyPermutationIndex (MUSIC_PermutationIndex *Index); |
| 157 |
|
| 158 |
MUSIC_LinearIndex *MUSIC_createLinearIndex (int baseIndex, |
| 159 |
int size); |
| 160 |
|
| 161 |
void MUSIC_destroyLinearIndex (MUSIC_LinearIndex *Index); |
| 162 |
|
| 163 |
/* Exception: The map argument can take any type of index map. */ |
| 164 |
|
| 165 |
MUSIC_ArrayData *MUSIC_createArrayData (void *buffer, |
| 166 |
MPI_Datatype type, |
| 167 |
void *map); |
| 168 |
|
| 169 |
/* Exception: MUSIC_createLinearArrayData corresponds to |
| 170 |
c++ MUSIC::ArrayData::ArrayData (..., ..., ..., ...) */ |
| 171 |
|
| 172 |
MUSIC_ArrayData *MUSIC_createLinearArrayData (void *buffer, |
| 173 |
MPI_Datatype type, |
| 174 |
int baseIndex, |
| 175 |
int size); |
| 176 |
|
| 177 |
void MUSIC_destroyArrayData (MUSIC_ArrayData *arrayData); |
| 178 |
|
| 179 |
/* Configuration variables */ |
| 180 |
|
| 181 |
/* Exceptions: Result is char * |
| 182 |
Extra maxlen argument prevents buffer overflow. |
| 183 |
Result is terminated by \0 unless longer than maxlen - 1 */ |
| 184 |
|
| 185 |
int MUSIC_configString (MUSIC_Setup *setup, |
| 186 |
char *name, |
| 187 |
char *result, |
| 188 |
size_t maxlen); |
| 189 |
|
| 190 |
int MUSIC_configInt (MUSIC_Setup *setup, char *name, int *result); |
| 191 |
|
| 192 |
int MUSIC_configDouble (MUSIC_Setup *setup, char *name, double *result); |
| 193 |
|
| 194 |
/* Runtime */ |
| 195 |
|
| 196 |
typedef struct MUSIC_Runtime MUSIC_Runtime; |
| 197 |
|
| 198 |
MUSIC_Runtime *MUSIC_createRuntime (MUSIC_Setup *setup, double h); |
| 199 |
|
| 200 |
void MUSIC_tick (MUSIC_Runtime *runtime); |
| 201 |
|
| 202 |
double MUSIC_time (MUSIC_Runtime *runtime); |
| 203 |
|
| 204 |
/* Finalization */ |
| 205 |
|
| 206 |
void MUSIC_destroyRuntime (MUSIC_Runtime *runtime); |
| 207 |
#endif |
| 208 |
#define MUSIC_C_H |
| 209 |
#endif /* MUSIC_C_H */ |