Skip to content

Commit

Permalink
Enabled USE_AVX in the theory.options and common.options files. Howev…
Browse files Browse the repository at this point in the history
…er, protected the user in case the compiler doesn't have AVX capability. I think if the compiler has AVX but the cpu doesn't, then the code will compile fine but crash at runtime
  • Loading branch information
manodeep committed Feb 5, 2016
1 parent 41fa3e4 commit 06d1f31
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion mocks.options
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ OPT += -DLINK_IN_RA

#### Code specs for both data Correlation Functions
OPT += -DDOUBLE_PREC
#OPT += -DUSE_AVX
OPT += -DUSE_AVX
OPT += -DUSE_OMP
#OPT += -DFAST_DIVIDE ##replaces divide in DDrppi with approximate divides. If you really must get that extra ~20% performance boost
2 changes: 1 addition & 1 deletion theory.options
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OPT = -DPERIODIC

#### Code specs for both theory and data Correlation Functions
#OPT += -DDOUBLE_PREC
#OPT += -DUSE_AVX
OPT += -DUSE_AVX
OPT += -DUSE_OMP


2 changes: 1 addition & 1 deletion xi_mocks/DDrppi/DDrppi_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
6 changes: 3 additions & 3 deletions xi_mocks/DDrppi/countpairs_rp_pi_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "cosmology_params.h"
#include "set_cosmo_dist.h"

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -241,7 +241,7 @@ results_countpairs_mocks * countpairs_mocks(const int64_t ND1, DOUBLE *phi1, DOU
rupp_sqr[i] = rupp[i]*rupp[i];
}

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rupp_sqr[nrpbin];
AVX_FLOATS m_kbin[nrpbin];
for(int i=0;i<nrpbin;i++) {
Expand Down Expand Up @@ -413,7 +413,7 @@ results_countpairs_mocks * countpairs_mocks(const int64_t ND1, DOUBLE *phi1, DOU
/* const DOUBLE TWO=2.0; */
/* const DOUBLE sqr_d1 = d1[i]*d1[i]; */

#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))

DOUBLE *localx2 = x2;
DOUBLE *localy2 = y2;
Expand Down
2 changes: 1 addition & 1 deletion xi_mocks/tests/tests_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#if !(defined(__INTEL_COMPILER)) && defined(USE_AVX)
#warning Test suite for mocks will be slow without Intel ICC while USE_AVX is set.
#warning Test suite for mocks are faster with Intel compiler, icc, AVX libraries.
#endif

#ifndef SILENT
Expand Down
12 changes: 6 additions & 6 deletions xi_mocks/vpf/countspheres_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "set_cosmo_dist.h"//cosmological distance calculations
#include "cosmology_params.h"//init_cosmology

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -256,7 +256,7 @@ results_countspheres_mocks * countspheres_mocks(const int64_t Ngal, DOUBLE *xgal
const DOUBLE rstep = rmax/(DOUBLE)nbin ;
const DOUBLE inv_rstep = ((DOUBLE) 1.0)/rstep;

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rupp_sqr[nbin];
AVX_FLOATS m_rmax_sqr = AVX_SET_FLOAT(rmax_sqr);
for(int k=0;k<nbin;k++) {
Expand Down Expand Up @@ -316,7 +316,7 @@ results_countspheres_mocks * countspheres_mocks(const int64_t Ngal, DOUBLE *xgal
const int max_ix = ix + bin_refine_factor > ngrid-1 ? ngrid-1:ix + bin_refine_factor;
for(int iix=min_ix;iix<=max_ix;iix++) {
const DOUBLE newxpos = xcen;
#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
const AVX_FLOATS m_newxpos = AVX_SET_FLOAT(newxpos);
#endif

Expand All @@ -325,7 +325,7 @@ results_countspheres_mocks * countspheres_mocks(const int64_t Ngal, DOUBLE *xgal

for(int iiy=min_iy;iiy<=max_iy;iiy++) {
const DOUBLE newypos = ycen;
#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
const AVX_FLOATS m_newypos = AVX_SET_FLOAT(newypos);
#endif

Expand All @@ -334,7 +334,7 @@ results_countspheres_mocks * countspheres_mocks(const int64_t Ngal, DOUBLE *xgal

for(int iiz=min_iz;iiz<=max_iz;iiz++) {
const DOUBLE newzpos = zcen;
#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
const AVX_FLOATS m_newzpos = AVX_SET_FLOAT(newzpos);
#endif
const int index=iix*ngrid*ngrid + iiy*ngrid + iiz;
Expand All @@ -344,7 +344,7 @@ results_countspheres_mocks * countspheres_mocks(const int64_t Ngal, DOUBLE *xgal
DOUBLE *z2 = cellstruct->pos + 2*NVEC;
int ipart;
for(ipart=0;ipart<=(cellstruct->nelements-NVEC);ipart+=NVEC) {
#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))
int ibin[NVEC];
#if __INTEL_COMPILER
#pragma simd vectorlengthfor(DOUBLE)
Expand Down
2 changes: 1 addition & 1 deletion xi_mocks/wtheta/DDtheta_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
6 changes: 3 additions & 3 deletions xi_mocks/wtheta/countpairs_theta_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "progressbar.h" //for the progressbar


#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -181,7 +181,7 @@ results_countpairs_theta * countpairs_theta_mocks(const int64_t ND1, DOUBLE *phi
#endif
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_costheta_upp[nthetabin] ;
for(int i=0;i<nthetabin;i++) {
/* fprintf(stderr," i = %d theta_upp[i-1] = %lf cos(theta_upp[i-1] = %lf cos(theta_upp[i]) = %lf \n",i, theta_upp[i-1],COSD(theta_upp[i-1]),COSD(theta_upp[i])); */
Expand Down Expand Up @@ -399,7 +399,7 @@ results_countpairs_theta * countpairs_theta_mocks(const int64_t ND1, DOUBLE *phi
/*---Loop-over-Data2-particles--------------------*/
int j;
for(j=0;j <=(Nloop-NVEC);j+=NVEC) {
#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))
DOUBLE costheta[NVEC];
int thetabin[NVEC];
#ifdef OUTPUT_THETAAVG
Expand Down
6 changes: 3 additions & 3 deletions xi_theory/vpf/countspheres.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "utils.h" //all of the utilities
#include "progressbar.h" //for the progressbar

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -65,7 +65,7 @@ results_countspheres * countspheres(const int64_t np, const DOUBLE * restrict X,
const DOUBLE inv_rstep = ((DOUBLE) 1.0)/rstep;
/* const DOUBLE inv_rcube = ((DOUBLE) 1.0)/rcube; */
const DOUBLE rmax_sqr = rmax*rmax;
#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rmax_sqr = AVX_SET_FLOAT(rmax_sqr);
AVX_FLOATS m_rupp_sqr[nbin];
for(int k=0;k<nbin;k++) {
Expand Down Expand Up @@ -200,7 +200,7 @@ results_countspheres * countspheres(const int64_t np, const DOUBLE * restrict X,
DOUBLE *x2 = first->pos;
DOUBLE *y2 = first->pos + NVEC;
DOUBLE *z2 = first->pos + 2*NVEC;
#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))

for(int64_t j=0;j<first->nelements;j+=NVEC) {
int block_size=first->nelements - j;
Expand Down
2 changes: 1 addition & 1 deletion xi_theory/vpf/vpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
6 changes: 3 additions & 3 deletions xi_theory/wp/countpairs_wp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "sglib.h"

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -136,7 +136,7 @@ results_countpairs_wp *countpairs_wp(const int64_t ND1, DOUBLE * restrict X1, DO
}


#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rupp_sqr[nbin];
for(int i=0;i<nbin;i++) {
m_rupp_sqr[i] = AVX_SET_FLOAT(rupp_sqr[i]);
Expand Down Expand Up @@ -270,7 +270,7 @@ results_countpairs_wp *countpairs_wp(const int64_t ND1, DOUBLE * restrict X1, DO
const DOUBLE y1pos = y1[ii] + off_ywrap;
const DOUBLE z1pos = z1[ii] + off_zwrap;

#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))
DOUBLE *localx2 = x2;
DOUBLE *localy2 = y2;
DOUBLE *localz2 = z2;
Expand Down
2 changes: 1 addition & 1 deletion xi_theory/wp/wp.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
6 changes: 3 additions & 3 deletions xi_theory/xi/countpairs_xi.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "progressbar.h" //for the progressbar
#include "sglib.h"

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -144,7 +144,7 @@ results_countpairs_xi *countpairs_xi(const int64_t ND1, DOUBLE * restrict X1, DO
const DOUBLE sqr_rpmax=rupp_sqr[nrpbin-1];
const DOUBLE sqr_rpmin=rupp_sqr[0];

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rupp_sqr[nrpbin];
for(int i=0;i<nrpbin;i++) {
m_rupp_sqr[i] = AVX_SET_FLOAT(rupp_sqr[i]);
Expand Down Expand Up @@ -247,7 +247,7 @@ results_countpairs_xi *countpairs_xi(const int64_t ND1, DOUBLE * restrict X1, DO
const DOUBLE y1pos=y1[ii] + off_ywrap;;
const DOUBLE z1pos=z1[ii] + off_zwrap;

#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))
DOUBLE *localx2 = x2;
DOUBLE *localy2 = y2;
DOUBLE *localz2 = z2;
Expand Down
2 changes: 1 addition & 1 deletion xi_theory/xi/xi.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
2 changes: 1 addition & 1 deletion xi_theory/xi_of_r/DD.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
6 changes: 3 additions & 3 deletions xi_theory/xi_of_r/countpairs.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "utils.h" //all of the utilities
#include "progressbar.h" //for the progressbar

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -165,7 +165,7 @@ results_countpairs * countpairs(const int64_t ND1, const DOUBLE * const X1, cons
DOUBLE sqr_rpmax=rupp_sqr[nrpbin-1];
DOUBLE sqr_rpmin=rupp_sqr[0];

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rupp_sqr[nrpbin];
for(int i=0;i<nrpbin;i++) {
m_rupp_sqr[i] = AVX_SET_FLOAT(rupp_sqr[i]);
Expand Down Expand Up @@ -297,7 +297,7 @@ results_countpairs * countpairs(const int64_t ND1, const DOUBLE * const X1, cons
#endif


#ifndef USE_AVX
#if !(defined(USE_AVX) && defined(__AVX__))

DOUBLE *localx2 = x2;
DOUBLE *localy2 = y2;
Expand Down
2 changes: 1 addition & 1 deletion xi_theory/xi_rp_pi/DDrppi.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void Printhelp(void)
fprintf(stderr,"Precision = float\n");
#endif

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
fprintf(stderr,"Use AVX = True\n");
#else
fprintf(stderr,"Use AVX = False\n");
Expand Down
6 changes: 3 additions & 3 deletions xi_theory/xi_rp_pi/countpairs_rp_pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "utils.h" //all of the utilities
#include "progressbar.h" //for the progressbar

#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
#include "avx_calls.h"
#endif

Expand Down Expand Up @@ -160,7 +160,7 @@ results_countpairs_rp_pi * countpairs_rp_pi(const int64_t ND1, const DOUBLE *X1,
#endif


#ifdef USE_AVX
#if defined(USE_AVX) && defined(__AVX__)
AVX_FLOATS m_rupp_sqr[nrpbin];
AVX_FLOATS m_kbin[nrpbin];
for(int i=0;i<nrpbin;i++) {
Expand Down Expand Up @@ -286,7 +286,7 @@ results_countpairs_rp_pi * countpairs_rp_pi(const int64_t ND1, const DOUBLE *X1,
#endif


#ifndef USE_AVX //Beginning of NO AVX section
#if !(defined(USE_AVX) && defined(__AVX__)) //Beginning of NO AVX section
DOUBLE *localx2=x2;
DOUBLE *localy2=y2;
DOUBLE *localz2=z2;
Expand Down

0 comments on commit 06d1f31

Please sign in to comment.