Skip to content

Commit

Permalink
Changed calling AoSoA by reference to by value.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Rangel committed Apr 28, 2022
1 parent d890d48 commit daaff7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/ParticleActions.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#include "ParticleActions.h"

#include <sys/time.h>
double mytime() {
timeval tv;
gettimeofday(&tv, NULL);
double time = 1.0*tv.tv_sec;
time += tv.tv_usec*1.e-6;
return time;
}

// Polynomial long range force calculation
KOKKOS_INLINE_FUNCTION
float FGridEvalPoly(float r2)
Expand Down Expand Up @@ -37,7 +46,7 @@ void ParticleActions::setParticles(Particles *P_)

// Stream
void ParticleActions::updatePos(\
Cabana::AoSoA<HACCabana::Particles::data_types, device_type> &aosoa_device,\
Cabana::AoSoA<HACCabana::Particles::data_types, device_type> aosoa_device,\
float prefactor)
{
auto position = Cabana::slice<HACCabana::Particles::Fields::Position>(aosoa_device, "position");
Expand All @@ -54,7 +63,7 @@ void ParticleActions::updatePos(\

// Kick
void ParticleActions::updateVel(\
Cabana::AoSoA<HACCabana::Particles::data_types, device_type> &aosoa_device,\
Cabana::AoSoA<HACCabana::Particles::data_types, device_type> aosoa_device,\
Cabana::LinkedCellList<device_type> cell_list,\
const float c, const float rmax2, const float rsm2)
{
Expand Down Expand Up @@ -175,9 +184,9 @@ void ParticleActions::subCycle(TimeStepper &ts, const int nsub, const float gpsc
this->updatePos(aosoa_device, prefactor*tau*0.5);

// kick
double tmp = MPI_Wtime();
double tmp = mytime();
this->updateVel(aosoa_device, cell_list, c, rmax2, rsm2);
kick_time += MPI_Wtime() - tmp;
kick_time += mytime() - tmp;

//half stream
this->updatePos(aosoa_device, prefactor*tau*0.5);
Expand Down
6 changes: 3 additions & 3 deletions src/ParticleActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "Particles.h"

// This might need to be changed for AMD and Intel GPUs. Nvidia warp size is 32.
#define VECTOR_LENGTH 32
#define VECTOR_LENGTH 64

namespace HACCabana
{
Expand All @@ -31,9 +31,9 @@ namespace HACCabana
void setParticles(Particles *P_);
void subCycle(TimeStepper &ts, const int nsub, const float gpscal, const float rmax2, const float rsm2,\
const float cm_size, const float min_pos, const float max_pos);
void updatePos(Cabana::AoSoA<HACCabana::Particles::data_types, device_type> &aosoa_device,\
void updatePos(Cabana::AoSoA<HACCabana::Particles::data_types, device_type> aosoa_device,\
float prefactor);
void updateVel(Cabana::AoSoA<HACCabana::Particles::data_types, device_type> &aosoa_device,\
void updateVel(Cabana::AoSoA<HACCabana::Particles::data_types, device_type> aosoa_device,\
Cabana::LinkedCellList<device_type> cell_list,\
const float c, const float rmax2, const float rsm2);
};
Expand Down

0 comments on commit daaff7f

Please sign in to comment.