28 int main(
int argc,
char *argv[]) {
32 unsigned long glen = 10;
37 sscanf(argv[4],
"%lu",&bz);
39 sscanf(argv[3],
"%lu",&glen);
42 sscanf(argv[1],
"%lu",&stopo.
total);
43 sscanf(argv[2],
"%lu",&dtopo.
total);
46 cerr <<
"Usage: " << argv[0] <<
" sd.total dd.total [glen [sz=0 bloc, else bloccyclic(sz)]]\n";
50 cerr <<
"stopo: " << stopo.
total << endl;
51 cerr <<
"dtopo: " << dtopo.
total << endl;
62 cerr <<
" glen: " << glen << endl;
65 unsigned ** comm_matrix =
new unsigned *[stopo.
total];
66 unsigned* comm_area = (
unsigned*)calloc(stopo.
total*dtopo.
total,
sizeof(
unsigned));
67 if (comm_area == NULL) {
68 cerr <<
"Can not allocate memory of size " << stopo.
total*dtopo.
total*
sizeof(unsigned) << endl;
72 for(
unsigned i=0; i<stopo.
total; i++)
74 comm_matrix[i] = &comm_area[i*dtopo.
total];
78 void *** info_matrix =
new void **[stopo.
total];
79 void ** info_area = (
void**) calloc(stopo.
total*dtopo.
total*1,
sizeof(
void*));
80 if (info_area == NULL) {
81 cerr <<
"Can not allocate memory of size " << stopo.
total*dtopo.
total*
sizeof(unsigned) << endl;
84 for(
unsigned i=0; i<stopo.
total; i++)
86 info_matrix[i] = &info_area[i*dtopo.
total*1];
89 cerr<<endl<<
"##############################"<<endl;
91 for(
unsigned i=0; i<stopo.
total; i++) {
93 cerr<<endl<<
"###### Sender "<<i<<endl<<endl;
95 sd[i].setSourceTopology(stopo);
96 sd[i].setDestTopology(dtopo);
98 sd[i].setEltSize(
sizeof(
long));
99 sd[i].setTotalNbElt(glen);
100 sd[i].setBlocSize(bz);
102 long* ptr =
sdata[i] = (
long*) malloc(glen);
103 sd[i].setDataPtr((
void*) ptr);
104 for(
unsigned j=0;j<glen;j++)
109 for (
unsigned j = 0; j <
ssize[i]; j++)
113 comm_matrix[i][dest] += p.
size;
114 info_matrix[i][dest+0] = p.
id;
115 cerr <<
"p.id: " << p.
id<<endl;
118 cerr<<endl<<
"##############################"<<endl;
120 for(
unsigned i=0; i<stopo.
total; i++) {
121 cerr<<endl<<
"###### Sender "<<i<<endl;
123 cerr <<
"*** case not yet supported (cf descr)\n";
126 for(
unsigned j=0; j<
ssize[i]; j++) {
127 cerr<<
" Message "<<j;
128 fprintf(stderr,
" , %2d -> %2d : %4d octets (%p)\n",
131 long msz=
spiece[i][j].size;
134 void* ptr =
sd[i].getClientData(
spiece[i][j].
id, i, msz, mlen, b);
135 fprintf(stderr,
" #element: %2u ptr:%p -- ", mlen, ptr);
136 for(
int k=0; k<mlen; k++)
137 fprintf(stderr,
" %d", ((
int*)ptr)[k]);
138 fprintf(stderr,
"\n");
141 cerr <<
"BIIIGGGG TROUBLE: msz is not 0: " <<msz<<endl;
150 cerr<<endl<<
"##############################"<<endl;
158 for(
unsigned int i = 0 ; i < stopo.
total ; i++)
160 for(
unsigned int i = 0 ; i < dtopo.
total ; i++)
164 for (
unsigned i = 0; i < (unsigned) stopo.
total; i++)
166 for (
unsigned j = 0; j < dtopo.
total; j++)
168 edge*e = g.add_edge(g.get_node(i,
true),
169 g.get_node(j,
false),
172 cerr <<
"id: " << info_matrix[i][j]<<
" "<<e->getDecoration()<<endl;
175 g.remove_empty_nodes();
179 kbps_approximation* _schedule_info =
new kbps_approximation(&g);
180 _schedule_info->compute_poly();
181 _schedule_info->serialize();
183 _schedule_info->serial_display();
186 unsigned int phases = _schedule_info->infophases[0];
188 for(
unsigned int i = 0; i < phases; i++)
190 for(
unsigned int j = 0 ; j < _schedule_info->infophases[i+1] ; j++)
192 kbps_approximation::_comm_t& s= _schedule_info->comms[k];
193 fprintf(stderr,
" %d -> %d : %d %p\n", s.src, s.dst, s.weight, s.info);
202 for(
unsigned i=0; i<dtopo.
total; i++) {
204 cerr<<endl<<
"##############################"<<endl;
205 cerr<<
"###### Receiver "<<i<<endl<<endl;
207 dd[i].setSourceTopology(stopo);
208 dd[i].setDestTopology(dtopo);
209 dd[i].setNodeRank(i);
210 dd[i].setEltSize(
sizeof(
long));
211 dd[i].setBlocSize(bz);
int main(int argc, char *argv[])
vector< PieceToSend * > spiece