-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtask_division_prb.cpp
108 lines (93 loc) · 2.46 KB
/
task_division_prb.cpp
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
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <ctime>
# include <cmath>
using namespace std;
# include "task_division.hpp"
int main ( int argc, char *argv[] );
//****************************************************************************80
int main ( int argc, char *argv[] )
//****************************************************************************80
//
// Purpose:
//
// MAIN is the main program for TASK_DIVISION_PRB.
//
// Discussion:
//
// TASK_DIVISION_PRB tests the TASK_DIVISION library.
//
// This program simply demonstrates how one might automate the
// assignment of T tasks to P processors, assuming that the assignment
// is to be beforehand.
//
// In that case, we just want to make sure that we assign each task
// to a processor, that we assign about the same number of tasks
// to each processor, and that we assign each processor a contiguous
// range of tasks, say tasks I_LO to I_HI.
//
// The routine that is called simulates this process.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 23 October 2011
//
// Author:
//
// John Burkardt
//
{
int proc_first;
int proc_last;
int task_number;
timestamp ( );
cout << "\n";
cout << "TASK_DIVISION_PRB:\n";
cout << " C++ version\n";
cout << " Test the TASK_DIVISION library.\n";
cout << " Demonstrate how to automate the division of\n";
cout << " T tasks among a range of P processors\n";
cout << " indexed from PROC_FIRST to PROC_LAST.\n";
task_number = 23;
proc_first = 0;
proc_last = 3;
task_division ( task_number, proc_first, proc_last );
task_number = 17;
proc_first = 1;
proc_last = 6;
task_division ( task_number, proc_first, proc_last );
task_number = 17;
proc_first = 4;
proc_last = 6;
task_division ( task_number, proc_first, proc_last );
task_number = 5;
proc_first = -2;
proc_last = 6;
task_division ( task_number, proc_first, proc_last );
task_number = 5;
proc_first = 0;
proc_last = 4;
task_division ( task_number, proc_first, proc_last );
task_number = 5;
proc_first = 0;
proc_last = 0;
task_division ( task_number, proc_first, proc_last );
task_number = 1000;
proc_first = 1;
proc_last = 17;
task_division ( task_number, proc_first, proc_last );
//
// Terminate.
//
cout << "\n";
cout << "TASK_DIVISION_PRB:\n";
cout << " Normal end of execution.\n";
cout << "\n";
timestamp ( );
return 0;
}