-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest (another copy).jdf
More file actions
215 lines (168 loc) · 4.31 KB
/
test (another copy).jdf
File metadata and controls
215 lines (168 loc) · 4.31 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
extern "C" %{
/**
* This second example shows how to create a simple jdf that has only one single task.
* JDF syntax
* parsec_JDFNAME_New()
* parsec_context_add_taskpool()
* parsec_data_collection_init()
*
* Can play with the HelloWorld bounds to show embarissingly parallel algorithm.
*
* @version 3.0
* @email parsec-users@icl.utk.edu
*
*/
#include "parsec.h"
#include "parsec/data_dist/matrix/matrix.h"
#include "parsec/data_dist/matrix/two_dim_rectangle_cyclic.h"
%}
data_A [ type="parsec_matrix_block_cyclic_t*" ]
rank [ type="int" ]
nodes [ type="int" ]
matrix_size_m [ type="int" ] // row number
matrix_size_n [ type="int" ] // column number
matrix_in_depth [ type="int" ]
WriteA(k)
k = 0 .. %{ return nodes-1; %}
: data_A( k )
//RW A <- data_A( k )
// -> A ReadA(k)
WRITE A <- NEW
-> A ReadA(k)
BODY
{
int *Aint = (int*)A;
//int *Bint = (int*)B;
*Aint = k*k;
printf("[%d] Wrote %d\n", rank, *Aint );
}
END
ReadA(k)
k = 0 .. %{ return nodes-1; %}
: data_A( k )
READ A <- A WriteA( k )
BODY
{
//printf("HelloWorld %d, %d\n", k, nodes);
int *Aint = (int*)A;
printf("[%d] Recv %d\n", rank, *Aint );
}
END
extern "C" %{
static uint32_t
rank_of(parsec_data_collection_t *desc, ...)
{
(void)desc;
return 0;
}
static int32_t
vpid_of(parsec_data_collection_t *desc, ...)
{
(void)desc;
return 0;
}
static parsec_data_t *ddata_A = NULL;
static parsec_data_t *
data_of_A(parsec_data_collection_t *desc, ...)
{
(void)desc;
return ddata_A;
}
static parsec_data_t *ddata_B = NULL;
static parsec_data_t *
data_of_B(parsec_data_collection_t *desc, ...)
{
(void)desc;
return ddata_B;
}
static parsec_data_t *ddata_C = NULL;
static parsec_data_t *
data_of_C(parsec_data_collection_t *desc, ...)
{
(void)desc;
return ddata_C;
}
static parsec_data_key_t
data_key(parsec_data_collection_t *desc, ...)
{
int k;
va_list ap;
(void)desc;
va_start(ap, desc);
k = va_arg(ap, int);
va_end(ap);
return (uint64_t)k;
}
#define MATRIX_M 5
#define MATRIX_N 6
#define MATRIX_DEPTH 15
int main(int argc, char *argv[])
{
parsec_context_t* parsec;
int rc;
int rank, world;
parsec_taskpool_t *tp;
parsec_data_collection_t data_A, data_B, data_C;
//int mycounter;
#if defined(PARSEC_HAVE_MPI)
{
int provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
}
MPI_Comm_size(MPI_COMM_WORLD, &world);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
#else
world = 1;
rank = 0;
#endif
parsec = parsec_init(-1, &argc, &argv);
parsec_data_collection_init(&data_A, world, rank);
data_A.rank_of = rank_of;
data_A.vpid_of = vpid_of;
data_A.data_key = data_key;
data_A.data_of = data_of_A;
parsec_data_collection_init(&data_B, world, rank);
data_B.rank_of = rank_of;
data_B.vpid_of = vpid_of;
data_B.data_key = data_key;
data_B.data_of = data_of_B;
parsec_data_collection_init(&data_C, world, rank);
data_C.rank_of = rank_of;
data_C.vpid_of = vpid_of;
data_C.data_key = data_key;
data_C.data_of = data_of_C;
//mycounter = 300 + rank;
int test_data = 0;
ddata_A = parsec_data_create(
&ddata_A, &data_A, 0,
&test_data, sizeof(int),
PARSEC_DATA_FLAG_PARSEC_MANAGED);
ddata_B = parsec_data_create(
&ddata_B, &data_B, 0,
&test_data, sizeof(int),
PARSEC_DATA_FLAG_PARSEC_MANAGED);
ddata_C = parsec_data_create(
&ddata_C, &data_C, 0,
&test_data, sizeof(int),
PARSEC_DATA_FLAG_PARSEC_MANAGED);
tp = (parsec_taskpool_t*)parsec_test_new(rank, world, MATRIX_M, MATRIX_N, MATRIX_DEPTH);
rc = parsec_context_add_taskpool( parsec, tp );
PARSEC_CHECK_ERROR(rc, "parsec_context_add_taskpool");
rc = parsec_context_start(parsec);
PARSEC_CHECK_ERROR(rc, "parsec_context_start");
rc = parsec_context_wait(parsec);
PARSEC_CHECK_ERROR(rc, "parsec_context_wait");
parsec_taskpool_free(tp);
parsec_data_destroy( ddata_A );
parsec_data_destroy( ddata_B );
parsec_data_destroy( ddata_C );
parsec_data_collection_destroy(&data_A);
parsec_data_collection_destroy(&data_B);
parsec_data_collection_destroy(&data_C);
parsec_fini(&parsec);
#if defined(PARSEC_HAVE_MPI)
MPI_Finalize();
#endif
return 0;
}
%}