diff --git a/cuda/GridInit.cu b/cuda/GridInit.cu index 13c62db..6eb4d53 100644 --- a/cuda/GridInit.cu +++ b/cuda/GridInit.cu @@ -100,6 +100,8 @@ SimulationData grid_init_do_not_profile( Inputs in, int mype ) { // Structure to hold all allocated simuluation data arrays SimulationData SD; + + // Keep track of how much data we're allocating size_t nbytes = 0; @@ -152,6 +154,11 @@ SimulationData grid_init_do_not_profile( Inputs in, int mype ) printf("E%d = %lf\n", j, SD.nuclide_grid[i * in.n_gridpoints + j].energy); } */ + + // Allocate Verification Array + size_t sz = in.lookups * sizeof(unsigned long); + SD.verification = (unsigned long *) malloc(sz); + nbytes += sz; //////////////////////////////////////////////////////////////////// diff --git a/cuda/Simulation.cu b/cuda/Simulation.cu index 8be81ab..c7b8a73 100644 --- a/cuda/Simulation.cu +++ b/cuda/Simulation.cu @@ -14,9 +14,6 @@ unsigned long long run_event_based_simulation_baseline(Inputs in, SimulationData SD, int mype) { - size_t sz = in.lookups * sizeof(unsigned long); - unsigned long * v = (unsigned long *) malloc(sz); - // Move Data to GPU SimulationData GSD = move_simulation_data_to_device(in, mype, SD); @@ -36,11 +33,11 @@ unsigned long long run_event_based_simulation_baseline(Inputs in, SimulationData // Reduce Verification Results //////////////////////////////////////////////////////////////////////////////// if( mype == 0) printf("Reducing verification results...\n"); - gpuErrchk(cudaMemcpy(v, GSD.verification, sz, cudaMemcpyDeviceToHost) ); + gpuErrchk(cudaMemcpy(SD.verification, GSD.verification, in.lookups * sizeof(unsigned long), cudaMemcpyDeviceToHost) ); unsigned long verification_scalar = 0; for( int i =0; i < in.lookups; i++ ) - verification_scalar += v[i]; + verification_scalar += SD.verification[i]; release_device_memory(GSD);