From 6dd8708204a70cac2e13e8f366064252feef29e7 Mon Sep 17 00:00:00 2001 From: Mark Berrill Date: Tue, 10 Nov 2015 16:42:55 -0500 Subject: [PATCH] Minor performance optimizations for lbpm_color_simulator --- tests/ColorToBinary.cpp | 6 ++---- tests/lbpm_color_simulator.cpp | 5 ++++- tests/lbpm_color_simulator.h | 11 +++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/ColorToBinary.cpp b/tests/ColorToBinary.cpp index cedd6b84..9d21578d 100644 --- a/tests/ColorToBinary.cpp +++ b/tests/ColorToBinary.cpp @@ -244,14 +244,12 @@ int main(int argc, char **argv) fwrite(Dm.id,1,Nx*Ny*Nz,OUTFILE); fclose(OUTFILE); - FILE *OUTFILE; OUTFILE = fopen("Phase.dat","wb"); - fwrite(Phase,8,Nx*Ny*Nz,OUTFILE); + fwrite(Phase.get(),8,Nx*Ny*Nz,OUTFILE); fclose(OUTFILE); - FILE *OUTFILE; OUTFILE = fopen("SignDist.dat","wb"); - fwrite(SignDist,8,Nx*Ny*Nz,OUTFILE); + fwrite(SignDist.get(),8,Nx*Ny*Nz,OUTFILE); fclose(OUTFILE); diff --git a/tests/lbpm_color_simulator.cpp b/tests/lbpm_color_simulator.cpp index c84b6259..d0f6ad36 100644 --- a/tests/lbpm_color_simulator.cpp +++ b/tests/lbpm_color_simulator.cpp @@ -871,7 +871,10 @@ int main(int argc, char **argv) run_analysis(timestep,RESTART_INTERVAL,rank_info,*Averages,last_ids,last_index,last_id_map, Nx,Ny,Nz,pBC,beta,err,Phi,Pressure,Velocity,ID,f_even,f_odd,Den, LocalRestartFile,meshData,fillData,tpool,work_ids); - PROFILE_SAVE("lbpm_color_simulator",false); + + // Save the timers + if ( timestep%50==0 ) + PROFILE_SAVE("lbpm_color_simulator",1); } tpool.wait_pool_finished(); PROFILE_STOP("Loop"); diff --git a/tests/lbpm_color_simulator.h b/tests/lbpm_color_simulator.h index 80c97515..2cc5bec6 100644 --- a/tests/lbpm_color_simulator.h +++ b/tests/lbpm_color_simulator.h @@ -200,7 +200,6 @@ public: Averages.PrintComponents(timestep); PROFILE_STOP("Compute dist",1); } - PROFILE_SAVE("lbpm_color_simulator",false); ThreadPool::WorkItem::d_state = 2; // Change state to finished } private: @@ -290,16 +289,16 @@ void run_analysis( int timestep, int restart_interval, if ( (type&CopyAverages) != 0 ) { // Copy the members of Averages to the cpu (phase was copied above) // Wait + PROFILE_START("Copy-Pressure",1); + ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz); + DeviceBarrier(); + PROFILE_STOP("Copy-Pressure",1); PROFILE_START("Copy-Wait",1); tpool.wait(wait.analysis); tpool.wait(wait.vis); // Make sure we are done using analysis before modifying PROFILE_STOP("Copy-Wait",1); - PROFILE_START("Copy-Pressure",1); - ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz); - memcpy(Averages.Phase.get(),phase->get(),N*sizeof(double)); - DeviceBarrier(); - PROFILE_STOP("Copy-Pressure",1); PROFILE_START("Copy-Averages",1); + memcpy(Averages.Phase.get(),phase->get(),N*sizeof(double)); CopyToHost(Averages.Press.get(),Pressure,N*sizeof(double)); CopyToHost(Averages.Vel_x.get(),&Velocity[0],N*sizeof(double)); CopyToHost(Averages.Vel_y.get(),&Velocity[N],N*sizeof(double));