czyszczenie kodu z niepotrzebnych rzeczy
This commit is contained in:
@@ -17,7 +17,7 @@ int main(int argc, char *argv[])
|
||||
int sumka_r, sumka_g, sumka_b;
|
||||
int suma_wag = 0;
|
||||
Mat img_out;
|
||||
int buff_max=0,porcja_new=0;
|
||||
int porcja_new=0;
|
||||
Mat img;
|
||||
Mat img_part_out;
|
||||
|
||||
@@ -58,13 +58,6 @@ int main(int argc, char *argv[])
|
||||
int porcja = (img.rows>=ntasks) ? (int)round(img.rows*1.0/ntasks) : 1;
|
||||
//porcja *= img.cols; //porcję mnożymy przez ilość elementów w jednym wektorze
|
||||
porcja_new = porcja;
|
||||
|
||||
// dla kompatybilności liczę jeszcze rozmiar bufora odbioru,
|
||||
// np. jeżeli chunki będą jednolitego rozmiaru, a ostatni będzie większy
|
||||
// to bufor odbioru musi być zwiększony (żeby go nie ucinało)
|
||||
buff_max = img.rows - porcja*(ntasks-1);
|
||||
if (porcja > buff_max)
|
||||
buff_max = porcja; // na wypadek, jeżeli jednak ostatni kawałek będzie mniejszy
|
||||
|
||||
if (taskid == 0)
|
||||
img_out.create(img.rows, img.cols, img.type());
|
||||
@@ -72,17 +65,14 @@ int main(int argc, char *argv[])
|
||||
int *chunk_sizes = new int[ntasks];
|
||||
int *chunk_order = new int[ntasks];
|
||||
|
||||
//liczę tablicę z danymi - o tym ile dany chunk ma rozmiaru oraz offset w tablicy od pierwszego procesu
|
||||
for (i=0; i<ntasks; ++i)
|
||||
{
|
||||
//if (i == 0)
|
||||
chunk_order[i] = (i == 0) ? 0 : chunk_order[i-1] + chunk_sizes[i-1];
|
||||
chunk_sizes[i] = porcja*img.cols*3;
|
||||
|
||||
if (i == ntasks-1)
|
||||
chunk_sizes[i] = (img.rows - porcja*(ntasks-1))*img.cols*3;
|
||||
|
||||
//if (taskid == 0)
|
||||
// cout << chunk_sizes[i] << endl;
|
||||
}
|
||||
|
||||
MPI::COMM_WORLD.Barrier();
|
||||
@@ -150,17 +140,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
MPI::COMM_WORLD.Barrier();
|
||||
if (taskid == 0 && false)
|
||||
if (taskid == 0)
|
||||
{
|
||||
long elapsed = tt.End();
|
||||
cout << "Time: " << elapsed << " ms" << endl;
|
||||
}
|
||||
// zwróć wszystko do programu głównego
|
||||
cout << porcja << endl;
|
||||
//MPI::COMM_WORLD.Gather(&img_part_out.data[0], buff_max*img.cols*3, MPI::CHAR, &img_out.data[0], buff_max*img.cols*3, MPI::CHAR, 0);
|
||||
MPI::COMM_WORLD.Gatherv(&img_part_out.data[0], porcja*img.cols*3, MPI::CHAR, &img_out.data[0], chunk_sizes, chunk_order, MPI::CHAR, 0);
|
||||
|
||||
//cout << taskid << endl;
|
||||
if (taskid == 0)
|
||||
imwrite(argv[2], img_out);
|
||||
MPI::Finalize();
|
||||
|
||||
Reference in New Issue
Block a user