#ifndef _RIGID_BODIES_H_ #define _RIGID_BODIES_H_ #include "stdafx.h" //Global structure declarations: //Physical Particle description. struct PhysicalParticle { union { struct { float * __restrict d_fx;//position x coordinate(float) float * __restrict d_fy;//position y coordinate(float) float * __restrict d_fz;//position z coordinate(float) float * __restrict d_fm;//mass(float) float * __restrict t;// time(float) int data_length;// helper member }Pos_F_XYZ; struct { double * __restrict d_dx;// position x coordinate(double) double * __restrict d_dy;// position y coordinate(double) double * __restrict d_dz;// position z coordinate(double) double * __restrict d_dm;// mass(double) double * __restrict t;// time(double) int data_length;// helper member }Pos_D_XYZ; }; }; struct ParticleVelocity { union { struct { float * __restrict f_vx;//velocity x coordinate(float) float * __restrict f_vy;//velocity y coordinate(float) float * __restrict f_vz;//velocity z coordinate(float) float * __restrict t;// time int data_length; }Velocity_F_XYZ; struct { double * __restrict d_vx;//velocity x coordinate(double) double * __restrict d_vy;//velocity y coordinate(double) double * __restrict d_vz;//velocity z coordinate(double) double * __restrict t;// time int data_length; }Velocity_D_XYZ; }; }; /*struct S { union { struct { int a; }; struct { double b; }; }; };*/ //Function declarations: void SSETotalParticleMass_d(const double* pArray, const int size, __m128d* result); void SSETotalParticleMass_f(const float* pArray, const int size,__m128d* result); void AVXTotalParticlesMass_d( const double* __restrict pArray, const int i_Size, double* __restrict result); void AVXTotalParticleMass_f(const float* __restrict pArray, const int i_Size, float* __restrict result); void ComputePhysParticleTotalMass_d(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleTotalMass_f(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleAccVecPosX_f(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleAccVecPosX_d(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleAccVecPosY_f(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleAccVecPosY_d(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleAccVecPosZ_f(const struct PhysicalParticle *, struct PhysicalParticle *); void ComputePhysParticleAccVecPosZ_d(const struct PhysicalParticle *, struct PhysicalParticle* ); struct PhysicalParticle *InitializePhysParticle_d( const int ); struct PhysicalParticle *InitializePhysParticle_f( const int ); //--------------------------------------------------------------------------------------------------// // CopyPhysicalParticleState_d(struct PhysicalParticle *, const PhysicalParticle *) // Arguments: pointer to struct PhysicalParticle , pointer to struct PhysicalParticle. // Returns: nothing void CopyPhysicalParticleState_d(struct PhysicalParticle *, const PhysicalParticle *); void CopyPhysicalParticleState_f(struct PhysicalParticle *, const PhysicalParticle *); void CopyPhysicalParticleState_df(struct PhysicalParticle *, const PhysicalParticle *, const int); //struct PhysicalParticle *SetPhysicalParticlePosition_d(struct PhysicalParticle *, double(*)(double), double, double(*)(double), double, double(*)(double), double //, double, double,double, double, double ); struct PhysicalParticle *SetPhysParticlePos_d(struct PhysicalParticle *, __m256d(*)(__m256d), __m256d(*)(__m256d), __m256d(*)(__m256d), __m256d m, double step); struct PhysicalParticle *SetPhysParticlePos_f(struct PhysicalParticle *, __m256(*)(__m256), __m256(*)(__m256), __m256(*)(__m256), __m256 , double ); void PhysParticleCopyFromArray_d(struct PhysicalParticle *, const double * __restrict, const double * __restrict, const double * __restrict, const double * __restrict, const int ); void PhysParticleCopyFromArray_f(struct PhysicalParticle *, const float * __restrict, const float * __restrict, const float * __restrict, const float * __restrict, const int); void PhysicalParticleVelocity(struct ParticleVelocity *, struct PhysicalParticle *, __m256d(*)(__m256d), __m256d); void PhysicalParticleVelocity_flt(struct ParticleVelocity *, struct PhysicalParticle *, __m256(*)(__m256), __m256); void PhysicalParticleAcceleration_d(struct ParticleVelocity *, struct ParticleVelocity *, __m256d(*)(__m256d), __m256d); void PhysicalParticleAcceleration_f(struct ParticleVelocity *, struct ParticleVelocity *, __m256(*)(__m256), __m256); //Ridders' derivative. double ridder_derivative_dbl(double(*func) (double), double, double, double *); float ridder_derivative_flt(float(*func) (float), float, float, float *); //Ridder's AVX derivative. void ridder_derivative_avx_dbl(__m256d (*pFunc) (__m256d), __m256d, __m256d, __m256d *); //Naive derivative implementation. double derivative_dbl(double (*pFunc) (double), double, double); float derivative_flt(float(*pFunc) (float), float, float); __m256 avx_derivative_flt(__m256 (*pFunc) (__m256), __m256, __m256); __m256d avx_derivative_dbl(__m256d (*pFunc) (__m256d), __m256d, __m256d); //For debugging only. inline __m256 vec_sin_f(__m256 arg) { __m256 ret_val = _mm256_setzero_ps(); return _mm256_sqrt_ps(arg); } //For debugging only. inline __m256d vec_sin_d(__m256d arg) { __m256d ret_val = _mm256_setzero_pd(); return _mm256_sqrt_pd(arg); } #endif /*RIGID_BODIES_H*/