-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.h
169 lines (143 loc) · 4.69 KB
/
main.h
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
161
162
163
164
165
166
167
168
169
/* tab:8
*
* main.h - Image Understanding Project
*
*
* "Copyright (c) 1994,1995 The Regents of the University of Maryland.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice and the following
* two paragraphs appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF MARYLAND BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* MARYLAND HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF MARYLAND SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF MARYLAND HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Authors: David A. Bader <dbader@umiacs.umd.edu>
* Joseph F. Ja'Ja' <joseph@umiacs.umd.edu>
* Institute for Advanced Computer Studies
* Department of Electrical Engineering
* AV Williams Building
* College Park, MD 20742
*
* Version: 2
* Creation Date: October 20, 1994
* Filename: main.h
* History:
*/
#ifndef _MAIN_H
#define _MAIN_H
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <mpi.h>
/* #include "mpi-printf.h" */
#define VER_MAJOR 3
#define VER_MINOR 6
#define MAXPROCS 64
extern int MYPROC, PROCS;
extern int PROCSLOG;
#ifdef MALLOC_DEBUG
#include "rmalloc.h"
#endif
#if 0
#define _INLINE extern inline
#else
#define _INLINE static
#endif
#if (defined(FBSD)||defined(AIX)||defined(SUN)||defined(LINUX))
#define log2(d) (log(d) / log(2.0))
#endif
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef CAT
#define CAT(a,b) a##b
#endif
#define errprnt(msg) { fprintf(stderr,"connComp: %s\n",msg); exit(1); }
FILE *outfile;
int watch_proc, /* Processor to debug */
OUTPUT_IMAGE, /* Output Image Status Bits */
UNSUPPARAM, /* Parameter for all_unsupported */
DO_TEST, /* Test machine specifics */
DO_UNSUP, /* Unsupported testing routines */
DO_HISTO, /* Do a histogram? */
DO_CCBIN, /* Do a binary 8-connected component? */
DO_CCBIF, /* Do a binary 4-connected component? */
DO_CCGRY, /* Do a grey-level 8-connected component? */
DO_CCGRF, /* Do a grey-level 4-connected component? */
DO_CCGRYL, /* Do a l-grey-level 8-connected component? */
DO_SEGM, /* Do Image Segmentation */
DO_GBLUR, /* Do Blur of image */
DO_BENCHMARK, /* Perform the benchmark suite? */
RESULTS; /* Print verbose results? */
#define MAXLEN 80
#define MAX_TIMER 256
double timer[MAX_TIMER];
int timer_cnt;
char timer_msg[MAX_TIMER][MAXLEN];
_INLINE void all_init_timer() {
MPI_Barrier(MPI_COMM_WORLD);
timer_cnt = 0;
}
_INLINE void all_start_timer() {
MPI_Barrier(MPI_COMM_WORLD);
if (timer_cnt >= MAX_TIMER) {
fprintf(stderr,"ERROR: Ran out of timers.\n");
exit(1);
}
timer[timer_cnt] = MPI_Wtime();
}
_INLINE void all_stop_timer(char* msg) {
MPI_Barrier(MPI_COMM_WORLD);
timer[timer_cnt] = MPI_Wtime() - timer[timer_cnt];
strcpy(timer_msg[timer_cnt], msg);
timer_cnt++;
}
_INLINE void all_print_timer(FILE* strm) {
register int i;
if (MYPROC==0) {
fprintf(strm,"\n");
fprintf(strm,"Timers:\n");
for (i=0 ; i<timer_cnt ; i++)
fprintf(strm,"%9.6f for %s\n",timer[i],timer_msg[i]);
fprintf(strm,"\n");
}
}
_INLINE void all_print_timer_PS(FILE* strm) {
register int i;
if (MYPROC==0) {
fprintf(strm,"\n");
fprintf(strm,"Prefix-Sums of Timers:\n");
for (i=1 ; i<timer_cnt ; i++)
timer[i] += timer[i-1];
for (i=0 ; i<timer_cnt ; i++)
fprintf(strm,"%9.6f for %s\n",timer[i],timer_msg[i]);
fprintf(strm,"\n");
}
}
_INLINE void assert_malloc(void *ptr) {
if (ptr==NULL) {
fprintf(stderr,"ERROR: PE%2d cannot malloc\n",MYPROC);
fflush(stderr);
exit(1);
}
}
#define MODPROCS(a) ((a) & (PROCS-1))
#define DIVPROCS(a) ((a) >> PROCSLOG)
#define NIL -1
#endif