summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2021-12-08 01:50:12 -0700
committerLogan Hunt <loganhunt@simponic.xyz>2021-12-08 01:50:12 -0700
commitc846568cf28b4d128cf893dc0abb6ccb5ccdcc32 (patch)
tree01ad0e303ea59103f2af9b9aa007785b88fa80ca
parent253b267f1cee377a834860fb4deac54ef9a78b7a (diff)
downloadgol-c846568cf28b4d128cf893dc0abb6ccb5ccdcc32.tar.gz
gol-c846568cf28b4d128cf893dc0abb6ccb5ccdcc32.zip
Timing study
-rwxr-xr-xcuda-global/golbin709816 -> 709816 bytes
-rw-r--r--cuda-global/src/game.cu9
-rw-r--r--cuda-global/src/main.cu56
-rw-r--r--cuda-global/timing-study/output--1000-1000.txt4
-rw-r--r--cuda-global/timing-study/output--1000-1250.txt4
-rw-r--r--cuda-global/timing-study/output--1000-1500.txt4
-rw-r--r--cuda-global/timing-study/output--1000-1750.txt4
-rw-r--r--cuda-global/timing-study/output--1000-2000.txt4
-rw-r--r--cuda-global/timing-study/output--1000-250.txt4
-rw-r--r--cuda-global/timing-study/output--1000-500.txt4
-rw-r--r--cuda-global/timing-study/output--1000-750.txt4
-rw-r--r--cuda-global/timing-study/slurm-3610476.err-notch0810
-rw-r--r--cuda-global/timing-study/slurm-3610476.out-notch0810
-rw-r--r--cuda-global/timing-study/slurm-3611549.err-notch0810
-rw-r--r--cuda-global/timing-study/slurm-3611549.out-notch0810
-rwxr-xr-xcuda-global/timing-study/timing_study.sh18
-rwxr-xr-xmpi/golbin155352 -> 152224 bytes
-rw-r--r--mpi/src/main.c69
-rw-r--r--mpi/timing-study/output-1-1000-1000.txt4
-rw-r--r--mpi/timing-study/output-1-1000-1250.txt11
-rw-r--r--mpi/timing-study/output-1-1000-1500.txt4
-rw-r--r--mpi/timing-study/output-1-1000-1750.txt11
-rw-r--r--mpi/timing-study/output-1-1000-2000.txt4
-rw-r--r--mpi/timing-study/output-1-1000-250.txt4
-rw-r--r--mpi/timing-study/output-1-1000-500.txt4
-rw-r--r--mpi/timing-study/output-1-1000-750.txt4
-rw-r--r--mpi/timing-study/output-12-1000-1000.txt4
-rw-r--r--mpi/timing-study/output-12-1000-1250.txt4
-rw-r--r--mpi/timing-study/output-12-1000-1500.txt11
-rw-r--r--mpi/timing-study/output-12-1000-1750.txt4
-rw-r--r--mpi/timing-study/output-12-1000-2000.txt11
-rw-r--r--mpi/timing-study/output-12-1000-250.txt4
-rw-r--r--mpi/timing-study/output-12-1000-500.txt4
-rw-r--r--mpi/timing-study/output-12-1000-750.txt4
-rw-r--r--mpi/timing-study/output-16-1000-1000.txt4
-rw-r--r--mpi/timing-study/output-16-1000-1250.txt4
-rw-r--r--mpi/timing-study/output-16-1000-1500.txt4
-rw-r--r--mpi/timing-study/output-16-1000-1750.txt8
-rw-r--r--mpi/timing-study/output-16-1000-2000.txt4
-rw-r--r--mpi/timing-study/output-16-1000-250.txt4
-rw-r--r--mpi/timing-study/output-16-1000-500.txt4
-rw-r--r--mpi/timing-study/output-16-1000-750.txt4
-rw-r--r--mpi/timing-study/output-20-1000-250.txt0
-rw-r--r--mpi/timing-study/output-24-1000-1000.txt4
-rw-r--r--mpi/timing-study/output-24-1000-1250.txt4
-rw-r--r--mpi/timing-study/output-24-1000-1500.txt4
-rw-r--r--mpi/timing-study/output-24-1000-1750.txt4
-rw-r--r--mpi/timing-study/output-24-1000-2000.txt4
-rw-r--r--mpi/timing-study/output-24-1000-250.txt4
-rw-r--r--mpi/timing-study/output-24-1000-500.txt4
-rw-r--r--mpi/timing-study/output-24-1000-750.txt4
-rw-r--r--mpi/timing-study/output-4-1000-1000.txt4
-rw-r--r--mpi/timing-study/output-4-1000-1250.txt11
-rw-r--r--mpi/timing-study/output-4-1000-1500.txt4
-rw-r--r--mpi/timing-study/output-4-1000-1750.txt11
-rw-r--r--mpi/timing-study/output-4-1000-2000.txt4
-rw-r--r--mpi/timing-study/output-4-1000-250.txt4
-rw-r--r--mpi/timing-study/output-4-1000-500.txt4
-rw-r--r--mpi/timing-study/output-4-1000-750.txt4
-rw-r--r--mpi/timing-study/output-8-1000-1000.txt4
-rw-r--r--mpi/timing-study/output-8-1000-1250.txt11
-rw-r--r--mpi/timing-study/output-8-1000-1500.txt4
-rw-r--r--mpi/timing-study/output-8-1000-1750.txt4
-rw-r--r--mpi/timing-study/output-8-1000-2000.txt4
-rw-r--r--mpi/timing-study/output-8-1000-250.txt4
-rw-r--r--mpi/timing-study/output-8-1000-500.txt4
-rw-r--r--mpi/timing-study/output-8-1000-750.txt4
-rw-r--r--mpi/timing-study/slurm-10870703.err-kp01311
-rw-r--r--mpi/timing-study/slurm-10870703.out-kp0130
-rw-r--r--mpi/timing-study/timing_study.sh24
-rw-r--r--openmp/src/create_grid.c2
-rw-r--r--openmp/src/file.c2
-rw-r--r--openmp/src/game.c5
-rw-r--r--openmp/src/main.c9
-rw-r--r--openmp/timing-study/output-1-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-1-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-1-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-1-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-1-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-1-1000-250.txt4
-rw-r--r--openmp/timing-study/output-1-1000-500.txt4
-rw-r--r--openmp/timing-study/output-1-1000-750.txt4
-rw-r--r--openmp/timing-study/output-12-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-12-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-12-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-12-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-12-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-12-1000-250.txt4
-rw-r--r--openmp/timing-study/output-12-1000-500.txt4
-rw-r--r--openmp/timing-study/output-12-1000-750.txt4
-rw-r--r--openmp/timing-study/output-16-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-16-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-16-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-16-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-16-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-16-1000-250.txt4
-rw-r--r--openmp/timing-study/output-16-1000-500.txt4
-rw-r--r--openmp/timing-study/output-16-1000-750.txt4
-rw-r--r--openmp/timing-study/output-20-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-20-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-20-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-20-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-20-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-20-1000-250.txt4
-rw-r--r--openmp/timing-study/output-20-1000-500.txt4
-rw-r--r--openmp/timing-study/output-20-1000-750.txt4
-rw-r--r--openmp/timing-study/output-24-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-24-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-24-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-24-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-24-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-24-1000-250.txt4
-rw-r--r--openmp/timing-study/output-24-1000-500.txt4
-rw-r--r--openmp/timing-study/output-24-1000-750.txt4
-rw-r--r--openmp/timing-study/output-4-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-4-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-4-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-4-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-4-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-4-1000-250.txt4
-rw-r--r--openmp/timing-study/output-4-1000-500.txt4
-rw-r--r--openmp/timing-study/output-4-1000-750.txt4
-rw-r--r--openmp/timing-study/output-8-1000-1000.txt4
-rw-r--r--openmp/timing-study/output-8-1000-1250.txt4
-rw-r--r--openmp/timing-study/output-8-1000-1500.txt4
-rw-r--r--openmp/timing-study/output-8-1000-1750.txt4
-rw-r--r--openmp/timing-study/output-8-1000-2000.txt4
-rw-r--r--openmp/timing-study/output-8-1000-250.txt4
-rw-r--r--openmp/timing-study/output-8-1000-500.txt4
-rw-r--r--openmp/timing-study/output-8-1000-750.txt4
-rw-r--r--openmp/timing-study/slurm-10870649.err-kp0131
-rw-r--r--openmp/timing-study/slurm-10870649.out-kp0130
-rw-r--r--openmp/timing-study/slurm-10870651.err-kp0131
-rw-r--r--openmp/timing-study/slurm-10870651.out-kp0130
-rw-r--r--openmp/timing-study/slurm-10870663.err-kp0130
-rw-r--r--openmp/timing-study/slurm-10870663.out-kp0130
-rw-r--r--openmp/timing-study/timing_study.sh23
-rw-r--r--serial/src/create_grid.c2
-rw-r--r--serial/src/file.c2
-rw-r--r--serial/src/game.c4
-rw-r--r--serial/src/main.c11
-rw-r--r--serial/timing-study/output-1-1000-1000.txt4
-rw-r--r--serial/timing-study/output-1-1000-1250.txt4
-rw-r--r--serial/timing-study/output-1-1000-1500.txt4
-rw-r--r--serial/timing-study/output-1-1000-1750.txt4
-rw-r--r--serial/timing-study/output-1-1000-2000.txt4
-rw-r--r--serial/timing-study/output-1-1000-250.txt4
-rw-r--r--serial/timing-study/output-1-1000-500.txt4
-rw-r--r--serial/timing-study/output-1-1000-750.txt4
-rw-r--r--serial/timing-study/slurm-10870643.err-kp0130
-rw-r--r--serial/timing-study/slurm-10870643.out-kp0130
-rw-r--r--serial/timing-study/timing_study.sh19
152 files changed, 755 insertions, 46 deletions
diff --git a/cuda-global/gol b/cuda-global/gol
index 4fb8b81..85af8de 100755
--- a/cuda-global/gol
+++ b/cuda-global/gol
Binary files differ
diff --git a/cuda-global/src/game.cu b/cuda-global/src/game.cu
index b0b5f61..abb5ed9 100644
--- a/cuda-global/src/game.cu
+++ b/cuda-global/src/game.cu
@@ -1,11 +1,12 @@
#include "game.cuh"
+// Count the number of life neighbors a cell has
__device__ int neighbors(struct GAME game, int x, int y) {
int n = 0;
for (int dy = -1; dy <= 1; dy++) {
for (int dx = -1; dx <= 1; dx++) {
- if (!(dx == 0 && dy == 0) && (x+dx) >= 0 && (y+dy) >= 0 && (x+dx) < game.width+(game.padding*2) && (y+dy) < game.height+(game.padding*2)) {
+ if (!(dx == 0 && dy == 0) && (x+dx) > 0 && (y+dy) > 0 && (x+dx) < game.width+(game.padding*2) && (y+dy) < game.height+(game.padding*2)) {
if (game.grid[(y+dy) * (game.width+game.padding*2) + (x+dx)]) {
n++;
}
@@ -15,11 +16,14 @@ __device__ int neighbors(struct GAME game, int x, int y) {
return n;
}
+// Compute the next iteration of a board
+// We have to give it the newGrid as a parameter otherwise
+// each block will be computing its own version of the next grid
__global__ void next(struct GAME game, unsigned char* newGrid) {
int idy = blockDim.y * blockIdx.y + threadIdx.y;
int idx = blockDim.x * blockIdx.x + threadIdx.x;
- if (idy <= game.height+game.padding*2 && idx <= game.width+game.padding*2) {
+ if (idy < game.height+game.padding*2 && idx < game.width+game.padding*2) {
int my_neighbors = neighbors(game, idx, idy);
int my_coord = idy * (game.width+game.padding*2) + idx;
newGrid[my_coord] = 0; // It's possible that there are artifacts from the last iteration
@@ -37,6 +41,7 @@ __global__ void next(struct GAME game, unsigned char* newGrid) {
}
}
+// Randomly assign life value to each cell
void randomize(struct GAME* game) {
for (int y = game->padding; y < game->height+game->padding; y++) {
for (int x = game->padding; x < game->width+game->padding; x++) {
diff --git a/cuda-global/src/main.cu b/cuda-global/src/main.cu
index f906b2a..41c2abf 100644
--- a/cuda-global/src/main.cu
+++ b/cuda-global/src/main.cu
@@ -18,7 +18,7 @@
*/
#define BLOCK 32
#define PADDING 10
-#define VERBOSE 1
+//#define VERBOSE 1
#define SEED 100
// gpuErrchk source: https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
@@ -33,14 +33,16 @@ true) {
}
}
+// Do the simulation
void simulate(int argc, char** argv) {
srand(SEED);
- clock_t totalStart = clock();
+ clock_t global_start = clock();
char* filename;
struct GAME game;
game.padding = PADDING;
int iterations, log_each_step;
if (argc == 7) {
+ // Parse the arguments
filename = argv[2];
game.width = atoi(argv[3]);
game.height = atoi(argv[4]);
@@ -60,6 +62,7 @@ void simulate(int argc, char** argv) {
game.grid = (unsigned char*)malloc(size);
memset(game.grid, 0, size);
+ // Choose where to read initial position
if (strcmp(filename, "random") == 0) {
randomize(&game);
} else {
@@ -68,43 +71,53 @@ void simulate(int argc, char** argv) {
char iteration_file[1024];
+ // Allocate device memory
unsigned char* grid_d;
unsigned char* newGrid;
gpuErrchk(cudaMalloc(&grid_d, size));
- gpuErrchk(cudaMemcpy(grid_d, game.grid, size, cudaMemcpyHostToDevice));
gpuErrchk(cudaMalloc(&newGrid, size));
+ gpuErrchk(cudaMemcpy(grid_d, game.grid, size, cudaMemcpyHostToDevice)); // Copy the initial grid to the device
+ free(game.grid);
+ game.grid = grid_d; // Use the device copy
+ // The grid that we will copy results
unsigned char* grid_h = (unsigned char*)malloc(size);
unsigned char* temp;
- game.grid = grid_d;
-
- int grid_num = (int)ceil((game.width+(2*game.padding))/(float)BLOCK);
- dim3 dim_grid(grid_num, grid_num, 1);
+ // Calculate grid width for kernel
+ int grid_width = (int)ceil((game.width+(2*game.padding))/(float)BLOCK);
+ int grid_height = (int)ceil((game.height+(2*game.padding))/(float)BLOCK);
+ dim3 dim_grid(grid_width, grid_height, 1);
dim3 dim_block(BLOCK, BLOCK, 1);
- cudaEvent_t startLife, stopLife;
- cudaEventCreate(&startLife);
- cudaEventCreate(&stopLife);
- double timeComputingLife = 0;
- float localTime = 0;
+ // Timing
+ cudaEvent_t start, end;
+ cudaEventCreate(&start);
+ cudaEventCreate(&end);
+ double time_computing_life = 0;
+ float local_time = 0;
for (int i = 0; i <= iterations; i++) {
+ // Iteration 0 will just be the initial grid
if (i > 0) {
- cudaEventRecord(startLife);
+ cudaEventRecord(start);
+ // Compute the next grid
next<<<dim_grid, dim_block>>>(game, newGrid);
- cudaEventRecord(stopLife);
- cudaEventSynchronize(stopLife);
- cudaEventElapsedTime(&localTime, startLife, stopLife);
- timeComputingLife += localTime/1000;
+ cudaEventRecord(end);
+ cudaEventSynchronize(end);
+ cudaEventElapsedTime(&local_time, start, end);
+ time_computing_life += local_time/1000;
+ // Swap game.grid and newGrid
temp = game.grid;
game.grid = newGrid;
newGrid = temp;
}
if (log_each_step) {
+ // If we are logging each step, perform IO operations
gpuErrchk(cudaMemcpy(grid_h, game.grid, size, cudaMemcpyDeviceToHost));
#ifdef VERBOSE
+ // Print the board without the padding elements
printf("\n===Iteration %i===\n", i);
for (int y = game.padding; y < game.height+game.padding; y++) {
for (int x = game.padding; x < game.width+game.padding; x++) {
@@ -114,6 +127,7 @@ void simulate(int argc, char** argv) {
}
printf("===End iteration %i===\n", i);
#endif
+ // Save to a file
sprintf(iteration_file, "output/iteration-%07d.bin", i);
temp = game.grid;
game.grid = grid_h;
@@ -122,13 +136,7 @@ void simulate(int argc, char** argv) {
}
}
- clock_t totalEnd = clock();
- printf("\n===Timing===\nTime computing life: %f\nClock time: %f\n", timeComputingLife, ((double)totalEnd - (double)totalStart)/CLOCKS_PER_SEC);
-
- cudaFree(&newGrid);
- cudaFree(&grid_d);
- cudaFree(&game.grid);
- free(grid_h);
+ printf("\n===Timing===\nTime computing life: %f\nClock time: %f\n", time_computing_life, ((double)clock() - (double)global_start)/CLOCKS_PER_SEC);
}
int main(int argc, char** argv) {
diff --git a/cuda-global/timing-study/output--1000-1000.txt b/cuda-global/timing-study/output--1000-1000.txt
new file mode 100644
index 0000000..3792efc
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.169687
+Clock time: 1.560000
diff --git a/cuda-global/timing-study/output--1000-1250.txt b/cuda-global/timing-study/output--1000-1250.txt
new file mode 100644
index 0000000..9081eb5
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.254989
+Clock time: 2.240000
diff --git a/cuda-global/timing-study/output--1000-1500.txt b/cuda-global/timing-study/output--1000-1500.txt
new file mode 100644
index 0000000..c2fafe8
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.354361
+Clock time: 3.050000
diff --git a/cuda-global/timing-study/output--1000-1750.txt b/cuda-global/timing-study/output--1000-1750.txt
new file mode 100644
index 0000000..557165e
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.480174
+Clock time: 4.070000
diff --git a/cuda-global/timing-study/output--1000-2000.txt b/cuda-global/timing-study/output--1000-2000.txt
new file mode 100644
index 0000000..91a9d45
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.619636
+Clock time: 5.220000
diff --git a/cuda-global/timing-study/output--1000-250.txt b/cuda-global/timing-study/output--1000-250.txt
new file mode 100644
index 0000000..0808a20
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.029867
+Clock time: 0.330000
diff --git a/cuda-global/timing-study/output--1000-500.txt b/cuda-global/timing-study/output--1000-500.txt
new file mode 100644
index 0000000..913b15e
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.059907
+Clock time: 0.540000
diff --git a/cuda-global/timing-study/output--1000-750.txt b/cuda-global/timing-study/output--1000-750.txt
new file mode 100644
index 0000000..e3b8c5d
--- /dev/null
+++ b/cuda-global/timing-study/output--1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.110954
+Clock time: 1.000000
diff --git a/cuda-global/timing-study/slurm-3610476.err-notch081 b/cuda-global/timing-study/slurm-3610476.err-notch081
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cuda-global/timing-study/slurm-3610476.err-notch081
diff --git a/cuda-global/timing-study/slurm-3610476.out-notch081 b/cuda-global/timing-study/slurm-3610476.out-notch081
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cuda-global/timing-study/slurm-3610476.out-notch081
diff --git a/cuda-global/timing-study/slurm-3611549.err-notch081 b/cuda-global/timing-study/slurm-3611549.err-notch081
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cuda-global/timing-study/slurm-3611549.err-notch081
diff --git a/cuda-global/timing-study/slurm-3611549.out-notch081 b/cuda-global/timing-study/slurm-3611549.out-notch081
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cuda-global/timing-study/slurm-3611549.out-notch081
diff --git a/cuda-global/timing-study/timing_study.sh b/cuda-global/timing-study/timing_study.sh
new file mode 100755
index 0000000..ef7ebcb
--- /dev/null
+++ b/cuda-global/timing-study/timing_study.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+#SBATCH --time=0:30:00 # walltime, abbreviated by -t
+#SBATCH --nodes=1 # number of cluster nodes, abbreviated by -N
+#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first node (%N)
+#SBATCH -e slurm-%j.err-%N # name of the stderr, using job and first node values
+#SBATCH --ntasks=1 # number of MPI tasks, abbreviated by -n
+# additional information for allocated clusters
+#SBATCH --account=notchpeak-shared-short # account - abbreviated by -A
+#SBATCH --partition=notchpeak-shared-short # partition, abbreviated by -p
+#SBATCH --gres=gpu:k80:1
+
+cd $HOME/gol/cuda-global
+
+iterations=1000
+for size in 250 500 750 1000 1250 1500 1750 2000
+do
+ srun ./gol simulate random $size $size $iterations 1 > timing-study/output-$cores-$iterations-$size.txt
+done
diff --git a/mpi/gol b/mpi/gol
index f7d934c..f9518e9 100755
--- a/mpi/gol
+++ b/mpi/gol
Binary files differ
diff --git a/mpi/src/main.c b/mpi/src/main.c
index 9fed89e..02e2bb6 100644
--- a/mpi/src/main.c
+++ b/mpi/src/main.c
@@ -15,10 +15,12 @@
Any live cell with more than three live neighbors dies (overpopulation).
Any dead cell with exactly three live neighbors becomes a live cell (reproduction).
*/
-#define PADDING 16
+#define PADDING 10
//#define VERBOSE 1
#define SEED 100
+// A structure to keep the global arguments because each process
+// will use its own GAME structure
struct Args {
int process_count;
int iterations;
@@ -30,6 +32,7 @@ struct Args {
int data_per_proc;
};
+// Make a datatype out of an Args struct
void broadcast_and_receive_input(MPI_Comm comm, struct Args* args) {
int blocks[8] = {1,1,1,1,1,1,1,1};
MPI_Aint displacements[8];
@@ -50,6 +53,7 @@ void broadcast_and_receive_input(MPI_Comm comm, struct Args* args) {
MPI_Bcast(args, 1, arg_t, 0, comm);
}
+// Scatter the grid among nodes
void scatter_data(MPI_Comm comm, struct Args* args, unsigned char* local_data, int rank, int* data_counts, int* displacements, char* filename) {
unsigned char* data;
@@ -63,12 +67,14 @@ void scatter_data(MPI_Comm comm, struct Args* args, unsigned char* local_data, i
data = malloc(size);
memset(data, 0, size);
game.grid = data;
+ // Choose where to read initial position
if (strcmp(filename, "random") == 0) {
randomize(&game);
} else {
read_in(filename, &game);
}
}
+ // Do the scatter (some nodes may work on more rows)
MPI_Scatterv(data, data_counts, displacements, MPI_UNSIGNED_CHAR, local_data, data_counts[rank], MPI_UNSIGNED_CHAR, 0, comm);
if (rank == 0) {
@@ -77,12 +83,13 @@ void scatter_data(MPI_Comm comm, struct Args* args, unsigned char* local_data, i
}
+// Do the simulation
void simulate(int argc, char** argv) {
srand(SEED);
- double totalStart = MPI_Wtime();
struct Args args;
args.padding = PADDING;
+ // Initialize MPI stuff
int rank, process_count;
MPI_Comm comm;
MPI_Init(&argc, &argv);
@@ -91,7 +98,9 @@ void simulate(int argc, char** argv) {
MPI_Comm_size(comm, &args.process_count);
char* filename;
+ double global_start;
if (rank == 0) {
+ // Parse the arguments
if (argc == 7) {
filename = argv[2];
args.width = atoi(argv[3]);
@@ -99,7 +108,7 @@ void simulate(int argc, char** argv) {
args.iterations = atoi(argv[5]);
args.log_each_step = atoi(argv[6]);
} else {
- printf("Usage: ./gol simulate <filename | random> <width> <height> <iterations> <log-each-step?1:0> <block-size>\n");
+ printf("Usage: ./gol simulate <filename | random> <width> <height> <iterations> <log-each-step?1:0>\n");
filename = "random";
args.height = 5;
args.width = 5;
@@ -107,12 +116,17 @@ void simulate(int argc, char** argv) {
args.log_each_step = 0;
}
+ global_start = MPI_Wtime();
+
+ // Figure out how much work the average node will be doing
args.rows_per_proc = (args.height + args.padding*2)/args.process_count;
args.data_per_proc = args.rows_per_proc * (args.width + args.padding*2);
}
broadcast_and_receive_input(comm, &args);
+ // Calculate the exact work each thread will do and arguments for
+ // the Scatterv to scatter the grid
int grid_size = ((args.width + args.padding*2)*(args.height + args.padding*2));
int* data_counts = malloc(sizeof(int) * args.process_count);
int* displacements = malloc(sizeof(int) * args.process_count);
@@ -123,19 +137,20 @@ void simulate(int argc, char** argv) {
data_counts[args.process_count-1] += grid_size % (args.data_per_proc * args.process_count);
unsigned char* local_data = malloc(data_counts[rank]*sizeof(unsigned char));
memset(local_data, 0, sizeof(unsigned char) * data_counts[rank]);
+
+ // Scatter the data among nodes
scatter_data(comm, &args, local_data, rank, data_counts, displacements, filename);
- // Allocate space for current grid (1 byte per tile)
char iteration_file[1024];
- double timeComputingLife = 0;
- float localTime = 0;
-
+ // Local_game is our current job
struct GAME local_game;
local_game.grid = local_data;
local_game.width = args.width;
local_game.height = data_counts[rank] / (args.width + args.padding*2);
local_game.padding = args.padding;
+
+ // Assign halo elements to send to be received from above and below nodes
unsigned char* halo_above = NULL;
unsigned char* halo_below = NULL;
if (rank > 0) {
@@ -148,32 +163,46 @@ void simulate(int argc, char** argv) {
}
unsigned char* global_data;
+ if (rank == 0) {
+ global_data = malloc(sizeof(unsigned char) * grid_size);
+ memset(global_data, 0, sizeof(unsigned char) * grid_size);
+ }
+
+ // Timing code
+ double time_computing_life = 0;
+ double start,end;
for (int i = 0; i <= args.iterations; i++) {
+ // Iteration 0 will just be the initial grid
if (i > 0) {
int total_width = args.width + args.padding*2;
+
+ MPI_Status status;
if (rank < args.process_count - 1) {
MPI_Send(&local_game.grid[(local_game.height-1) * total_width], total_width, MPI_UNSIGNED_CHAR, rank+1, 1, comm);
}
if (rank > 0) {
- MPI_Recv(halo_above, total_width, MPI_UNSIGNED_CHAR, rank-1, 1, comm, NULL);
+ MPI_Recv(halo_above, total_width, MPI_UNSIGNED_CHAR, rank-1, 1, comm, &status);
MPI_Send(&local_game.grid[0], total_width, MPI_UNSIGNED_CHAR, rank-1, 0, comm);
}
if (rank < args.process_count - 1) {
- MPI_Recv(halo_below, total_width, MPI_UNSIGNED_CHAR, rank+1, 0, comm, NULL);
+ MPI_Recv(halo_below, total_width, MPI_UNSIGNED_CHAR, rank+1, 0, comm, &status);
}
MPI_Barrier(comm);
+ start = MPI_Wtime();
+ // Compute the next grid
next(&local_game, halo_above, halo_below);
+ end = MPI_Wtime();
+ time_computing_life += end-start;
}
if (args.log_each_step) {
- if (rank == 0) {
- global_data = malloc(sizeof(unsigned char) * grid_size);
- memset(global_data, 0, sizeof(unsigned char) * grid_size);
- }
+ // If we are logging each step, perform IO operations
+ // Gather all of the local grids into global_data
MPI_Gatherv(local_game.grid, data_counts[rank], MPI_UNSIGNED_CHAR, global_data, data_counts, displacements, MPI_UNSIGNED_CHAR, 0, comm);
if (rank == 0) {
- #ifdef VERBOSE
+ #if VERBOSE == 1
printf("\n===Iteration %i===\n", i);
+ // Print the baord without the padding elements
for (int y = args.padding; y < args.height+args.padding; y++) {
for (int x = args.padding; x < args.width+args.padding; x++) {
printf("%s ", global_data[y*(args.width+2*args.padding) + x] ? "X" : " ");
@@ -183,6 +212,7 @@ void simulate(int argc, char** argv) {
printf("===End iteration %i===\n", i);
#endif
+ // Save to a file
struct GAME global_game;
global_game.grid = global_data;
global_game.width = args.width;
@@ -194,12 +224,15 @@ void simulate(int argc, char** argv) {
}
}
- double totalEnd = MPI_Wtime();
- MPI_Finalize();
+ double total_end = MPI_Wtime();
if (rank == 0) {
- printf("\n===Timing===\nTime computing life: %f\nClock time: %f\n", timeComputingLife, (totalEnd - totalStart));
+ printf("\n===Timing===\nTime computing life: %f\nClock time: %f\n", time_computing_life, (total_end - global_start));
+ free(local_game.grid);
+ free(data_counts);
+ free(halo_above);
+ free(halo_below);
}
-
+ MPI_Finalize();
}
int main(int argc, char** argv) {
diff --git a/mpi/timing-study/output-1-1000-1000.txt b/mpi/timing-study/output-1-1000-1000.txt
new file mode 100644
index 0000000..f500f74
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 33.832562
+Clock time: 37.939663
diff --git a/mpi/timing-study/output-1-1000-1250.txt b/mpi/timing-study/output-1-1000-1250.txt
new file mode 100644
index 0000000..f928063
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-1250.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 21716 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-1-1000-1500.txt b/mpi/timing-study/output-1-1000-1500.txt
new file mode 100644
index 0000000..d31db96
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 75.141736
+Clock time: 83.149478
diff --git a/mpi/timing-study/output-1-1000-1750.txt b/mpi/timing-study/output-1-1000-1750.txt
new file mode 100644
index 0000000..6bbaf1f
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-1750.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 21837 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-1-1000-2000.txt b/mpi/timing-study/output-1-1000-2000.txt
new file mode 100644
index 0000000..3ba37f2
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 132.636661
+Clock time: 145.001708
diff --git a/mpi/timing-study/output-1-1000-250.txt b/mpi/timing-study/output-1-1000-250.txt
new file mode 100644
index 0000000..544de8e
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.383001
+Clock time: 4.113476
diff --git a/mpi/timing-study/output-1-1000-500.txt b/mpi/timing-study/output-1-1000-500.txt
new file mode 100644
index 0000000..dfa5abb
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 8.793952
+Clock time: 9.832794
diff --git a/mpi/timing-study/output-1-1000-750.txt b/mpi/timing-study/output-1-1000-750.txt
new file mode 100644
index 0000000..e1437a3
--- /dev/null
+++ b/mpi/timing-study/output-1-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 19.270078
+Clock time: 21.813069
diff --git a/mpi/timing-study/output-12-1000-1000.txt b/mpi/timing-study/output-12-1000-1000.txt
new file mode 100644
index 0000000..2d1c3b3
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.833550
+Clock time: 6.323680
diff --git a/mpi/timing-study/output-12-1000-1250.txt b/mpi/timing-study/output-12-1000-1250.txt
new file mode 100644
index 0000000..5e8cbfb
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.347700
+Clock time: 9.178630
diff --git a/mpi/timing-study/output-12-1000-1500.txt b/mpi/timing-study/output-12-1000-1500.txt
new file mode 100644
index 0000000..206bf6c
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-1500.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 23209 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-12-1000-1750.txt b/mpi/timing-study/output-12-1000-1750.txt
new file mode 100644
index 0000000..f2798ae
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 8.483342
+Clock time: 17.330302
diff --git a/mpi/timing-study/output-12-1000-2000.txt b/mpi/timing-study/output-12-1000-2000.txt
new file mode 100644
index 0000000..165b598
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-2000.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 23290 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-12-1000-250.txt b/mpi/timing-study/output-12-1000-250.txt
new file mode 100644
index 0000000..e4be53e
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.198089
+Clock time: 2.217166
diff --git a/mpi/timing-study/output-12-1000-500.txt b/mpi/timing-study/output-12-1000-500.txt
new file mode 100644
index 0000000..51bc78b
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.735509
+Clock time: 2.513034
diff --git a/mpi/timing-study/output-12-1000-750.txt b/mpi/timing-study/output-12-1000-750.txt
new file mode 100644
index 0000000..c9351f2
--- /dev/null
+++ b/mpi/timing-study/output-12-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.617002
+Clock time: 4.091923
diff --git a/mpi/timing-study/output-16-1000-1000.txt b/mpi/timing-study/output-16-1000-1000.txt
new file mode 100644
index 0000000..4b98fae
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.106571
+Clock time: 7.500836
diff --git a/mpi/timing-study/output-16-1000-1250.txt b/mpi/timing-study/output-16-1000-1250.txt
new file mode 100644
index 0000000..183314c
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 3.445883
+Clock time: 11.167682
diff --git a/mpi/timing-study/output-16-1000-1500.txt b/mpi/timing-study/output-16-1000-1500.txt
new file mode 100644
index 0000000..a08be6f
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.741983
+Clock time: 16.777514
diff --git a/mpi/timing-study/output-16-1000-1750.txt b/mpi/timing-study/output-16-1000-1750.txt
new file mode 100644
index 0000000..cd6757e
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-1750.txt
@@ -0,0 +1,8 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 34784 RUNNING AT kp160
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
diff --git a/mpi/timing-study/output-16-1000-2000.txt b/mpi/timing-study/output-16-1000-2000.txt
new file mode 100644
index 0000000..4bfa78c
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 8.301682
+Clock time: 28.791425
diff --git a/mpi/timing-study/output-16-1000-250.txt b/mpi/timing-study/output-16-1000-250.txt
new file mode 100644
index 0000000..2f97b52
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.145483
+Clock time: 2.572587
diff --git a/mpi/timing-study/output-16-1000-500.txt b/mpi/timing-study/output-16-1000-500.txt
new file mode 100644
index 0000000..adc146c
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.570992
+Clock time: 3.899400
diff --git a/mpi/timing-study/output-16-1000-750.txt b/mpi/timing-study/output-16-1000-750.txt
new file mode 100644
index 0000000..961b2a9
--- /dev/null
+++ b/mpi/timing-study/output-16-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.215016
+Clock time: 5.047125
diff --git a/mpi/timing-study/output-20-1000-250.txt b/mpi/timing-study/output-20-1000-250.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mpi/timing-study/output-20-1000-250.txt
diff --git a/mpi/timing-study/output-24-1000-1000.txt b/mpi/timing-study/output-24-1000-1000.txt
new file mode 100644
index 0000000..b1fd01d
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.414322
+Clock time: 9.439315
diff --git a/mpi/timing-study/output-24-1000-1250.txt b/mpi/timing-study/output-24-1000-1250.txt
new file mode 100644
index 0000000..08acf8e
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.171989
+Clock time: 13.927639
diff --git a/mpi/timing-study/output-24-1000-1500.txt b/mpi/timing-study/output-24-1000-1500.txt
new file mode 100644
index 0000000..e8452d5
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 3.133675
+Clock time: 19.271850
diff --git a/mpi/timing-study/output-24-1000-1750.txt b/mpi/timing-study/output-24-1000-1750.txt
new file mode 100644
index 0000000..9757c78
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.398371
+Clock time: 25.650748
diff --git a/mpi/timing-study/output-24-1000-2000.txt b/mpi/timing-study/output-24-1000-2000.txt
new file mode 100644
index 0000000..8fd3c60
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 5.639865
+Clock time: 33.529967
diff --git a/mpi/timing-study/output-24-1000-250.txt b/mpi/timing-study/output-24-1000-250.txt
new file mode 100644
index 0000000..e6ddcb7
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.100765
+Clock time: 2.412458
diff --git a/mpi/timing-study/output-24-1000-500.txt b/mpi/timing-study/output-24-1000-500.txt
new file mode 100644
index 0000000..8f6af46
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.465147
+Clock time: 3.942927
diff --git a/mpi/timing-study/output-24-1000-750.txt b/mpi/timing-study/output-24-1000-750.txt
new file mode 100644
index 0000000..1329b1b
--- /dev/null
+++ b/mpi/timing-study/output-24-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.815429
+Clock time: 5.642879
diff --git a/mpi/timing-study/output-4-1000-1000.txt b/mpi/timing-study/output-4-1000-1000.txt
new file mode 100644
index 0000000..14dc1e9
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 8.467197
+Clock time: 11.707533
diff --git a/mpi/timing-study/output-4-1000-1250.txt b/mpi/timing-study/output-4-1000-1250.txt
new file mode 100644
index 0000000..408cfeb
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-1250.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 22126 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-4-1000-1500.txt b/mpi/timing-study/output-4-1000-1500.txt
new file mode 100644
index 0000000..d304a5d
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 18.823087
+Clock time: 26.449810
diff --git a/mpi/timing-study/output-4-1000-1750.txt b/mpi/timing-study/output-4-1000-1750.txt
new file mode 100644
index 0000000..ab98c94
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-1750.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 22197 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-4-1000-2000.txt b/mpi/timing-study/output-4-1000-2000.txt
new file mode 100644
index 0000000..2c85e0c
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 33.274214
+Clock time: 45.841294
diff --git a/mpi/timing-study/output-4-1000-250.txt b/mpi/timing-study/output-4-1000-250.txt
new file mode 100644
index 0000000..8b1fa3c
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.599813
+Clock time: 2.807879
diff --git a/mpi/timing-study/output-4-1000-500.txt b/mpi/timing-study/output-4-1000-500.txt
new file mode 100644
index 0000000..b3ce6ae
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.212790
+Clock time: 4.133439
diff --git a/mpi/timing-study/output-4-1000-750.txt b/mpi/timing-study/output-4-1000-750.txt
new file mode 100644
index 0000000..59aa17f
--- /dev/null
+++ b/mpi/timing-study/output-4-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.830949
+Clock time: 6.854574
diff --git a/mpi/timing-study/output-8-1000-1000.txt b/mpi/timing-study/output-8-1000-1000.txt
new file mode 100644
index 0000000..c063ee2
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.226861
+Clock time: 7.517444
diff --git a/mpi/timing-study/output-8-1000-1250.txt b/mpi/timing-study/output-8-1000-1250.txt
new file mode 100644
index 0000000..4be7ca8
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-1250.txt
@@ -0,0 +1,11 @@
+
+===================================================================================
+= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
+= PID 22852 RUNNING AT kp013
+= EXIT CODE: 11
+= CLEANING UP REMAINING PROCESSES
+= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
+===================================================================================
+YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
+This typically refers to a problem with your application.
+Please see the FAQ page for debugging suggestions
diff --git a/mpi/timing-study/output-8-1000-1500.txt b/mpi/timing-study/output-8-1000-1500.txt
new file mode 100644
index 0000000..957fc99
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 9.416485
+Clock time: 16.706325
diff --git a/mpi/timing-study/output-8-1000-1750.txt b/mpi/timing-study/output-8-1000-1750.txt
new file mode 100644
index 0000000..8dbd945
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 12.741221
+Clock time: 22.281683
diff --git a/mpi/timing-study/output-8-1000-2000.txt b/mpi/timing-study/output-8-1000-2000.txt
new file mode 100644
index 0000000..9610e3f
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 16.578412
+Clock time: 26.921717
diff --git a/mpi/timing-study/output-8-1000-250.txt b/mpi/timing-study/output-8-1000-250.txt
new file mode 100644
index 0000000..ca01ca3
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.296146
+Clock time: 2.211905
diff --git a/mpi/timing-study/output-8-1000-500.txt b/mpi/timing-study/output-8-1000-500.txt
new file mode 100644
index 0000000..3e3b83c
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.111486
+Clock time: 2.710176
diff --git a/mpi/timing-study/output-8-1000-750.txt b/mpi/timing-study/output-8-1000-750.txt
new file mode 100644
index 0000000..4a98753
--- /dev/null
+++ b/mpi/timing-study/output-8-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.419305
+Clock time: 4.675962
diff --git a/mpi/timing-study/slurm-10870703.err-kp013 b/mpi/timing-study/slurm-10870703.err-kp013
new file mode 100644
index 0000000..4bdaa5d
--- /dev/null
+++ b/mpi/timing-study/slurm-10870703.err-kp013
@@ -0,0 +1,11 @@
+mkdir: cannot create directory ‘timing-study’: File exists
+[proxy:0:0@kp013] HYD_pmcd_pmip_control_cmd_cb (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/pm/pmiserv/pmip_cb.c:887): assert (!closed) failed
+[proxy:0:0@kp013] HYDT_dmxu_poll_wait_for_event (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/tools/demux/demux_poll.c:76): callback returned error status
+[proxy:0:0@kp013] main (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/pm/pmiserv/pmip.c:202): demux engine error waiting for event
+srun: error: kp013: task 0: Exited with exit code 7
+[mpiexec@kp013] HYDT_bscu_wait_for_completion (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/tools/bootstrap/utils/bscu_wait.c:76): one of the processes terminated badly; aborting
+[mpiexec@kp013] HYDT_bsci_wait_for_completion (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/tools/bootstrap/src/bsci_wait.c:23): launcher returned error waiting for completion
+[mpiexec@kp013] HYD_pmci_wait_for_completion (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/pm/pmiserv/pmiserv_pmci.c:218): launcher returned error waiting for completion
+[mpiexec@kp013] main (../../../../../../srcdir/mpich/3.2.1/src/pm/hydra/ui/mpich/mpiexec.c:340): process manager error waiting for completion
+srun: error: Unable to create step for job 10870703: Job/step already completing or completed
+slurmstepd: error: *** JOB 10870703 ON kp013 CANCELLED AT 2021-12-08T01:29:02 DUE TO TIME LIMIT ***
diff --git a/mpi/timing-study/slurm-10870703.out-kp013 b/mpi/timing-study/slurm-10870703.out-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mpi/timing-study/slurm-10870703.out-kp013
diff --git a/mpi/timing-study/timing_study.sh b/mpi/timing-study/timing_study.sh
new file mode 100644
index 0000000..04b64ff
--- /dev/null
+++ b/mpi/timing-study/timing_study.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#SBATCH --time=0:10:00 # walltime, abbreviated by -t
+#SBATCH --nodes=2 # number of cluster nodes, abbreviated by -N
+#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first node (%N)
+#SBATCH -e slurm-%j.err-%N # name of the stderr, using job and first node values
+#SBATCH --ntasks=24 # number of MPI tasks, abbreviated by -n
+# additional information for allocated clusters
+#SBATCH --account=usucs5030 # account - abbreviated by -A
+#SBATCH --partition=kingspeak # partition, abbreviated by -p
+
+cd $HOME/gol/mpi
+mkdir timing-study
+
+module load intel mpich
+
+iterations=1000
+
+for cores in 1 4 8 12 16 20 #24
+do
+ for size in 250 500 750 1000 1250 1500 1750 2000
+ do
+ mpirun -np $cores ./gol simulate random $size $size $iterations 1 > timing-study/output-$cores-$iterations-$size.txt
+ done
+done
diff --git a/openmp/src/create_grid.c b/openmp/src/create_grid.c
index d6a5b94..a48317d 100644
--- a/openmp/src/create_grid.c
+++ b/openmp/src/create_grid.c
@@ -1,5 +1,6 @@
#include "create_grid.h"
+// Print entirety of a grid to verify input
void print_grid(struct GAME* game) {
printf("\n===GRID===\n");
for (int y = 0; y < game->height; y++) {
@@ -10,6 +11,7 @@ void print_grid(struct GAME* game) {
}
}
+// Go through user input
void create_grid(int argc, char** argv) {
char* filename;
struct GAME game;
diff --git a/openmp/src/file.c b/openmp/src/file.c
index 3ecb613..e10b667 100644
--- a/openmp/src/file.c
+++ b/openmp/src/file.c
@@ -1,5 +1,6 @@
#include "file.h"
+// Read a grid from a binary file into the space without padding
void read_in(char* filename, struct GAME* game) {
FILE* file = fopen(filename, "rb");
for (int i = game->padding; i < game->height+game->padding; i++) {
@@ -8,6 +9,7 @@ void read_in(char* filename, struct GAME* game) {
fclose(file);
}
+// Write a grid to a binary file into the space without padding
void write_out(char* filename, struct GAME* game) {
FILE* file = fopen(filename, "w+");
for (int i = game->padding; i < game->height+game->padding; i++) {
diff --git a/openmp/src/game.c b/openmp/src/game.c
index b5e786d..cac6fa0 100644
--- a/openmp/src/game.c
+++ b/openmp/src/game.c
@@ -1,5 +1,6 @@
#include "game.h"
+// Calculate the number of live neighbors a cell has
int neighbors(struct GAME* game, int x, int y) {
int n = 0;
for (int dy = -1; dy <= 1; dy++) {
@@ -15,6 +16,7 @@ int neighbors(struct GAME* game, int x, int y) {
return n;
}
+// Compute the next iteration of a board
void next(struct GAME* game, int threads) {
unsigned char** newGrid = malloc(sizeof(unsigned char*) * (game->height+(game->padding*2)));
int y,x,i,size;
@@ -30,10 +32,12 @@ void next(struct GAME* game, int threads) {
#pragma omp parallel num_threads(threads) shared(per_thread, threads, total_width, total_height, newGrid, game) private(y,x,i)
{
+ // Each thread gets a number of cells to compute
int me = omp_get_thread_num();
int thread_start = per_thread * me;
int thread_end = thread_start + per_thread + (me == threads-1 ? (total_width*total_height) % per_thread : 0);
for (i = thread_start; i < thread_end; i++) {
+ // Iterate through each cell assigned for this thread
y = i / total_width;
x = i % total_width;
int my_neighbors = neighbors(game, x, y);
@@ -55,6 +59,7 @@ void next(struct GAME* game, int threads) {
game->grid = newGrid;
}
+//Rnadomly assign life value to each cell
void randomize(struct GAME* game) {
for (int y = game->padding; y < game->height+game->padding; y++) {
for (int x = game->padding; x < game->width+game->padding; x++) {
diff --git a/openmp/src/main.c b/openmp/src/main.c
index 68ec0bd..50fb096 100644
--- a/openmp/src/main.c
+++ b/openmp/src/main.c
@@ -19,6 +19,7 @@
//#define VERBOSE 1
#define SEED 100
+// Do the simulation
void simulate(int argc, char** argv) {
srand(SEED);
char* filename;
@@ -26,6 +27,7 @@ void simulate(int argc, char** argv) {
game.padding = PADDING;
int iterations, log_each_step, threads;
if (argc == 8) {
+ // Parse the arguments
filename = argv[2];
game.width = atoi(argv[3]);
game.height = atoi(argv[4]);
@@ -51,6 +53,7 @@ void simulate(int argc, char** argv) {
memset(game.grid[i], 0, game.width+(2*game.padding));
}
+ // Choose where to read initial position
if (strcmp(filename, "random") == 0) {
randomize(&game);
} else {
@@ -62,16 +65,19 @@ void simulate(int argc, char** argv) {
double start, end;
for (int i = 0; i <= iterations; i++) {
+ // Iteration 0 will just be the initial grid
if (i > 0) {
- // Iteration 0 is just the input board
start = omp_get_wtime();
+ // Compute the next grid with threads
next(&game, threads);
end = omp_get_wtime();
time_computing_life += ((double) (end - start));
}
if (log_each_step) {
+ // If we are logging each step, perform IO operations
#if VERBOSE == 1
printf("\n===Iteration %i===\n", i);
+ // Print the board without the padding elements
for (int y = game.padding; y < game.height+game.padding; y++) {
for (int x = game.padding; x < game.width+game.padding; x++) {
printf("%s ", game.grid[y][x] ? "X" : " ");
@@ -80,6 +86,7 @@ void simulate(int argc, char** argv) {
}
printf("===End iteration %i===\n", i);
#endif
+ // Save to a file
sprintf(iteration_file, "output/iteration-%07d.bin", i);
write_out(iteration_file, &game);
}
diff --git a/openmp/timing-study/output-1-1000-1000.txt b/openmp/timing-study/output-1-1000-1000.txt
new file mode 100644
index 0000000..42681a1
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 73.312715
+Clock time: 77.450210
diff --git a/openmp/timing-study/output-1-1000-1250.txt b/openmp/timing-study/output-1-1000-1250.txt
new file mode 100644
index 0000000..ba1464f
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 113.646203
+Clock time: 118.646829
diff --git a/openmp/timing-study/output-1-1000-1500.txt b/openmp/timing-study/output-1-1000-1500.txt
new file mode 100644
index 0000000..7d09b62
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 163.034248
+Clock time: 171.017339
diff --git a/openmp/timing-study/output-1-1000-1750.txt b/openmp/timing-study/output-1-1000-1750.txt
new file mode 100644
index 0000000..66bcb80
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 220.656360
+Clock time: 231.050593
diff --git a/openmp/timing-study/output-1-1000-2000.txt b/openmp/timing-study/output-1-1000-2000.txt
new file mode 100644
index 0000000..a11469d
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 287.698970
+Clock time: 300.176503
diff --git a/openmp/timing-study/output-1-1000-250.txt b/openmp/timing-study/output-1-1000-250.txt
new file mode 100644
index 0000000..420bfe2
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 5.088550
+Clock time: 5.963468
diff --git a/openmp/timing-study/output-1-1000-500.txt b/openmp/timing-study/output-1-1000-500.txt
new file mode 100644
index 0000000..066b863
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 18.956314
+Clock time: 20.440567
diff --git a/openmp/timing-study/output-1-1000-750.txt b/openmp/timing-study/output-1-1000-750.txt
new file mode 100644
index 0000000..991980d
--- /dev/null
+++ b/openmp/timing-study/output-1-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 41.660313
+Clock time: 44.581177
diff --git a/openmp/timing-study/output-12-1000-1000.txt b/openmp/timing-study/output-12-1000-1000.txt
new file mode 100644
index 0000000..613af8c
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 7.026118
+Clock time: 10.251363
diff --git a/openmp/timing-study/output-12-1000-1250.txt b/openmp/timing-study/output-12-1000-1250.txt
new file mode 100644
index 0000000..57fbe93
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 10.801676
+Clock time: 15.900482
diff --git a/openmp/timing-study/output-12-1000-1500.txt b/openmp/timing-study/output-12-1000-1500.txt
new file mode 100644
index 0000000..0211559
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 25.918769
+Clock time: 34.562182
diff --git a/openmp/timing-study/output-12-1000-1750.txt b/openmp/timing-study/output-12-1000-1750.txt
new file mode 100644
index 0000000..0cf8832
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 25.862278
+Clock time: 34.828966
diff --git a/openmp/timing-study/output-12-1000-2000.txt b/openmp/timing-study/output-12-1000-2000.txt
new file mode 100644
index 0000000..b407d23
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 30.705054
+Clock time: 43.042410
diff --git a/openmp/timing-study/output-12-1000-250.txt b/openmp/timing-study/output-12-1000-250.txt
new file mode 100644
index 0000000..5c7f4a4
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.860293
+Clock time: 3.331446
diff --git a/openmp/timing-study/output-12-1000-500.txt b/openmp/timing-study/output-12-1000-500.txt
new file mode 100644
index 0000000..2af2794
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.097878
+Clock time: 3.643646
diff --git a/openmp/timing-study/output-12-1000-750.txt b/openmp/timing-study/output-12-1000-750.txt
new file mode 100644
index 0000000..5e235a9
--- /dev/null
+++ b/openmp/timing-study/output-12-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.321400
+Clock time: 6.663178
diff --git a/openmp/timing-study/output-16-1000-1000.txt b/openmp/timing-study/output-16-1000-1000.txt
new file mode 100644
index 0000000..7f376d5
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 9.131005
+Clock time: 12.449032
diff --git a/openmp/timing-study/output-16-1000-1250.txt b/openmp/timing-study/output-16-1000-1250.txt
new file mode 100644
index 0000000..d57a287
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 13.434282
+Clock time: 18.116181
diff --git a/openmp/timing-study/output-16-1000-1500.txt b/openmp/timing-study/output-16-1000-1500.txt
new file mode 100644
index 0000000..8b11fc0
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 16.706991
+Clock time: 24.712374
diff --git a/openmp/timing-study/output-16-1000-1750.txt b/openmp/timing-study/output-16-1000-1750.txt
new file mode 100644
index 0000000..c0018ec
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 23.733395
+Clock time: 33.306681
diff --git a/openmp/timing-study/output-16-1000-2000.txt b/openmp/timing-study/output-16-1000-2000.txt
new file mode 100644
index 0000000..bd9c5d0
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 30.429469
+Clock time: 42.369926
diff --git a/openmp/timing-study/output-16-1000-250.txt b/openmp/timing-study/output-16-1000-250.txt
new file mode 100644
index 0000000..dc8331f
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.738930
+Clock time: 3.383995
diff --git a/openmp/timing-study/output-16-1000-500.txt b/openmp/timing-study/output-16-1000-500.txt
new file mode 100644
index 0000000..f86a977
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.352756
+Clock time: 3.601057
diff --git a/openmp/timing-study/output-16-1000-750.txt b/openmp/timing-study/output-16-1000-750.txt
new file mode 100644
index 0000000..75efb03
--- /dev/null
+++ b/openmp/timing-study/output-16-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 5.147589
+Clock time: 7.427564
diff --git a/openmp/timing-study/output-20-1000-1000.txt b/openmp/timing-study/output-20-1000-1000.txt
new file mode 100644
index 0000000..206d879
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 7.390921
+Clock time: 11.239737
diff --git a/openmp/timing-study/output-20-1000-1250.txt b/openmp/timing-study/output-20-1000-1250.txt
new file mode 100644
index 0000000..86f7469
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 11.254777
+Clock time: 16.136264
diff --git a/openmp/timing-study/output-20-1000-1500.txt b/openmp/timing-study/output-20-1000-1500.txt
new file mode 100644
index 0000000..3c905b0
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 16.076534
+Clock time: 23.718524
diff --git a/openmp/timing-study/output-20-1000-1750.txt b/openmp/timing-study/output-20-1000-1750.txt
new file mode 100644
index 0000000..db999b9
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 21.727030
+Clock time: 31.285851
diff --git a/openmp/timing-study/output-20-1000-2000.txt b/openmp/timing-study/output-20-1000-2000.txt
new file mode 100644
index 0000000..b8c5e44
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 28.363274
+Clock time: 40.847248
diff --git a/openmp/timing-study/output-20-1000-250.txt b/openmp/timing-study/output-20-1000-250.txt
new file mode 100644
index 0000000..1dc5094
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.555697
+Clock time: 2.156701
diff --git a/openmp/timing-study/output-20-1000-500.txt b/openmp/timing-study/output-20-1000-500.txt
new file mode 100644
index 0000000..d394ec5
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.944395
+Clock time: 3.506218
diff --git a/openmp/timing-study/output-20-1000-750.txt b/openmp/timing-study/output-20-1000-750.txt
new file mode 100644
index 0000000..a52ddf0
--- /dev/null
+++ b/openmp/timing-study/output-20-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.297441
+Clock time: 6.404743
diff --git a/openmp/timing-study/output-24-1000-1000.txt b/openmp/timing-study/output-24-1000-1000.txt
new file mode 100644
index 0000000..8f4e5a3
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 6.344307
+Clock time: 9.689612
diff --git a/openmp/timing-study/output-24-1000-1250.txt b/openmp/timing-study/output-24-1000-1250.txt
new file mode 100644
index 0000000..819e097
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 9.870428
+Clock time: 14.864989
diff --git a/openmp/timing-study/output-24-1000-1500.txt b/openmp/timing-study/output-24-1000-1500.txt
new file mode 100644
index 0000000..f19ee37
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 13.883823
+Clock time: 21.691046
diff --git a/openmp/timing-study/output-24-1000-1750.txt b/openmp/timing-study/output-24-1000-1750.txt
new file mode 100644
index 0000000..a1079b9
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 18.691083
+Clock time: 26.919679
diff --git a/openmp/timing-study/output-24-1000-2000.txt b/openmp/timing-study/output-24-1000-2000.txt
new file mode 100644
index 0000000..e21c9f1
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 24.792304
+Clock time: 36.801597
diff --git a/openmp/timing-study/output-24-1000-250.txt b/openmp/timing-study/output-24-1000-250.txt
new file mode 100644
index 0000000..eaa55fb
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.613609
+Clock time: 3.196133
diff --git a/openmp/timing-study/output-24-1000-500.txt b/openmp/timing-study/output-24-1000-500.txt
new file mode 100644
index 0000000..a0c8a7f
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.735787
+Clock time: 3.401682
diff --git a/openmp/timing-study/output-24-1000-750.txt b/openmp/timing-study/output-24-1000-750.txt
new file mode 100644
index 0000000..7f4e763
--- /dev/null
+++ b/openmp/timing-study/output-24-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 3.754690
+Clock time: 5.885699
diff --git a/openmp/timing-study/output-4-1000-1000.txt b/openmp/timing-study/output-4-1000-1000.txt
new file mode 100644
index 0000000..488f5bf
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 19.561461
+Clock time: 23.064553
diff --git a/openmp/timing-study/output-4-1000-1250.txt b/openmp/timing-study/output-4-1000-1250.txt
new file mode 100644
index 0000000..0c61b09
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 29.425730
+Clock time: 34.283721
diff --git a/openmp/timing-study/output-4-1000-1500.txt b/openmp/timing-study/output-4-1000-1500.txt
new file mode 100644
index 0000000..040f8b7
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 42.126591
+Clock time: 50.662123
diff --git a/openmp/timing-study/output-4-1000-1750.txt b/openmp/timing-study/output-4-1000-1750.txt
new file mode 100644
index 0000000..83870a1
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 57.302075
+Clock time: 66.844318
diff --git a/openmp/timing-study/output-4-1000-2000.txt b/openmp/timing-study/output-4-1000-2000.txt
new file mode 100644
index 0000000..149b7a2
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 76.421121
+Clock time: 88.379760
diff --git a/openmp/timing-study/output-4-1000-250.txt b/openmp/timing-study/output-4-1000-250.txt
new file mode 100644
index 0000000..9623aa2
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 1.413768
+Clock time: 3.713147
diff --git a/openmp/timing-study/output-4-1000-500.txt b/openmp/timing-study/output-4-1000-500.txt
new file mode 100644
index 0000000..0c18324
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.947206
+Clock time: 6.380269
diff --git a/openmp/timing-study/output-4-1000-750.txt b/openmp/timing-study/output-4-1000-750.txt
new file mode 100644
index 0000000..9086291
--- /dev/null
+++ b/openmp/timing-study/output-4-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 10.829915
+Clock time: 13.182029
diff --git a/openmp/timing-study/output-8-1000-1000.txt b/openmp/timing-study/output-8-1000-1000.txt
new file mode 100644
index 0000000..ebe72e8
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 9.924235
+Clock time: 13.583743
diff --git a/openmp/timing-study/output-8-1000-1250.txt b/openmp/timing-study/output-8-1000-1250.txt
new file mode 100644
index 0000000..ec82ee8
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 15.336835
+Clock time: 20.191594
diff --git a/openmp/timing-study/output-8-1000-1500.txt b/openmp/timing-study/output-8-1000-1500.txt
new file mode 100644
index 0000000..7741d7f
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 21.996220
+Clock time: 30.139829
diff --git a/openmp/timing-study/output-8-1000-1750.txt b/openmp/timing-study/output-8-1000-1750.txt
new file mode 100644
index 0000000..f62ef5a
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 29.524371
+Clock time: 39.165025
diff --git a/openmp/timing-study/output-8-1000-2000.txt b/openmp/timing-study/output-8-1000-2000.txt
new file mode 100644
index 0000000..da43dc5
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 38.636923
+Clock time: 50.111060
diff --git a/openmp/timing-study/output-8-1000-250.txt b/openmp/timing-study/output-8-1000-250.txt
new file mode 100644
index 0000000..6301921
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 0.803572
+Clock time: 3.170951
diff --git a/openmp/timing-study/output-8-1000-500.txt b/openmp/timing-study/output-8-1000-500.txt
new file mode 100644
index 0000000..da9f4a2
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 2.643531
+Clock time: 4.040041
diff --git a/openmp/timing-study/output-8-1000-750.txt b/openmp/timing-study/output-8-1000-750.txt
new file mode 100644
index 0000000..70b85a1
--- /dev/null
+++ b/openmp/timing-study/output-8-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 5.837011
+Clock time: 8.027314
diff --git a/openmp/timing-study/slurm-10870649.err-kp013 b/openmp/timing-study/slurm-10870649.err-kp013
new file mode 100644
index 0000000..5e4a08a
--- /dev/null
+++ b/openmp/timing-study/slurm-10870649.err-kp013
@@ -0,0 +1 @@
+slurmstepd: error: *** JOB 10870649 ON kp013 CANCELLED AT 2021-12-07T21:36:02 DUE TO TIME LIMIT ***
diff --git a/openmp/timing-study/slurm-10870649.out-kp013 b/openmp/timing-study/slurm-10870649.out-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openmp/timing-study/slurm-10870649.out-kp013
diff --git a/openmp/timing-study/slurm-10870651.err-kp013 b/openmp/timing-study/slurm-10870651.err-kp013
new file mode 100644
index 0000000..367d47f
--- /dev/null
+++ b/openmp/timing-study/slurm-10870651.err-kp013
@@ -0,0 +1 @@
+slurmstepd: error: *** JOB 10870651 ON kp013 CANCELLED AT 2021-12-07T22:07:02 DUE TO TIME LIMIT ***
diff --git a/openmp/timing-study/slurm-10870651.out-kp013 b/openmp/timing-study/slurm-10870651.out-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openmp/timing-study/slurm-10870651.out-kp013
diff --git a/openmp/timing-study/slurm-10870663.err-kp013 b/openmp/timing-study/slurm-10870663.err-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openmp/timing-study/slurm-10870663.err-kp013
diff --git a/openmp/timing-study/slurm-10870663.out-kp013 b/openmp/timing-study/slurm-10870663.out-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openmp/timing-study/slurm-10870663.out-kp013
diff --git a/openmp/timing-study/timing_study.sh b/openmp/timing-study/timing_study.sh
new file mode 100644
index 0000000..16771a6
--- /dev/null
+++ b/openmp/timing-study/timing_study.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#SBATCH --time=0:30:00 # walltime, abbreviated by -t
+#SBATCH --nodes=2 # number of cluster nodes, abbreviated by -N
+#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first node (%N)
+#SBATCH -e slurm-%j.err-%N # name of the stderr, using job and first node values
+#SBATCH --ntasks=32
+# additional information for allocated clusters
+#SBATCH --account=usucs5030 # account - abbreviated by -A
+#SBATCH --partition=kingspeak # partition, abbreviated by -p
+
+cd $HOME/gol/openmp
+
+module load intel openmpi
+
+iterations=1000
+
+for threads in 20 24 #1 4 8 12 16 20 24
+do
+ for size in 250 500 750 1000 1250 1500 1750 2000
+ do
+ ./gol simulate random $size $size $iterations 1 $threads > timing-study/output-$threads-$iterations-$size.txt
+ done
+done
diff --git a/serial/src/create_grid.c b/serial/src/create_grid.c
index d6a5b94..a48317d 100644
--- a/serial/src/create_grid.c
+++ b/serial/src/create_grid.c
@@ -1,5 +1,6 @@
#include "create_grid.h"
+// Print entirety of a grid to verify input
void print_grid(struct GAME* game) {
printf("\n===GRID===\n");
for (int y = 0; y < game->height; y++) {
@@ -10,6 +11,7 @@ void print_grid(struct GAME* game) {
}
}
+// Go through user input
void create_grid(int argc, char** argv) {
char* filename;
struct GAME game;
diff --git a/serial/src/file.c b/serial/src/file.c
index 3ecb613..e10b667 100644
--- a/serial/src/file.c
+++ b/serial/src/file.c
@@ -1,5 +1,6 @@
#include "file.h"
+// Read a grid from a binary file into the space without padding
void read_in(char* filename, struct GAME* game) {
FILE* file = fopen(filename, "rb");
for (int i = game->padding; i < game->height+game->padding; i++) {
@@ -8,6 +9,7 @@ void read_in(char* filename, struct GAME* game) {
fclose(file);
}
+// Write a grid to a binary file into the space without padding
void write_out(char* filename, struct GAME* game) {
FILE* file = fopen(filename, "w+");
for (int i = game->padding; i < game->height+game->padding; i++) {
diff --git a/serial/src/game.c b/serial/src/game.c
index 2921e3c..ebaab1b 100644
--- a/serial/src/game.c
+++ b/serial/src/game.c
@@ -1,5 +1,6 @@
#include "game.h"
+// Calculate the number of live neighbors a cell has
int neighbors(struct GAME* game, int x, int y) {
int n = 0;
for (int dy = -1; dy <= 1; dy++) {
@@ -15,6 +16,7 @@ int neighbors(struct GAME* game, int x, int y) {
return n;
}
+// Compute the next iteration of a board
void next(struct GAME* game) {
unsigned char** newGrid = malloc(sizeof(unsigned char*) * (game->height+(game->padding*2)));
int size = sizeof(unsigned char) * (game->width+(game->padding*2));
@@ -23,6 +25,7 @@ void next(struct GAME* game) {
memset(newGrid[y], 0, size);
}
+ // Iterate through each cell
for (int y = 0; y < game->height+(game->padding*2); y++) {
for (int x = 0; x < game->width+(game->padding*2); x++) {
int my_neighbors = neighbors(game, x, y);
@@ -44,6 +47,7 @@ void next(struct GAME* game) {
game->grid = newGrid;
}
+// Randomly assign life value to each cell
void randomize(struct GAME* game) {
for (int y = game->padding; y < game->height+game->padding; y++) {
for (int x = game->padding; x < game->width+game->padding; x++) {
diff --git a/serial/src/main.c b/serial/src/main.c
index f4c8141..c7cdacf 100644
--- a/serial/src/main.c
+++ b/serial/src/main.c
@@ -18,6 +18,7 @@
//#define VERBOSE 1
#define SEED 100
+// Do the simulation
void simulate(int argc, char** argv) {
srand(SEED);
char* filename;
@@ -25,6 +26,7 @@ void simulate(int argc, char** argv) {
game.padding = PADDING;
int iterations, log_each_step;
if (argc == 7) {
+ // Parse the arguments
filename = argv[2];
game.width = atoi(argv[3]);
game.height = atoi(argv[4]);
@@ -48,6 +50,7 @@ void simulate(int argc, char** argv) {
memset(game.grid[i], 0, game.width+(2*game.padding));
}
+ // Choose where to read initial position
if (strcmp(filename, "random") == 0) {
randomize(&game);
} else {
@@ -55,20 +58,25 @@ void simulate(int argc, char** argv) {
}
char iteration_file[1024];
+
+ // Timing code
double time_computing_life = 0;
clock_t start, end;
for (int i = 0; i <= iterations; i++) {
+ // Iteration 0 will just be the initial grid
if (i > 0) {
- // Iteration 0 is just the input board
start = clock();
+ // Compute the next grid
next(&game);
end = clock();
time_computing_life += ((double) (end - start)) / CLOCKS_PER_SEC;
}
if (log_each_step) {
+ // If we are logging each step, perform IO operations
#if VERBOSE == 1
printf("\n===Iteration %i===\n", i);
+ // Print the board without the padding elements
for (int y = game.padding; y < game.height+game.padding; y++) {
for (int x = game.padding; x < game.width+game.padding; x++) {
printf("%s ", game.grid[y][x] ? "X" : " ");
@@ -77,6 +85,7 @@ void simulate(int argc, char** argv) {
}
printf("===End iteration %i===\n", i);
#endif
+ // Save to a file
sprintf(iteration_file, "output/iteration-%07d.bin", i);
write_out(iteration_file, &game);
}
diff --git a/serial/timing-study/output-1-1000-1000.txt b/serial/timing-study/output-1-1000-1000.txt
new file mode 100644
index 0000000..4445862
--- /dev/null
+++ b/serial/timing-study/output-1-1000-1000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 65.330000
+Clock time: 66.520000
diff --git a/serial/timing-study/output-1-1000-1250.txt b/serial/timing-study/output-1-1000-1250.txt
new file mode 100644
index 0000000..5adeb8d
--- /dev/null
+++ b/serial/timing-study/output-1-1000-1250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 101.210000
+Clock time: 103.190000
diff --git a/serial/timing-study/output-1-1000-1500.txt b/serial/timing-study/output-1-1000-1500.txt
new file mode 100644
index 0000000..30ddd59
--- /dev/null
+++ b/serial/timing-study/output-1-1000-1500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 145.440000
+Clock time: 148.020000
diff --git a/serial/timing-study/output-1-1000-1750.txt b/serial/timing-study/output-1-1000-1750.txt
new file mode 100644
index 0000000..25fa9c5
--- /dev/null
+++ b/serial/timing-study/output-1-1000-1750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 196.590000
+Clock time: 200.020000
diff --git a/serial/timing-study/output-1-1000-2000.txt b/serial/timing-study/output-1-1000-2000.txt
new file mode 100644
index 0000000..3582584
--- /dev/null
+++ b/serial/timing-study/output-1-1000-2000.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 256.560000
+Clock time: 260.770000
diff --git a/serial/timing-study/output-1-1000-250.txt b/serial/timing-study/output-1-1000-250.txt
new file mode 100644
index 0000000..c7652f2
--- /dev/null
+++ b/serial/timing-study/output-1-1000-250.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 4.560000
+Clock time: 4.830000
diff --git a/serial/timing-study/output-1-1000-500.txt b/serial/timing-study/output-1-1000-500.txt
new file mode 100644
index 0000000..c6b006d
--- /dev/null
+++ b/serial/timing-study/output-1-1000-500.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 16.990000
+Clock time: 17.340000
diff --git a/serial/timing-study/output-1-1000-750.txt b/serial/timing-study/output-1-1000-750.txt
new file mode 100644
index 0000000..fddfee8
--- /dev/null
+++ b/serial/timing-study/output-1-1000-750.txt
@@ -0,0 +1,4 @@
+
+===Timing===
+Time computing life: 36.980000
+Clock time: 37.830000
diff --git a/serial/timing-study/slurm-10870643.err-kp013 b/serial/timing-study/slurm-10870643.err-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/serial/timing-study/slurm-10870643.err-kp013
diff --git a/serial/timing-study/slurm-10870643.out-kp013 b/serial/timing-study/slurm-10870643.out-kp013
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/serial/timing-study/slurm-10870643.out-kp013
diff --git a/serial/timing-study/timing_study.sh b/serial/timing-study/timing_study.sh
new file mode 100644
index 0000000..20f405d
--- /dev/null
+++ b/serial/timing-study/timing_study.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+#SBATCH --time=0:35:00 # walltime, abbreviated by -t
+#SBATCH --nodes=1 # number of cluster nodes, abbreviated by -N
+#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first node (%N)
+#SBATCH -e slurm-%j.err-%N # name of the stderr, using job and first node values
+#SBATCH --ntasks=1 # number of MPI tasks, abbreviated by -n
+# additional information for allocated clusters
+#SBATCH --account=usucs5030 # account - abbreviated by -A
+#SBATCH --partition=kingspeak # partition, abbreviated by -p
+
+cd $HOME/gol/serial
+
+iterations=1000
+cores=1
+
+for size in 250 500 750 1000 1250 1500 1750 2000
+do
+ ./gol simulate random $size $size $iterations 1 > timing-study/output-$cores-$iterations-$size.txt
+done