push to github

This commit is contained in:
2020-03-16 19:49:59 -06:00
parent 4cc4ae4afd
commit 1d67b1ff76
114 changed files with 7067 additions and 27 deletions

View File

@@ -12,8 +12,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="403496ef-b28d-436c-8dab-9b2445467bf8" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../HW5/a.out" beforeDir="false" afterPath="$PROJECT_DIR$/../HW5/a.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../ConWays/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../HW5/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/../HW5/main.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/a.out" beforeDir="false" afterPath="$PROJECT_DIR$/a.out" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/main.dir/main.cpp.o" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/main.dir/main.cpp.o" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/main" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/main" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/main.cpp" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@@ -70,7 +75,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1582969423610</updated>
<workItem from="1582969425689" duration="6726000" />
<workItem from="1582969425689" duration="8778000" />
</task>
<servers />
</component>

Binary file not shown.

Binary file not shown.

View File

@@ -6,9 +6,11 @@
#include <ctime>
#define MCW MPI_COMM_WORLD
using namespace std;
int main(int argc, char **argv){ int rank, size;
int main(int argc, char **argv){
int rank, size;
int N = 6;
MPI_Init(&argc, &argv); MPI_Comm_rank(MCW, &rank);
MPI_Init(&argc, &argv);
MPI_Comm_rank(MCW, &rank);
MPI_Comm_size(MCW, &size);
int* C=(int*)malloc(sizeof(int) *(N/size));
@@ -37,11 +39,8 @@ int main(int argc, char **argv){ int rank, size;
}else{
world[i][j] = 0;
}
cout << world[i][j] << " ";
}
cout << endl;
}
cout << endl << endl;
finished = false;
}
MPI_Barrier(MCW);
@@ -51,24 +50,16 @@ int main(int argc, char **argv){ int rank, size;
do{
MPI_Bcast (world, N*N, MPI_INT, 0, MCW);
int from = rank * N/size;
int to = ((rank+1) * N/size);
//Do Computations.
for(int i = 0; i < N; i++){
// Scatter the random numbers to all processes
cout << "ABOVE SCATTER" << endl;
MPI_Scatter (rank == 0 ? &(world[0][0]) : NULL, to-from, MPI_INT, C, to-from, MPI_INT, 0, MCW);
cout << "Rank: " << rank << endl;
for(int i = 0; i < N/size; i++){
cout << C[i] << " ";
}cout << endl;
MPI_Scatter (&world[i], 1, MPI_INT, C, 1, MPI_INT, 0, MCW);
int from = rank * N/size;
int to = ((rank+1) * N/size);
for(int j = from, k = 0; j < to; j++, k++){
cout << "MADE IT BACK TO THE TOP!!!!!!!!!!!!!!" << endl;
cout << "K: " << k << endl << endl;
// cout << "From " << from<<" TO: " << to <<" process: " << rank <<" j: " << j << " i: " << i<< endl;
cout << "From " << from<<" TO: " << to <<" process: " << rank <<" j: " << j << " i: " << i<< endl;
int neighbors = 0;
//Above 3 cells
if(i - 1 >= 0) {
@@ -99,9 +90,8 @@ int main(int argc, char **argv){ int rank, size;
if(j - 1 >= 0)
if(world[i][j-1]==1)
neighbors++;
//If neighbors are to many or few i die.
///We Are Segfaulting here because C is only size N/size not j*size/rank
//If neighbors are to many or few i die.
//cout << "k: " << k << " C[k]: " << C[k] << " World[i][j] " << world[i][j] << " rank: " << rank <<endl;
if(neighbors > 3 || neighbors <2)
C[k]=0;
@@ -112,10 +102,8 @@ int main(int argc, char **argv){ int rank, size;
C[k]=world[i][j];
}
}
//cout << "ABOVE BARRIER" << endl;
MPI_Barrier(MCW);
//Gather all of it back up.
cout << "above gather !!!!!!!!!!!!!!!" << endl;
MPI_Gather (&C[0], N/size, MPI_INT, &world[i][0], N/size, MPI_INT, 0, MCW);
@@ -123,11 +111,8 @@ int main(int argc, char **argv){ int rank, size;
if(rank == 0){
for(int x = 0; x < N; x++){
for( int y = 0; y < N; y++){
cout << world[x][y] << " ";
}
cout << endl;
}
cout << endl << endl << endl;
finished = true;
for( int i = 0; i<N*N; i++){
if(worldData[i]!=0)