Skip to content

Commit

Permalink
fix: allocation of host verification vector
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-sivaraman committed Nov 5, 2023
1 parent 622988e commit 36a4e03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 7 additions & 0 deletions cuda/GridInit.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;


////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 2 additions & 5 deletions cuda/Simulation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit 36a4e03

Please sign in to comment.