Skip to content

Commit

Permalink
python struct alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Jun 23, 2023
1 parent 6bdff3d commit cd10cff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
21 changes: 10 additions & 11 deletions src/integrator_whfast512.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,16 @@ void reb_integrator_whfast512_synchronize(struct reb_simulation* const r){
}
}

#else // AVX512
// Dummy functions when AVX512 is not available
void reb_integrator_whfast512_synchronize(struct reb_simulation* const r){
reb_error(r, "WHFast512 is not available. Please make sure your CPU supports AVX512 instructions, then recompile REBOUND with the AVX512 option turned on in the Makefile or setup.py file.");
}
void reb_integrator_whfast512_part1(struct reb_simulation* const r){
reb_integrator_whfast512_synchronize(r);
}
#endif // AVX512

void reb_integrator_whfast512_reset(struct reb_simulation* const r){
struct reb_simulation_integrator_whfast512* const ri_whfast512 = &(r->ri_whfast512);
if (ri_whfast512->allocated_N){
Expand All @@ -777,17 +787,6 @@ void reb_integrator_whfast512_reset(struct reb_simulation* const r){
ri_whfast512->keep_unsynchronized = 0;
ri_whfast512->recalculate_constants = 1;
}
#else // AVX512
// Dummy functions when AVX512 is not available
void reb_integrator_whfast512_reset(struct reb_simulation* const r){
}
void reb_integrator_whfast512_synchronize(struct reb_simulation* const r){
}
void reb_integrator_whfast512_part1(struct reb_simulation* const r){
reb_error(r, "WHFast512 is not available. Please make sure your CPU supports AVX512 instructions, then recompile REBOUND with the AVX512 option turned on in the Makefile or setup.py file.");
}

#endif // AVX512

void reb_integrator_whfast512_part2(struct reb_simulation* const r){
}
15 changes: 10 additions & 5 deletions src/rebound.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,34 @@ struct reb_simulation_integrator_whfast {
unsigned int recalculate_coordinates_but_not_synchronized_warning;
};

#ifdef AVX512
struct reb_particle_avx512{
#ifdef AVX512
__m512d m __attribute__ ((aligned (64)));
__m512d x __attribute__ ((aligned (64)));
__m512d y __attribute__ ((aligned (64)));
__m512d z __attribute__ ((aligned (64)));
__m512d vx __attribute__ ((aligned (64)));
__m512d vy __attribute__ ((aligned (64)));
__m512d vz __attribute__ ((aligned (64)));
};
#else // AVX512
double m[8];
double x[8];
double y[8];
double z[8];
double vx[8];
double vy[8];
double vz[8];
#endif // AVX512
};

struct reb_simulation_integrator_whfast512 {
unsigned int is_synchronized;
unsigned int keep_unsynchronized;
unsigned int allocated_N;
unsigned int gr_potential;
unsigned int recalculate_constants;
#ifdef AVX512
struct reb_particle_avx512* p_jh;
struct reb_particle p_jh0;
#endif // AVX512

};

struct reb_ode{ // defines an ODE
Expand Down

0 comments on commit cd10cff

Please sign in to comment.