aboutsummaryrefslogtreecommitdiff
path: root/src/Panda/definitions.h
blob: 32c4da06b8155ffb36b124987f820c38c7e3218c (plain)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#ifndef definitions_dot_h
#define definitions_dot_h

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#include "cctk.h"

extern "C"  {int fsync(int f);}



#define START  0
#define WAITING 1

/* Different I/O strategies */
#define SIMPLE_IO 1
#define CSDIO_IO 2

/* The different possible nodetypes */
#define COMPUTE_NODE 0
#define IO_NODE 1
#define PART_TIME_COMPUTE 2
#define PART_TIME_IO 3
#define SUB_CHUNK 4
#define PART_TIME 5


/* Unix or MPI based file system */
#define MPI_SYSTEM 0
#define UNIX_SYSTEM 1

/* Different kinds of collective I/O operations */
#define RESTART 0
#define READ_TIMESTEP 1
#define GENERAL_READ 2
#define CHECKPOINT 3
#define TIMESTEP 4
#define GENERAL_WRITE 5


/* Tags to indicate the type of the message */

/* #define NO_MESSAGE 10
   #define SPECIAL     9
   #define ARRAYGROUP_SCHEMA 8
   #define CHUNK_DATA_TO_IO  7
   #define APP_IO_DONE 6
   #define QUIT 5
   #define COMP_QUIT 4
   #define CHUNK_SCHEMA 3
   #define CHUNK_DATA_FROM_IO 2
   #define CHUNK_SCHEMA_DATA 1
*/
/* Modified it to make it compatible with my thesis */
#define CHUNK_SCHEMA       1
#define CHUNK_DATA_FROM_IO 2
#define CHUNK_DATA_TO_IO   3

#define COMP_QUIT          4
#define QUIT               5
#define ATTRIBUTE_SCHEMA   6 
#define ATTRIBUTE_DATA     7 

#define ARRAYGROUP_SCHEMA  8
#define SPECIAL            9
#define NO_MESSAGE        10

/* Tags to indicate the type of special operatiosn required */
#define APP_INFO 1
#define APP_BARRIER 2
#define GLOBAL_BARRIER 3
#define CLEANFILES 4
#define FLUSHFILES 5
#define CREATEFILES 6

typedef enum { UNSET,
               Regular,
               Irregular
             } Distribution_Type;

typedef enum { NONE,
	       BLOCK,
	       GENERAL,
               CYCLIC
	       } Distribution;

typedef enum { HPF,
               NAS,
               GENERAL_BLOCK
               } Block_Distribution;

typedef enum { ROUND_ROBIN,
               REGULAR
               } ChunkAllocPolicy;


typedef enum { NO = 0,
               YES = 1
	       } Boolean;


typedef enum { ALLOC,
	       NO_ALLOC,
	       SHARED
	       } DataStatus;
		 


inline int max(int a, int b)
{
  if (a > b) return a;
  else return b;
}

inline int min(int a, int b)
{
  if (a < b) return a;
  else return b;
}


inline int* copy_int_list(int s, int *l)
{
  int *ret_list = (int *) malloc(sizeof(int)*s);
  for(int i=0;i<s;i++)
    ret_list[i] = l[i];
  return ret_list;
}



inline Distribution* copy_distribution(int num, Distribution *ptr)
{
  Distribution *ret_list = (Distribution *)malloc(sizeof(Distribution)*num);
  
  for(int i=0; i < num; i++)
     ret_list[i] = ptr[i];

  return ret_list;
}


inline Boolean equal_distribution(int size, Distribution* dist1, Distribution* dist2)
{
  for(int i=0; i < size; i++)
  {
    if (dist1[i] != dist2[i])
	return NO;
  }
  return YES;
}

inline void pack_distribution(int **schema_buf, int rank, Distribution *in_dist)
{
  Distribution *dist = in_dist;
  int* ptr = *schema_buf;
  
  for(int i=0;i<rank;i++)
  	*ptr++ = (int) dist[i];  
  *schema_buf = ptr;
}

inline Distribution* new_distribution(int **schema_buf, int rank)
{
  Distribution *dist = (Distribution*) malloc(sizeof(Distribution)*rank);
  int *ptr = *schema_buf;
  
  for(int i=0;i<rank;i++)
     dist[i] = (Distribution) *ptr++;

  *schema_buf = ptr;
  return  dist;

}

inline int num_elements(int r, int *size)
{
  int total=1;
  for(int i=0;i<r;i++) total *= size[i];
  return total;
}

           
#endif