File: mpich1.h

package info (click to toggle)
paraview 3.14.1-6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 234,468 kB
  • sloc: cpp: 2,166,013; ansic: 801,575; xml: 58,068; tcl: 49,247; python: 43,091; java: 16,625; fortran: 12,224; sh: 11,722; yacc: 5,688; perl: 3,128; makefile: 2,228; lex: 1,311; lisp: 486; asm: 471; pascal: 228
file content (160 lines) | stat: -rw-r--r-- 5,025 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef PyMPI_COMPAT_MPICH1_H
#define PyMPI_COMPAT_MPICH1_H

/* ---------------------------------------------------------------- */

/* this does not actually work in parallel, */
/* but avoids a nasty segfault.             */

static int    PyMPI_MPICH1_argc    = 0;
static char **PyMPI_MPICH1_argv    = 0;
static char  *PyMPI_MPICH1_args[2] = {0, 0};

static void PyMPI_MPICH1_FixArgs(int **argc, char ****argv)
{
  if ((argc[0]==(int *)0) || (argv[0]==(char ***)0)) {
#ifdef Py_PYTHON_H
#if PY_MAJOR_VERSION >= 3
  PyMPI_MPICH1_args[0] = (char *) "python";
#else
  PyMPI_MPICH1_args[0] = Py_GetProgramName();
#endif
  PyMPI_MPICH1_argc = 1;
#endif
  PyMPI_MPICH1_argv = PyMPI_MPICH1_args;
  argc[0] = &PyMPI_MPICH1_argc;
  argv[0] = &PyMPI_MPICH1_argv;
  }
}

static int PyMPI_MPICH1_MPI_Init(int *argc, char ***argv)
{
  PyMPI_MPICH1_FixArgs(&argc, &argv);
  return MPI_Init(argc, argv);
}
#undef  MPI_Init
#define MPI_Init PyMPI_MPICH1_MPI_Init

static int PyMPI_MPICH1_MPI_Init_thread(int *argc, char ***argv,
                                        int required, int *provided)
{
  PyMPI_MPICH1_FixArgs(&argc, &argv);
  return MPI_Init_thread(argc, argv, required, provided);
}
#undef  MPI_Init_thread
#define MPI_Init_thread PyMPI_MPICH1_MPI_Init_thread

/* ---------------------------------------------------------------- */

static int PyMPI_MPICH1_MPI_Status_set_elements(MPI_Status *status,
                                                MPI_Datatype datatype,
                                                int count)
{
  if (datatype == MPI_DATATYPE_NULL) return MPI_ERR_TYPE;
  return MPI_Status_set_elements(status, datatype, count);
}
#undef  MPI_Status_set_elements
#define MPI_Status_set_elements PyMPI_MPICH1_MPI_Status_set_elements

/* ---------------------------------------------------------------- */

static int PyMPI_MPICH1_MPI_Sendrecv(void *sendbuf,
                                     int sendcount,
                                     MPI_Datatype sendtype,
                                     int dest,
                                     int sendtag,
                                     void *recvbuf,
                                     int recvcount,
                                     MPI_Datatype recvtype,
                                     int source,
                                     int recvtag,
                                     MPI_Comm comm,
                                     MPI_Status *status)
{
  MPI_Status dummy;
  if (status == MPI_STATUS_IGNORE) status = &dummy;
  return MPI_Sendrecv(sendbuf, sendcount, sendtype, dest,   sendtag,
                      recvbuf, recvcount, recvtype, source, recvtag,
                      comm, status);
}
#undef  MPI_Sendrecv
#define MPI_Sendrecv PyMPI_MPICH1_MPI_Sendrecv

/* ---------------------------------------------------------------- */

#if defined(ROMIO_VERSION)

#if defined(__cplusplus)
extern "C" {
#endif

#define MPIR_COOKIE unsigned long cookie;
  struct MPIR_Errhandler {
    MPIR_COOKIE
    MPI_Handler_function *routine;
    int                  ref_count;
  };
  void *MPIR_ToPointer(int);

#if defined(__cplusplus)
}
#endif

static int PyMPI_MPICH1_MPI_File_get_errhandler(MPI_File file,
                                                MPI_Errhandler *errhandler)
{
  int ierr = MPI_SUCCESS;
  ierr = MPI_File_get_errhandler(file, errhandler);
  if (ierr != MPI_SUCCESS) return ierr;
  if (errhandler == 0) return ierr; /* just in case  */
  /* manage reference counting */
  if (*errhandler != MPI_ERRHANDLER_NULL) {
  struct MPIR_Errhandler *eh =
    (struct MPIR_Errhandler *) MPIR_ToPointer(*errhandler);
  if (eh) eh->ref_count++;
  }
  return MPI_SUCCESS;
}

static int PyMPI_MPICH1_MPI_File_set_errhandler(MPI_File file,
                                                MPI_Errhandler errhandler)
{
  int ierr = MPI_SUCCESS;
  MPI_Errhandler previous = MPI_ERRHANDLER_NULL;
  ierr = MPI_File_get_errhandler(file, &previous);
  if (ierr != MPI_SUCCESS) return ierr;
  ierr = MPI_File_set_errhandler(file, errhandler);
  if (ierr != MPI_SUCCESS) return ierr;
  /* manage reference counting */
  if (previous != MPI_ERRHANDLER_NULL) {
  struct MPIR_Errhandler *eh =
    (struct MPIR_Errhandler *) MPIR_ToPointer(previous);
  if (eh) eh->ref_count--;
  }
  if (errhandler != MPI_ERRHANDLER_NULL) {
  struct MPIR_Errhandler *eh =
    (struct MPIR_Errhandler *) MPIR_ToPointer(errhandler);
  if (eh) eh->ref_count++;
  }
  return MPI_SUCCESS;
}

#undef  MPI_File_get_errhandler
#define MPI_File_get_errhandler PyMPI_MPICH1_MPI_File_get_errhandler

#undef  MPI_File_set_errhandler
#define MPI_File_set_errhandler PyMPI_MPICH1_MPI_File_set_errhandler

#endif /* !ROMIO_VERSION */

/* ---------------------------------------------------------------- */

#undef  MPI_ERR_KEYVAL
#define MPI_ERR_KEYVAL MPI_ERR_OTHER

#undef  MPI_MAX_OBJECT_NAME
#define MPI_MAX_OBJECT_NAME MPI_MAX_NAME_STRING

/* ---------------------------------------------------------------- */

#endif /* !PyMPI_COMPAT_MPICH1_H */