Commit 0f5a1d48 authored by Thomas Ponweiser's avatar Thomas Ponweiser
Browse files

removed unnecessary memcpy's, minor improvements

parent be1aa9f4
......@@ -5,6 +5,8 @@
#include "configuration.h"
#define MAX_ITERATIONS 100
const char *verbosity_levels[] = {"OFF", "INFO", "DEBUG", "TRACE"};
const char *communication_computation_modes[] = {
......@@ -80,6 +82,15 @@ void conf_init_from_args(conf_t *c, int argc, char* argv[])
}
}
if(c->n_iterations > MAX_ITERATIONS) {
fprintf(stderr,
"Specified number of iterations, %d, exceeds maximum of %d.\n"
"(One output file will be generated for each iteration)\n",
c->n_iterations, MAX_ITERATIONS
);
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
if(optind > argc) {
fprintf(stderr, "Expected base name of input file (omitting '.wi' file extension)\n");
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
......
......@@ -103,8 +103,9 @@ void iterate(const conf_t *c, world_t *world)
size_t header_length;
if(info_enabled(c)) printf(
"Running %d iterations with %ld generations per iteration.\n\n",
n_it, n_gen
"Running %d iteration%s with %ld generation%s per iteration.\n\n",
n_it, n_it == 1 ? "" : "s",
n_gen, n_gen == 1 ? "" : "s"
);
total_time = -MPI_Wtime();
......
......@@ -201,27 +201,23 @@ void do_simulation_persistent_request_no_overlap(world_t *world, size_t n_genera
const size_t sz = world_get_storage_size(world);
size_t g, i;
char *tmp = malloc(sz);
MPI_Request *requests = world->transfer.persistent_requests;
for(g = 0; g < n_generations; g++) {
// Persistent send/receive requests have been initialized with pointer to world->cell_prev.
// Swapping pointers here will therefore not work and swapping memory is necessary.
// Swapping pointers here will therefore not work and copying memory is necessary.
//
// Possible Optimization:
// ----------------------
// Alternately using two sets of persistent requests (one for world->cells_prev and world->cells_next).
memcpy(tmp, world->cells_prev, sz);
memcpy(world->cells_prev, world->cells_next, sz);
memcpy(world->cells_next, tmp, sz);
MPI_Startall(2*n_neighbors, requests);
MPI_Waitall(2*n_neighbors, requests, MPI_STATUSES_IGNORE);
wireworld_step_complete(world);
}
free(tmp);
}
void do_simulation_persistent_request_overlap(world_t *world, size_t n_generations)
......@@ -230,16 +226,12 @@ void do_simulation_persistent_request_overlap(world_t *world, size_t n_generatio
const size_t sz = world_get_storage_size(world);
size_t g, i;
char *tmp = malloc(sz);
MPI_Request *requests = world->transfer.persistent_requests;
for(g = 0; g < n_generations; g++) {
// See above note in the '_no_overlap' funciton.
memcpy(tmp, world->cells_prev, sz);
memcpy(world->cells_prev, world->cells_next, sz);
memcpy(world->cells_next, tmp, sz);
MPI_Startall(2*n_neighbors, requests);
......@@ -249,7 +241,6 @@ void do_simulation_persistent_request_overlap(world_t *world, size_t n_generatio
wireworld_step_boundary(world);
}
free(tmp);
}
void wireworld_step_complete(world_t *world)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment