Skip to content

Commit fec6c6c

Browse files
author
alielabridi
committed
added the message packing/unpacking and put back the WaitFuture so to paralyze it
1 parent 72507aa commit fec6c6c

File tree

4 files changed

+88
-219
lines changed

4 files changed

+88
-219
lines changed

AddSubMat.h

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,13 @@ class addition :public CBase_addition{
99
thisProxy.run(f,A,B,size);
1010
}
1111
void run(CkFuture f,const std::vector<std::vector<int>>& A, const std::vector<std::vector<int>>& B, int size){
12-
//if(VERBOSE)CkPrintf("addition run 1:\n");
1312
/*wrap the resulting addition in a message of size and send it back to future*/
14-
15-
//if(VERBOSE)CkPrintf("Work done by processor %d\n",CkMyPe());
16-
CkPrintf("ADD: Work done by processor %d\n",CkMyPe());
17-
18-
1913
ValueMsg *m = new ValueMsg(size);
20-
21-
22-
23-
//if(VERBOSE)CkPrintf("addition run 1-1:\n");
24-
/* CkPrintf("the result of the addition\n");
25-
2614
for (int i = 0; i < size; ++i)
27-
{
2815
for (int j = 0; j < size; ++j)
29-
{
3016
m->v[i][j] = A[i][j] + B[i][j];
31-
CkPrintf("%d ", m->v[i][j] );
32-
}
33-
CkPrintf("\n");
34-
35-
}*/
36-
//if(VERBOSE)CkPrintf("addition run 2:\n");
37-
38-
39-
40-
//if(VERBOSE)CkPrintf("addition run 4:\n");
41-
4217
CkSendToFuture(f, m);
4318
}
44-
45-
4619
};
4720

4821
class substraction :public CBase_substraction{
@@ -52,22 +25,12 @@ class substraction :public CBase_substraction{
5225
thisProxy.run(f,A,B,size);
5326
}
5427
void run(CkFuture f,const std::vector<std::vector<int>>& A, const std::vector<std::vector<int>>& B, int size){
55-
//std::vector<std::vector<int>> C;
56-
57-
//if(VERBOSE)CkPrintf("Work done by processor %d\n",CkMyPe());
58-
CkPrintf("substraction: Work done by processor %d\n",CkMyPe());
59-
60-
ValueMsg *m = new ValueMsg(size);
61-
62-
28+
//CkPrintf("substraction: Work done by processor %d\n",CkMyPe());
29+
/*wrap the resulting addition in a message of size and send it back to future*/
30+
ValueMsg *m = new ValueMsg(size);
6331
for (int i = 0; i < size; ++i)
64-
{
6532
for (int j = 0; j < size; ++j)
66-
{
6733
m->v[i][j] = A[i][j] - B[i][j];
68-
}
69-
}
70-
/*wrap the resulting substraction in a message of size and send it back to future*/
7134
CkSendToFuture(f, m);
7235
}
7336
};

StrassenSub.h

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,73 +19,46 @@ class strassenSub: public CBase_strassenSub{
1919
int size, char partition){
2020
std::vector<std::vector<int>> temp1(size,std::vector<int>(size));
2121
std::vector<std::vector<int>> temp2(size,std::vector<int>(size));
22-
CkPrintf("SUB: Work done by processor %d\n",CkMyPe());
22+
//CkPrintf("SUB: Work done by processor %d\n",CkMyPe());
2323

24-
//if(VERBOSE)CkPrintf("Work done by processor %d\n",CkMyPe());
24+
//if(VERBOSE)//CkPrintf("Work done by processor %d\n",CkMyPe());
2525

2626
//do the addition/substraction, and wait for for the result then call on it the bigger strassen chare
2727
//if needed a big multiplication
2828
//inside the bigger strassen chare it will decide whether to use the naive or strassen algo
2929
if(partition == '1'){
30-
//if(VERBOSE)CkPrintf("here stressen SUB run 1:\n");
31-
CkPrintf("SUB1: Work done by processor %d\n",CkMyPe());
30+
//if(VERBOSE)//CkPrintf("here stressen SUB run 1:\n");
31+
//CkPrintf("SUB1: Work done by processor %d\n",CkMyPe());
3232

3333
/*first partition M1 = (A11+A22)(B11+B22)*/
3434
CkFuture p1add1 = CkCreateFuture(); //A11+A22
3535
CkFuture p1add2 = CkCreateFuture(); //B11+B22
3636
//i could spawn all the additions needed here
37-
//if(VERBOSE)CkPrintf("here stressen SUB run 2:\n");
37+
//if(VERBOSE)//CkPrintf("here stressen SUB run 2:\n");
3838

3939
CProxy_addition::ckNew(p1add1,A,B,size);//param not matching yet just a pseudo code
4040
CProxy_addition::ckNew(p1add2,C,D,size);//param not matching yet just a pseudo code
41-
//if(VERBOSE)CkPrintf("here stressen SUB run 3:\n");
41+
//if(VERBOSE)//CkPrintf("here stressen SUB run 3:\n");
4242

4343
//ValueMsg *m1 = new ValueMsg(size);
4444
//ValueMsg *m2 = new ValueMsg(size);
45-
CkPrintf("SUB1 - END0: Work done by processor %d\n",CkMyPe());
4645

4746
ValueMsg * m1 = (ValueMsg *) CkWaitFuture(p1add1);
4847
ValueMsg * m2 = (ValueMsg *) CkWaitFuture(p1add2);
49-
CkPrintf("SUB1 - END0: Work done by processor %d\n",CkMyPe());
5048

51-
/* if(VERBOSE)CkPrintf("value of a11+a22:\n");
49+
/* if(VERBOSE)//CkPrintf("value of a11+a22:\n");
5250
5351
for(int i=0; i<newSize;i++){
5452
for (int j = 0; j < newSize; ++j)
5553
{
56-
if(VERBOSE)CkPrintf("%d ",a11->v[i][j]);
54+
if(VERBOSE)//CkPrintf("%d ",a11->v[i][j]);
5755
}
58-
if(VERBOSE)CkPrintf("\n");
56+
if(VERBOSE)//CkPrintf("\n");
5957
}*/
60-
//if(VERBOSE)CkPrintf("here stressen SUB run 4:\n");
61-
CkPrintf("SUB1 - END0: Work done by processor %d\n",CkMyPe());
58+
6259

6360
CkFuture p1 = CkCreateFuture();
64-
//if(VERBOSE)CkPrintf("here stressen SUB run 5:\n");
65-
CkPrintf("SUB1 - END0: Work done by processor %d\n",CkMyPe());
66-
67-
CkPrintf("SUB1 - END5: Work done by processor %d\n",CkMyPe());
68-
CkPrintf("the result of m2 in partition %c\n",partition);
69-
for (int i = 0; i < size; ++i)
70-
{
71-
for (int j = 0; j < size; ++j)
72-
{
73-
CkPrintf("%d ",m2->v[i][j]);
74-
}
75-
CkPrintf("\n");
76-
77-
}
78-
CkPrintf("the result of m1 in partition %c\n",partition);
79-
80-
for (int i = 0; i < size; ++i)
81-
{
82-
for (int j = 0; j < size; ++j)
83-
{
84-
CkPrintf("%d ",m1->v[i][j]);
85-
}
86-
CkPrintf("\n");
87-
88-
}
61+
8962

9063
for (int i = 0; i < size; ++i)
9164
for (int j = 0; j < size; ++j)
@@ -94,20 +67,17 @@ for (int i = 0; i < size; ++i)
9467
temp1[i][j] = m1->v[i][j];
9568
temp2[i][j] = m2->v[i][j];
9669
}
97-
CkPrintf("SUB1 - END6: Work done by processor %d\n",CkMyPe());
9870

9971
CProxy_strassen::ckNew(p1,temp1,temp2,size); //to do (A11+A22)*(B11+B22) by giving m1->v and m2->v
100-
//if(VERBOSE)CkPrintf("here stressen SUB run 6:\n");
72+
//if(VERBOSE)//CkPrintf("here stressen SUB run 6:\n");
10173

10274
//i could free m1 and m2 at this point
103-
//if(VERBOSE)CkPrintf("here stressen SUB run 7:\n");
75+
//if(VERBOSE)//CkPrintf("here stressen SUB run 7:\n");
10476

10577
//ValueMsg *m3 = new ValueMsg(size);
106-
CkPrintf("SUB1 - END0: Work done by processor %d\n",CkMyPe());
10778

10879
ValueMsg * m3 = (ValueMsg *) CkWaitFuture(p1);
109-
//if(VERBOSE)CkPrintf("here stressen SUB run 8:\n");
110-
CkPrintf("SUB1 - END: Work done by processor %d\n",CkMyPe());
80+
//if(VERBOSE)//CkPrintf("here stressen SUB run 8:\n");
11181

11282
CkSendToFuture(f, m3);
11383
delete m1;
@@ -120,7 +90,7 @@ CkPrintf("SUB1 - END: Work done by processor %d\n",CkMyPe());
12090
}
12191

12292
else if(partition == '6' || partition == '7'){
123-
CkPrintf("SUB6-7: Work done by processor %d\n",CkMyPe());
93+
//CkPrintf("SUB6-7: Work done by processor %d\n",CkMyPe());
12494

12595
/*partition M6 = (A21-A11)(B11+B12)*/
12696
/*OR partition M7 = (A12-A22)(B21+B22)*/
@@ -173,7 +143,7 @@ CkPrintf("SUB6-7: Work done by processor %d\n",CkMyPe());
173143
//if needed a big multiplication
174144
//inside the bigger strassen chare it will decide whether to use the naive or strassen algo
175145
if(partition == '2' || partition == '5'){
176-
CkPrintf("SUB2-5: Work done by processor %d\n",CkMyPe());
146+
//CkPrintf("SUB2-5: Work done by processor %d\n",CkMyPe());
177147

178148
/*partition M2 =(A21+A22)B11*/
179149
/*OR partition M5 =(A11+A12)B22*/
@@ -199,7 +169,7 @@ CkPrintf("SUB2-5: Work done by processor %d\n",CkMyPe());
199169
//or should I use a block instead? UPDATES: I guess by now that I am using strassenSub It will be ok
200170
}
201171
else if(partition == '3' || partition == '4'){
202-
CkPrintf("SUB3-4: Work done by processor %d\n",CkMyPe());
172+
//CkPrintf("SUB3-4: Work done by processor %d\n",CkMyPe());
203173

204174
/*partition M3 = A11(B12-B22)*/
205175
/*OR partition M4 =A22(B21-B11)*/

0 commit comments

Comments
 (0)