IOR
iordef.h
Go to the documentation of this file.
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 /******************************************************************************\
5 * *
6 * Copyright (c) 2003, The Regents of the University of California *
7 * See the file COPYRIGHT for a complete copyright notice and license. *
8 * *
9 \******************************************************************************/
10 
11 #ifndef _IORDEF_H
12 #define _IORDEF_H
13 
14 #ifdef HAVE_CONFIG_H
15 # include "config.h"
16 #endif
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <errno.h>
22 #include <mpi.h>
23 
24 #ifdef _WIN32
25 # define _CRT_SECURE_NO_WARNINGS
26 # define _CRT_RAND_S
27 # pragma warning(4 : 4996) /* Don't complain about POSIX names */
28 # pragma warning(4 : 4267) /* '=' : conversion from 'size_t' to 'int' */
29 # pragma warning(4 : 4244) /* 'function' : conversion from 'IOR_offset_t' to 'int' */
30 
31 # include <Windows.h>
32 # include <io.h>
33 # include <direct.h>
34 
35 # define F_OK 00
36 # define W_OK 02
37 # define R_OK 04
38 # define X_OK 04
39 
40 # define lseek _lseeki64
41 # define fsync _commit
42 # define mkdir(dir, mode) _mkdir(dir)
43 # define strcasecmp _stricmp
44 # define strncasecmp _strnicmp
45 # define srandom srand
46 # define random() (rand() * (RAND_MAX+1) + rand()) /* Note: only 30 bits */
47 # define sleep(X) Sleep((X)*1000)
48 # define getpagesize() 4096
49 #else
50 # include <sys/param.h> /* MAXPATHLEN */
51 # include <unistd.h>
52 # include <limits.h>
53 #endif
54 
55 /************************** D E C L A R A T I O N S ***************************/
56 
57 extern int numTasks; /* MPI variables */
58 extern int rank;
59 extern int rankOffset;
60 extern int verbose; /* verbose output */
61 
62 /*************************** D E F I N I T I O N S ****************************/
63 
68 };
69 
70 #ifndef FALSE
71 # define FALSE 0
72 #endif /* not FALSE */
73 
74 #ifndef TRUE
75 # define TRUE 1
76 #endif /* not TRUE */
77 
78 #ifndef NULL
79 # define NULL ((void *)0)
80 #endif /* not NULL */
81 
82 #define KILOBYTE 1000
83 #define MEGABYTE 1000000
84 #define GIGABYTE 1000000000
85 
86 #define KIBIBYTE (1 << 10)
87 #define MEBIBYTE (1 << 20)
88 #define GIBIBYTE (1 << 30)
89 
90 /* for displaying MiB or MB */
91 #define BASE_TWO 0
92 #define BASE_TEN 1
93 
94 /* any write/read access in code */
95 #define WRITE 0
96 #define WRITECHECK 1
97 #define READ 2
98 #define READCHECK 3
99 #define CHECK 4
100 
101 /* verbosity settings */
102 #define VERBOSE_0 0
103 #define VERBOSE_1 1
104 #define VERBOSE_2 2
105 #define VERBOSE_3 3
106 #define VERBOSE_4 4
107 #define VERBOSE_5 5
108 
109 #define MAX_STR 1024 /* max string length */
110 #define MAX_HINTS 16 /* max number of hints */
111 #define MAX_RETRY 10000 /* max retries for POSIX xfer */
112 #ifndef PATH_MAX
113 #define PATH_MAX 4096
114 #endif
115 
116 #define DELIMITERS " \t\r\n=" /* ReadScript() */
117 #define FILENAME_DELIMITER '@' /* ParseFileName() */
118 
119 /* MACROs for debugging */
120 #define HERE fprintf(stdout, "** LINE %d (TASK=%d) **\n", \
121  __LINE__, rank);
122 
123 typedef long long int IOR_offset_t;
124 typedef long long int IOR_size_t;
125 
126 #define IOR_format "%016llx"
127 
128 
129 /******************************** M A C R O S *********************************/
130 
131 /******************************************************************************/
132 /*
133  * WARN_RESET will display a custom error message and set value to default
134  */
135 #define WARN_RESET(MSG, TO_STRUCT_PTR, FROM_STRUCT_PTR, MEMBER) do { \
136  (TO_STRUCT_PTR)->MEMBER = (FROM_STRUCT_PTR)->MEMBER; \
137  if (rank == 0) { \
138  fprintf(stdout, "ior WARNING: %s. Using value of %d.\n", \
139  MSG, (TO_STRUCT_PTR)->MEMBER); \
140  } \
141  fflush(stdout); \
142 } while (0)
143 
144 
145 #define WARN(MSG) do { \
146  if (verbose > VERBOSE_2) { \
147  fprintf(stdout, "ior WARNING: %s, (%s:%d).\n", \
148  MSG, __FILE__, __LINE__); \
149  } else { \
150  fprintf(stdout, "ior WARNING: %s.\n", MSG); \
151  } \
152  fflush(stdout); \
153 } while (0)
154 
155 /* warning with errno printed */
156 #define EWARN(MSG) do { \
157  if (verbose > VERBOSE_2) { \
158  fprintf(stdout, "ior WARNING: %s, errno %d, %s (%s:%d).\n", \
159  MSG, errno, strerror(errno), __FILE__, __LINE__); \
160  } else { \
161  fprintf(stdout, "ior WARNING: %s, errno %d, %s \n", \
162  MSG, errno, strerror(errno)); \
163  } \
164  fflush(stdout); \
165 } while (0)
166 
167 
168 /* display error message and terminate execution */
169 #define ERR(MSG) do { \
170  fprintf(stdout, "ior ERROR: %s, errno %d, %s (%s:%d)\n", \
171  MSG, errno, strerror(errno), __FILE__, __LINE__); \
172  fflush(stdout); \
173  MPI_Abort(MPI_COMM_WORLD, -1); \
174 } while (0)
175 
176 
177 /* display a simple error message (i.e. errno is not set) and terminate execution */
178 #define ERR_SIMPLE(MSG) do { \
179  fprintf(stdout, "ior ERROR: %s, (%s:%d)\n", \
180  MSG, __FILE__, __LINE__); \
181  fflush(stdout); \
182  MPI_Abort(MPI_COMM_WORLD, -1); \
183 } while (0)
184 
185 
186 /******************************************************************************/
187 /*
188  * MPI_CHECK will display a custom error message as well as an error string
189  * from the MPI_STATUS and then exit the program
190  */
191 
192 #define MPI_CHECK(MPI_STATUS, MSG) do { \
193  char resultString[MPI_MAX_ERROR_STRING]; \
194  int resultLength; \
195  \
196  if (MPI_STATUS != MPI_SUCCESS) { \
197  MPI_Error_string(MPI_STATUS, resultString, &resultLength); \
198  fprintf(stdout, "ior ERROR: %s, MPI %s, (%s:%d)\n", \
199  MSG, resultString, __FILE__, __LINE__); \
200  fflush(stdout); \
201  MPI_Abort(MPI_COMM_WORLD, -1); \
202  } \
203 } while(0)
204 
205 
206 /******************************************************************************/
207 /*
208  * System info for Windows.
209  */
210 
211 #ifdef _WIN32
212 
213 struct utsname {
214  char sysname [16];
215  char nodename[257];
216  char release [16];
217  char version [16];
218  char machine [16];
219 };
220 
221 extern int uname(struct utsname *name);
222 
223 #endif /* _WIN32 */
224 
225 #endif /* not _IORDEF_H */
OutputFormat_t
Definition: iordef.h:64
int verbose
Definition: utilities.c:60
int rankOffset
Definition: utilities.c:58
long long int IOR_size_t
Definition: iordef.h:124
int rank
Definition: utilities.c:57
long long int IOR_offset_t
Definition: iordef.h:123
int numTasks