changed reading hint
[gromacs/adressmacs.git] / src / fftw / test_sched.c
blobe3e9c746f4646133727904fb462800ca5c084df0
1 /*
2 * Copyright (c) 1997-1999 Massachusetts Institute of Technology
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <stdio.h>
21 #include <stdlib.h>
23 #include "sched.h"
25 int main(int argc, char **argv)
27 int **sched;
28 int npes = -1, mype, sortpe = -1, steps;
30 if (argc >= 2) {
31 npes = atoi(argv[1]);
32 if (npes <= 0) {
33 fprintf(stderr,"npes must be positive!");
34 return 1;
37 if (argc >= 3) {
38 sortpe = atoi(argv[2]);
39 if (sortpe < 0 || sortpe >= npes) {
40 fprintf(stderr,"sortpe must be between 0 and npes-1.\n");
41 return 1;
45 if (npes != -1) {
46 printf("Computing schedule for npes = %d:\n",npes);
47 sched = make_comm_schedule(npes);
48 if (!sched) {
49 fprintf(stderr,"Out of memory!");
50 return 6;
53 if (steps = check_comm_schedule(sched,npes))
54 printf("schedule OK (takes %d steps to complete).\n", steps);
55 else
56 printf("schedule not OK.\n");
58 print_comm_schedule(sched, npes);
60 if (sortpe != -1) {
61 printf("\nSorting schedule for sortpe = %d...\n", sortpe);
62 sort_comm_schedule(sched,npes,sortpe);
64 if (steps = check_comm_schedule(sched,npes))
65 printf("schedule OK (takes %d steps to complete).\n",
66 steps);
67 else
68 printf("schedule not OK.\n");
70 print_comm_schedule(sched, npes);
72 printf("\nInverting schedule...\n");
73 invert_comm_schedule(sched,npes);
75 if (steps = check_comm_schedule(sched,npes))
76 printf("schedule OK (takes %d steps to complete).\n",
77 steps);
78 else
79 printf("schedule not OK.\n");
81 print_comm_schedule(sched, npes);
83 free_comm_schedule(sched,npes);
86 else {
87 printf("Doing infinite tests...\n");
88 for (npes = 1; ; ++npes) {
89 printf("npes = %d...",npes);
90 sched = make_comm_schedule(npes);
91 if (!sched) {
92 fprintf(stderr,"Out of memory!\n");
93 return 5;
95 for (sortpe = 0; sortpe < npes; ++sortpe) {
96 empty_comm_schedule(sched,npes);
97 fill_comm_schedule(sched,npes);
98 if (!check_comm_schedule(sched,npes)) {
99 fprintf(stderr,
100 "\n -- fill error for sortpe = %d!\n",sortpe);
101 return 2;
103 sort_comm_schedule(sched,npes,sortpe);
104 if (!check_comm_schedule(sched,npes)) {
105 fprintf(stderr,
106 "\n -- sort error for sortpe = %d!\n",sortpe);
107 return 3;
109 invert_comm_schedule(sched,npes);
110 if (!check_comm_schedule(sched,npes)) {
111 fprintf(stderr,
112 "\n -- invert error for sortpe = %d!\n",
113 sortpe);
114 return 4;
117 free_comm_schedule(sched,npes);
118 printf("OK\n");
119 if (npes % 50 == 0)
120 printf("(...Hit Ctrl-C to stop...)\n");
124 return 0;