Ensured that acBoundcondStep is called everywhere in the program before acStore

This commit is contained in:
jpekkila
2019-08-07 19:20:40 +03:00
parent d8eb2723b4
commit 2b3f9d75af
3 changed files with 29 additions and 29 deletions

View File

@@ -197,7 +197,6 @@ run_benchmark(void)
double(results[int(NTH_PERCENTILE * NUM_ITERS)]), int(NTH_PERCENTILE * 100), double(results[int(NTH_PERCENTILE * NUM_ITERS)]), int(NTH_PERCENTILE * 100),
mesh_info.int_params[AC_nx]); mesh_info.int_params[AC_nx]);
acStore(mesh);
acQuit(); acQuit();
acmesh_destroy(mesh); acmesh_destroy(mesh);
} }
@@ -269,7 +268,6 @@ run_benchmark(void)
write_result_to_file(wallclock * 1e3f / steps); write_result_to_file(wallclock * 1e3f / steps);
#endif #endif
acStore(mesh);
acQuit(); acQuit();
acmesh_destroy(mesh); acmesh_destroy(mesh);

View File

@@ -32,13 +32,13 @@
#include <string.h> // memcpy #include <string.h> // memcpy
#include "config_loader.h" #include "config_loader.h"
#include "src/core/errchk.h"
#include "src/core/math_utils.h"
#include "model/host_forcing.h" #include "model/host_forcing.h"
#include "model/host_memory.h" #include "model/host_memory.h"
#include "model/host_timestep.h" #include "model/host_timestep.h"
#include "model/model_reduce.h" #include "model/model_reduce.h"
#include "model/model_rk3.h" #include "model/model_rk3.h"
#include "src/core/errchk.h"
#include "src/core/math_utils.h"
#include "timer_hires.h" #include "timer_hires.h"
// Window // Window
@@ -410,9 +410,10 @@ run_renderer(void)
/* Render */ /* Render */
const float timer_diff_sec = timer_diff_nsec(frame_timer) / 1e9f; const float timer_diff_sec = timer_diff_nsec(frame_timer) / 1e9f;
if (timer_diff_sec >= desired_frame_time) { if (timer_diff_sec >= desired_frame_time) {
// acStore(mesh);
const int num_vertices = mesh->info.int_params[AC_mxy]; const int num_vertices = mesh->info.int_params[AC_mxy];
const int3 dst = (int3){0, 0, k_slice}; const int3 dst = (int3){0, 0, k_slice};
acBoundcondStep();
// acStore(mesh);
acStoreWithOffset(dst, num_vertices, mesh); acStoreWithOffset(dst, num_vertices, mesh);
acSynchronizeStream(STREAM_ALL); acSynchronizeStream(STREAM_ALL);
renderer_draw(*mesh); // Bottleneck is here renderer_draw(*mesh); // Bottleneck is here
@@ -422,7 +423,6 @@ run_renderer(void)
} }
printf("Wallclock time %f s\n", double(timer_diff_nsec(wallclock) / 1e9f)); printf("Wallclock time %f s\n", double(timer_diff_nsec(wallclock) / 1e9f));
acStore(mesh);
acQuit(); acQuit();
acmesh_destroy(mesh); acmesh_destroy(mesh);

View File

@@ -27,13 +27,13 @@
#include "run.h" #include "run.h"
#include "config_loader.h" #include "config_loader.h"
#include "src/core/errchk.h"
#include "src/core/math_utils.h"
#include "model/host_forcing.h" #include "model/host_forcing.h"
#include "model/host_memory.h" #include "model/host_memory.h"
#include "model/host_timestep.h" #include "model/host_timestep.h"
#include "model/model_reduce.h" #include "model/model_reduce.h"
#include "model/model_rk3.h" #include "model/model_rk3.h"
#include "src/core/errchk.h"
#include "src/core/math_utils.h"
#include "timer_hires.h" #include "timer_hires.h"
#include <string.h> #include <string.h>
@@ -205,6 +205,7 @@ run_simulation(void)
write_mesh_info(&mesh_info); write_mesh_info(&mesh_info);
print_diagnostics(0, AcReal(.0), t_step, diag_file); print_diagnostics(0, AcReal(.0), t_step, diag_file);
acBoundcondStep();
acStore(mesh); acStore(mesh);
save_mesh(*mesh, 0, t_step); save_mesh(*mesh, 0, t_step);
@@ -218,13 +219,13 @@ run_simulation(void)
/* initialize random seed: */ /* initialize random seed: */
srand(312256655); srand(312256655);
//TODO_SINK. init_sink_particle() // TODO_SINK. init_sink_particle()
// Initialize the basic variables of the sink particle to a suitable initial value. // Initialize the basic variables of the sink particle to a suitable initial value.
// 1. Location of the particle // 1. Location of the particle
// 2. Mass of the particle // 2. Mass of the particle
// (3. Velocity of the particle) // (3. Velocity of the particle)
// This at the level of Host in this case. // This at the level of Host in this case.
// acUpdate_sink_particle() will do the similar trick to the device. // acUpdate_sink_particle() will do the similar trick to the device.
/* Step the simulation */ /* Step the simulation */
for (int i = 1; i < max_steps; ++i) { for (int i = 1; i < max_steps; ++i) {
@@ -236,26 +237,26 @@ run_simulation(void)
loadForcingParamsToDevice(forcing_params); loadForcingParamsToDevice(forcing_params);
#endif #endif
//TODO_SINK acUpdate_sink_particle() // TODO_SINK acUpdate_sink_particle()
// Update properties of the sing particle for acIntegrate(). Essentially: // Update properties of the sing particle for acIntegrate(). Essentially:
// 1. Location of the particle // 1. Location of the particle
// 2. Mass of the particle // 2. Mass of the particle
// (3. Velocity of the particle) // (3. Velocity of the particle)
// These can be used for calculating he gravitational field. // These can be used for calculating he gravitational field.
acIntegrate(dt); acIntegrate(dt);
//TODO_SINK acAdvect_sink_particle() // TODO_SINK acAdvect_sink_particle()
// THIS IS OPTIONAL. We will start from unmoving particle. // THIS IS OPTIONAL. We will start from unmoving particle.
// 1. Calculate the equation of motion for the sink particle. // 1. Calculate the equation of motion for the sink particle.
// NOTE: Might require embedding with acIntegrate(dt). // NOTE: Might require embedding with acIntegrate(dt).
//TODO_SINK acAccrete_sink_particle() // TODO_SINK acAccrete_sink_particle()
// Calculate accretion of the sink particle from the surrounding medium // Calculate accretion of the sink particle from the surrounding medium
// 1. Transfer density into sink particle mass // 1. Transfer density into sink particle mass
// 2. Transfer momentum into sink particle // 2. Transfer momentum into sink particle
// (OPTIONAL: Affection the motion of the particle) // (OPTIONAL: Affection the motion of the particle)
// NOTE: Might require embedding with acIntegrate(dt). // NOTE: Might require embedding with acIntegrate(dt).
// This is the hardest part. Please see Lee et al. ApJ 783 (2014) for reference. // This is the hardest part. Please see Lee et al. ApJ 783 (2014) for reference.
t_step += dt; t_step += dt;
@@ -298,9 +299,10 @@ run_simulation(void)
assumed to be asynchronous, so the meshes must be also synchronized assumed to be asynchronous, so the meshes must be also synchronized
before transferring the data to the CPU. Like so: before transferring the data to the CPU. Like so:
acSynchronize(); acBoundcondStep();
acStore(mesh); acStore(mesh);
*/ */
acBoundcondStep();
acStore(mesh); acStore(mesh);
save_mesh(*mesh, i, t_step); save_mesh(*mesh, i, t_step);