Benchmark results now written out to a file

This commit is contained in:
Johannes Pekkila
2019-10-24 15:53:08 +02:00
parent 4ffde83215
commit 981331e7d7

View File

@@ -810,8 +810,8 @@ get_neighbor(const int3 offset)
MPI_Comm_rank(MPI_COMM_WORLD, &pid); MPI_Comm_rank(MPI_COMM_WORLD, &pid);
MPI_Comm_size(MPI_COMM_WORLD, &num_processes); MPI_Comm_size(MPI_COMM_WORLD, &num_processes);
const int n = floor(cbrt(num_processes)); const int n = (int)cbrt(num_processes);
ERRCHK_ALWAYS(ceil(cbrt(num_processes)) == n); ERRCHK_ALWAYS((int)ceil(cbrt(num_processes)) == n);
ERRCHK_ALWAYS(n * n * n == num_processes); ERRCHK_ALWAYS(n * n * n == num_processes);
return mod(pid + offset.x, n) + offset.y * n + offset.z * n * n; return mod(pid + offset.x, n) + offset.y * n + offset.z * n * n;
@@ -1235,10 +1235,14 @@ acDeviceRunMPITest(void)
acMeshRandomize(&submesh); acMeshRandomize(&submesh);
acDeviceDistributeMeshMPI(model, &submesh); acDeviceDistributeMeshMPI(model, &submesh);
#define VERIFY (0)
// Master CPU // Master CPU
#if VERIFY
if (pid == 0) { if (pid == 0) {
acMeshApplyPeriodicBounds(&model); acMeshApplyPeriodicBounds(&model);
} }
#endif
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
Device device; Device device;
@@ -1246,14 +1250,14 @@ acDeviceRunMPITest(void)
acDeviceLoadMesh(device, STREAM_DEFAULT, submesh); acDeviceLoadMesh(device, STREAM_DEFAULT, submesh);
// Warmup // Warmup
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 5; ++i) {
acDeviceIntegrateStepMPI(device, FLT_EPSILON); acDeviceIntegrateStepMPI(device, FLT_EPSILON);
} }
acDeviceSynchronizeStream(device, STREAM_ALL); acDeviceSynchronizeStream(device, STREAM_ALL);
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
// Benchmark // Benchmark
const int num_iters = 1000; const int num_iters = 100;
Timer total_time; Timer total_time;
timer_reset(&total_time); timer_reset(&total_time);
for (int i = 0; i < num_iters; ++i) { for (int i = 0; i < num_iters; ++i) {
@@ -1267,6 +1271,13 @@ acDeviceRunMPITest(void)
printf("vertices: %d^3, iterations: %d\n", nn, num_iters); printf("vertices: %d^3, iterations: %d\n", nn, num_iters);
printf("Total time: %f ms\n", ms_elapsed); printf("Total time: %f ms\n", ms_elapsed);
printf("Time per step: %f ms\n", ms_elapsed / num_iters); printf("Time per step: %f ms\n", ms_elapsed / num_iters);
char buf[256];
sprintf(buf, "procs_%d.bench", num_processes);
FILE* fp = fopen(buf, "w");
ERRCHK_ALWAYS(fp);
fprintf(fp, "%d, %g", num_processes, ms_elapsed);
fclose(fp);
} }
////////////////////////////// Timer end ////////////////////////////// Timer end
acDeviceBoundStepMPI(device); acDeviceBoundStepMPI(device);
@@ -1279,7 +1290,9 @@ acDeviceRunMPITest(void)
// Master CPU // Master CPU
if (pid == 0) { if (pid == 0) {
#if VERIFY
acVerifyMesh(model, candidate); acVerifyMesh(model, candidate);
#endif
acMeshDestroy(&model); acMeshDestroy(&model);
acMeshDestroy(&candidate); acMeshDestroy(&candidate);
} }