Thanks
Your code works well.
I also got the error of MPI_ERR_TRUNCATE .
I solved it in this way,
If I use:
master :
world.irecv(resultSourceRank, upStreamTaskTag, myResultTaskPackage[iRank][taskCounterT3]);
I got this error, because I declared " TaskPackage myResultTaskPackage. "
It seems that the 2-dimension array cannot be used to receive my defined
class package from worker, who sends a TaskPackage to master.
So, I changed it to an int 2-d array to get the result, it works well.
But, I still want to find out how to store the result in a data structure with the type TaskPackage because
int type data can only be used to carry integers. Too limited.
What I want to do is:
The master can store the results from each worker and then combine them together
to form the final result after collecting all results from workers.
But, if the master has number of tasks that cannot be divided evenly by worker numbers,
each worker may have different number of tasks.
If we have 11 task and 3 workers.
aveTaskNumPerNode = (11 - 11%3) /3 = 3
leftTaskNum = 11%3 =2 = Z
the master distributes each of left tasks from worker 1 to work Z (Z < totalNumWorkers).
For example, worker 1: 4 tasks, worker 2: 4 task, worker 3: 3 tasks.
The master tries to distribute tasks evenly so that the difference between workloads of
each worker is minimized.
I found your code "hello1.cpp" also use the " std::vector<hello_msg*> recv_msgs" to
get message and then " recv_msgs.back()" into a vector with a "recv_msgs.push_back(new hello_msg);" .
But, vector is one dimension, I am trying to design a 2-dimensional data-structure that can
store results from workers. Each row element of the data-structure has different columns.
It can be indexed by iterator so that I can find the a specified number worker task result
by searching the data strucutre.
For example,
column column
1 2
row 1 (worker1.task1) (worker1.task4)
row 2 (worker2.task2) (worker1.task5)
row 3 (worker3.task3)
the data strucutre should remember the location of work ID and the task ID.
So that the master can know which task comes from which worker.
Any help or comment are appreciated.
thanks
Jack
June 30 2010