5
static int test(int shape_idx, int type_idx, int dist_idx)
7
int type = TYPES[type_idx];
8
int *dims = SHAPES[shape_idx];
9
int ndim = SHAPES_NDIM[shape_idx];
10
mock_ga_t *mock_a, *result_a, *mock_b, *result_b;
13
int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
14
int result=0, error_index=-1, error_proc=-1;
16
/* create the local array and result array */
17
mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
18
result_a = Mock_Create(type, ndim, dims, "mock", NULL);
20
mock_b = Mock_Create(type, ndim, dims, "mock", NULL);
21
result_b = Mock_Create(type, ndim, dims, "mock", NULL);
23
/* create the global array */
24
g_a = create_function[dist_idx](type, ndim, dims);
25
g_b = create_function[dist_idx](type, ndim, dims);
27
/* create meaningful data for local array */
28
mock_data(mock_a, g_a);
29
mock_data(mock_b, g_b);
31
/* init global array with same data as local array */
32
mock_to_global(mock_a, g_a);
33
mock_to_global(mock_b, g_b);
35
/* call the local routine */
36
Mock_Copy(mock_a, mock_b);
38
/* call the global routine */
41
/* get the results from the global array */
42
global_to_mock(g_a, result_a);
43
global_to_mock(g_b, result_b);
45
/* compare the results */
46
result = neq_mock(result_a, result_b, &error_index);
48
error_proc = GA_Nodeid();
50
/* make sure all procs get same result so they can die gracefully */
51
GA_Igop(&result, 1, "+");
52
/* if error occured, find the highest failing node ID */
53
GA_Igop(&error_proc, 1, "max");
54
/* clear the error index for all but the highest failing node ID */
55
if (error_proc != GA_Nodeid()) {
58
/* make sure all procs get the error index on the highest failing node ID */
59
GA_Igop(&error_index, 1, "+");
61
if (error_proc == GA_Nodeid()) {
62
printf("ERROR: local result failed to compare to global result\n");
63
printf("\terror_proc=%d\n", error_proc);
64
printf("\terror_index=%d\n", error_index);
65
printf("***LOCAL RESULT***\n");
67
printf("***GLOBAL RESULT***\n");
69
printf("\tprinting array distribution\n");
73
GA_Print_distribution(g_a);
79
Mock_Destroy(result_a);
86
int main(int argc, char **argv)
90
int shape_idx=0, type_idx=0, dist_idx=0;
93
for (shape_idx=0; shape_idx < NUM_SHAPES; ++shape_idx) {
94
for (type_idx=0; type_idx < NUM_TYPES; ++type_idx) {
95
for (dist_idx=0; dist_idx < NUM_DISTS; ++dist_idx) {
96
if (0 == GA_Nodeid()) {
97
printf("%s\t%s\t%s\n",
98
SHAPE_NAMES[shape_idx],
104
return_code = test(shape_idx, type_idx, dist_idx);
105
if (0 != return_code) {
109
if (0 != return_code) {
113
if (0 != return_code) {