libsc  1.6.0
src/sc_mpi.h
Go to the documentation of this file.
00001 /*
00002   This file is part of the SC Library.
00003   The SC Library provides support for parallel scientific applications.
00004 
00005   Copyright (C) 2010 The University of Texas System
00006 
00007   The SC Library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Lesser General Public
00009   License as published by the Free Software Foundation; either
00010   version 2.1 of the License, or (at your option) any later version.
00011 
00012   The SC Library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Lesser General Public License for more details.
00016 
00017   You should have received a copy of the GNU Lesser General Public
00018   License along with the SC Library; if not, write to the Free Software
00019   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020   02110-1301, USA.
00021 */
00022 
00045 #ifndef SC_MPI_H
00046 #define SC_MPI_H
00047 
00048 #include <sc.h>
00049 
00050 SC_EXTERN_C_BEGIN;
00051 
00052 typedef enum
00053 {
00054   SC_TAG_AG_ALLTOALL = 's' + 'c',       /* anything really */
00055   SC_TAG_AG_RECURSIVE_A,
00056   SC_TAG_AG_RECURSIVE_B,
00057   SC_TAG_AG_RECURSIVE_C,
00058   SC_TAG_NOTIFY_RECURSIVE,
00059   SC_TAG_REDUCE,
00060   SC_TAG_PSORT_LO,
00061   SC_TAG_PSORT_HI
00062 }
00063 sc_tag_t;
00064 
00065 #ifdef SC_ENABLE_MPI
00066 
00067 /* constants */
00068 
00069 #define sc_MPI_SUCCESS             MPI_SUCCESS
00070 #define sc_MPI_COMM_NULL           MPI_COMM_NULL
00071 #define sc_MPI_COMM_WORLD          MPI_COMM_WORLD
00072 #define sc_MPI_COMM_SELF           MPI_COMM_SELF
00073 
00074 #define sc_MPI_ANY_SOURCE          MPI_ANY_SOURCE
00075 #define sc_MPI_ANY_TAG             MPI_ANY_TAG
00076 #define sc_MPI_STATUS_IGNORE       MPI_STATUS_IGNORE
00077 #define sc_MPI_STATUSES_IGNORE     MPI_STATUSES_IGNORE
00078 
00079 #define sc_MPI_REQUEST_NULL        MPI_REQUEST_NULL
00080 
00081 #define sc_MPI_CHAR                MPI_CHAR
00082 #define sc_MPI_SIGNED_CHAR         MPI_SIGNED_CHAR
00083 #define sc_MPI_UNSIGNED_CHAR       MPI_UNSIGNED_CHAR
00084 #define sc_MPI_BYTE                MPI_BYTE
00085 #define sc_MPI_SHORT               MPI_SHORT
00086 #define sc_MPI_UNSIGNED_SHORT      MPI_UNSIGNED_SHORT
00087 #define sc_MPI_INT                 MPI_INT
00088 #define sc_MPI_UNSIGNED            MPI_UNSIGNED
00089 #define sc_MPI_LONG                MPI_LONG
00090 #define sc_MPI_UNSIGNED_LONG       MPI_UNSIGNED_LONG
00091 #define sc_MPI_LONG_LONG_INT       MPI_LONG_LONG_INT
00092 #define sc_MPI_FLOAT               MPI_FLOAT
00093 #define sc_MPI_DOUBLE              MPI_DOUBLE
00094 #define sc_MPI_LONG_DOUBLE         MPI_LONG_DOUBLE
00095 
00096 #define sc_MPI_MAX                 MPI_MAX
00097 #define sc_MPI_MIN                 MPI_MIN
00098 #define sc_MPI_SUM                 MPI_SUM
00099 #define sc_MPI_PROD                MPI_PROD
00100 #define sc_MPI_LAND                MPI_LAND
00101 #define sc_MPI_BAND                MPI_BAND
00102 #define sc_MPI_LOR                 MPI_LOR
00103 #define sc_MPI_BOR                 MPI_BOR
00104 #define sc_MPI_LXOR                MPI_LXOR
00105 #define sc_MPI_BXOR                MPI_BXOR
00106 #define sc_MPI_MINLOC              MPI_MINLOC
00107 #define sc_MPI_MAXLOC              MPI_MAXLOC
00108 #define sc_MPI_REPLACE             MPI_REPLACE
00109 
00110 #define sc_MPI_UNDEFINED           MPI_UNDEFINED
00111 
00112 /* types */
00113 
00114 #define sc_MPI_Comm                MPI_Comm
00115 #define sc_MPI_Datatype            MPI_Datatype
00116 #define sc_MPI_Op                  MPI_Op
00117 #define sc_MPI_Request             MPI_Request
00118 #define sc_MPI_Status              MPI_Status
00119 
00120 /* functions */
00121 
00122 #define sc_MPI_Init                MPI_Init
00123 /*      sc_MPI_Init_thread is handled below */
00124 #define sc_MPI_Finalize            MPI_Finalize
00125 #define sc_MPI_Abort               MPI_Abort
00126 #define sc_MPI_Comm_dup            MPI_Comm_dup
00127 #define sc_MPI_Comm_free           MPI_Comm_free
00128 #define sc_MPI_Comm_size           MPI_Comm_size
00129 #define sc_MPI_Comm_rank           MPI_Comm_rank
00130 #define sc_MPI_Barrier             MPI_Barrier
00131 #define sc_MPI_Bcast               MPI_Bcast
00132 #define sc_MPI_Gather              MPI_Gather
00133 #define sc_MPI_Gatherv             MPI_Gatherv
00134 #define sc_MPI_Allgather           MPI_Allgather
00135 #define sc_MPI_Allgatherv          MPI_Allgatherv
00136 #define sc_MPI_Reduce              MPI_Reduce
00137 #define sc_MPI_Allreduce           MPI_Allreduce
00138 #define sc_MPI_Recv                MPI_Recv
00139 #define sc_MPI_Irecv               MPI_Irecv
00140 #define sc_MPI_Send                MPI_Send
00141 #define sc_MPI_Isend               MPI_Isend
00142 #define sc_MPI_Probe               MPI_Probe
00143 #define sc_MPI_Iprobe              MPI_Iprobe
00144 #define sc_MPI_Get_count           MPI_Get_count
00145 #define sc_MPI_Wtime               MPI_Wtime
00146 #define sc_MPI_Wait                MPI_Wait
00147 #define sc_MPI_Waitsome            MPI_Waitsome
00148 #define sc_MPI_Waitall             MPI_Waitall
00149 
00150 #else /* !SC_ENABLE_MPI */
00151 
00152 /* constants */
00153 
00154 #define sc_MPI_SUCCESS             0
00155 #define sc_MPI_COMM_NULL           ((sc_MPI_Comm) 0x04000000)
00156 #define sc_MPI_COMM_WORLD          ((sc_MPI_Comm) 0x44000000)
00157 #define sc_MPI_COMM_SELF           ((sc_MPI_Comm) 0x44000001)
00158 
00159 #define sc_MPI_ANY_SOURCE          (-2)
00160 #define sc_MPI_ANY_TAG             (-1)
00161 #define sc_MPI_STATUS_IGNORE       (sc_MPI_Status *) 1
00162 #define sc_MPI_STATUSES_IGNORE     (sc_MPI_Status *) 1
00163 
00164 #define sc_MPI_REQUEST_NULL        ((sc_MPI_Request) 0x2c000000)
00165 
00166 #define sc_MPI_CHAR                ((sc_MPI_Datatype) 0x4c000101)
00167 #define sc_MPI_SIGNED_CHAR         ((sc_MPI_Datatype) 0x4c000118)
00168 #define sc_MPI_UNSIGNED_CHAR       ((sc_MPI_Datatype) 0x4c000102)
00169 #define sc_MPI_BYTE                ((sc_MPI_Datatype) 0x4c00010d)
00170 #define sc_MPI_SHORT               ((sc_MPI_Datatype) 0x4c000203)
00171 #define sc_MPI_UNSIGNED_SHORT      ((sc_MPI_Datatype) 0x4c000204)
00172 #define sc_MPI_INT                 ((sc_MPI_Datatype) 0x4c000405)
00173 #define sc_MPI_UNSIGNED            ((sc_MPI_Datatype) 0x4c000406)
00174 #define sc_MPI_LONG                ((sc_MPI_Datatype) 0x4c000407)
00175 #define sc_MPI_UNSIGNED_LONG       ((sc_MPI_Datatype) 0x4c000408)
00176 #define sc_MPI_LONG_LONG_INT       ((sc_MPI_Datatype) 0x4c000809)
00177 #define sc_MPI_FLOAT               ((sc_MPI_Datatype) 0x4c00040a)
00178 #define sc_MPI_DOUBLE              ((sc_MPI_Datatype) 0x4c00080b)
00179 #define sc_MPI_LONG_DOUBLE         ((sc_MPI_Datatype) 0x4c000c0c)
00180 
00181 #define sc_MPI_MAX                 ((sc_MPI_Op) 0x58000001)
00182 #define sc_MPI_MIN                 ((sc_MPI_Op) 0x58000002)
00183 #define sc_MPI_SUM                 ((sc_MPI_Op) 0x58000003)
00184 #define sc_MPI_PROD                ((sc_MPI_Op) 0x58000004)
00185 #define sc_MPI_LAND                ((sc_MPI_Op) 0x58000005)
00186 #define sc_MPI_BAND                ((sc_MPI_Op) 0x58000006)
00187 #define sc_MPI_LOR                 ((sc_MPI_Op) 0x58000007)
00188 #define sc_MPI_BOR                 ((sc_MPI_Op) 0x58000008)
00189 #define sc_MPI_LXOR                ((sc_MPI_Op) 0x58000009)
00190 #define sc_MPI_BXOR                ((sc_MPI_Op) 0x5800000a)
00191 #define sc_MPI_MINLOC              ((sc_MPI_Op) 0x5800000b)
00192 #define sc_MPI_MAXLOC              ((sc_MPI_Op) 0x5800000c)
00193 #define sc_MPI_REPLACE             ((sc_MPI_Op) 0x5800000d)
00194 
00195 #define sc_MPI_UNDEFINED           (-32766)
00196 
00197 /* types */
00198 
00199 typedef int         sc_MPI_Comm;
00200 typedef int         sc_MPI_Datatype;
00201 typedef int         sc_MPI_Op;
00202 typedef int         sc_MPI_Request;
00203 typedef struct sc_MPI_Status
00204 {
00205   int                 count;
00206   int                 cancelled;
00207   int                 MPI_SOURCE;
00208   int                 MPI_TAG;
00209   int                 MPI_ERROR;
00210 }
00211 sc_MPI_Status;
00212 
00213 /* These functions are valid and functional for a single process. */
00214 
00215 int                 sc_MPI_Init (int *, char ***);
00216 /*                  sc_MPI_Init_thread is handled below */
00217 
00218 int                 sc_MPI_Finalize (void);
00219 int                 sc_MPI_Abort (sc_MPI_Comm, int)
00220   __attribute__ ((noreturn));
00221 
00222 int                 sc_MPI_Comm_dup (sc_MPI_Comm, sc_MPI_Comm *);
00223 int                 sc_MPI_Comm_free (sc_MPI_Comm *);
00224 int                 sc_MPI_Comm_size (sc_MPI_Comm, int *);
00225 int                 sc_MPI_Comm_rank (sc_MPI_Comm, int *);
00226 
00227 int                 sc_MPI_Barrier (sc_MPI_Comm);
00228 int                 sc_MPI_Bcast (void *, int, sc_MPI_Datatype, int,
00229                                   sc_MPI_Comm);
00230 int                 sc_MPI_Gather (void *, int, sc_MPI_Datatype, void *, int,
00231                                    sc_MPI_Datatype, int, sc_MPI_Comm);
00232 int                 sc_MPI_Gatherv (void *, int, sc_MPI_Datatype, void *,
00233                                     int *, int *, sc_MPI_Datatype, int,
00234                                     sc_MPI_Comm);
00235 int                 sc_MPI_Allgather (void *, int, sc_MPI_Datatype, void *,
00236                                       int, sc_MPI_Datatype, sc_MPI_Comm);
00237 int                 sc_MPI_Allgatherv (void *, int, sc_MPI_Datatype, void *,
00238                                        int *, int *, sc_MPI_Datatype,
00239                                        sc_MPI_Comm);
00240 int                 sc_MPI_Reduce (void *, void *, int, sc_MPI_Datatype,
00241                                    sc_MPI_Op, int, sc_MPI_Comm);
00242 int                 sc_MPI_Allreduce (void *, void *, int, sc_MPI_Datatype,
00243                                       sc_MPI_Op, sc_MPI_Comm);
00244 
00245 double              sc_MPI_Wtime (void);
00246 
00247 /* These functions will abort. */
00248 
00249 int                 sc_MPI_Recv (void *, int, sc_MPI_Datatype, int, int,
00250                                  sc_MPI_Comm, sc_MPI_Status *);
00251 int                 sc_MPI_Irecv (void *, int, sc_MPI_Datatype, int, int,
00252                                   sc_MPI_Comm, sc_MPI_Request *);
00253 int                 sc_MPI_Send (void *, int, sc_MPI_Datatype, int, int,
00254                                  sc_MPI_Comm);
00255 int                 sc_MPI_Isend (void *, int, sc_MPI_Datatype, int, int,
00256                                   sc_MPI_Comm, sc_MPI_Request *);
00257 int                 sc_MPI_Probe (int, int, sc_MPI_Comm, sc_MPI_Status *);
00258 int                 sc_MPI_Iprobe (int, int, sc_MPI_Comm, int *,
00259                                    sc_MPI_Status *);
00260 int                 sc_MPI_Get_count (sc_MPI_Status *, sc_MPI_Datatype,
00261                                       int *);
00262 
00263 /* These functions are only allowed to be called with NULL requests. */
00264 
00265 int                 sc_MPI_Wait (sc_MPI_Request *, sc_MPI_Status *);
00266 int                 sc_MPI_Waitsome (int, sc_MPI_Request *,
00267                                      int *, int *, sc_MPI_Status *);
00268 int                 sc_MPI_Waitall (int, sc_MPI_Request *, sc_MPI_Status *);
00269 
00270 #endif /* !SC_ENABLE_MPI */
00271 
00272 #if defined SC_ENABLE_MPI && defined SC_ENABLE_MPITHREAD
00273 
00274 #define sc_MPI_THREAD_SINGLE       MPI_THREAD_SINGLE
00275 #define sc_MPI_THREAD_FUNNELED     MPI_THREAD_FUNNELED
00276 #define sc_MPI_THREAD_SERIALIZED   MPI_THREAD_SERIALIZED
00277 #define sc_MPI_THREAD_MULTIPLE     MPI_THREAD_MULTIPLE
00278 
00279 #define sc_MPI_Init_thread         MPI_Init_thread
00280 
00281 #else
00282 
00283 #define sc_MPI_THREAD_SINGLE       0
00284 #define sc_MPI_THREAD_FUNNELED     1
00285 #define sc_MPI_THREAD_SERIALIZED   2
00286 #define sc_MPI_THREAD_MULTIPLE     3
00287 
00288 int                 sc_MPI_Init_thread (int *argc, char ***argv,
00289                                         int required, int *provided);
00290 
00291 #endif /* !(SC_ENABLE_MPI && SC_ENABLE_MPITHREAD) */
00292 
00297 size_t              sc_mpi_sizeof (sc_MPI_Datatype t);
00298 
00299 SC_EXTERN_C_END;
00300 
00301 #endif /* !SC_MPI_H */
 All Data Structures Files Functions Variables Typedefs Defines