From 8307070ca25c6f69a292337f758309afdfea16ee Mon Sep 17 00:00:00 2001 From: Ryan Pepper Date: Fri, 10 May 2019 12:00:17 +0100 Subject: [PATCH] Tweak some of the setup --- Makefile | 4 +-- native/Makefile | 32 ------------------- native/include/c_demagcoef.h | 49 +++-------------------------- native/src/c_demag_oommf.cpp | 60 ++++++++++++++++++++++++++++++------ setup.py | 3 +- 5 files changed, 58 insertions(+), 90 deletions(-) delete mode 100644 native/Makefile diff --git a/Makefile b/Makefile index bad03019..1f20b315 100644 --- a/Makefile +++ b/Makefile @@ -43,13 +43,13 @@ build: $(LIBRARY) CC=${CC} CXX=${CXX} CPPFLAGS="${CPPFLAGS}" ${PYTHON} setup.py build_ext --inplace - - clean: rm -rf ${EXTENSIONS_DIR}/* touch ${EXTENSIONS_DIR}/__init__.py rm -rf build rm -rf $(OBJECTS) $(TARGET) *.dSYM + find fidimag/ "*.cpp" -exec echo {} \; + docker: docker build -t fidimag -f ./docker/travis/Dockerfile . diff --git a/native/Makefile b/native/Makefile deleted file mode 100644 index f1b128a7..00000000 --- a/native/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -.PHONY : clean - -FFTW_INC=../local/include -FFTW_LIB=../local/lib - -SUNDIALS_INC=../local/include -SUNDIALS_LIB=../local/lib - -CPPFLAGS = -fPIC -g -Iinclude/ \ - -I${FFTW_INC} -L${FFTW_LIB} \ - -I${SUNDIALS_INC} -L${SUNDIALS_LIB} \ - -lm \ - -lfftw3_omp -lfftw3 \ - -lsundials_cvodes -lsundials_nvecserial -lsundials_nvecopenmp \ - -lblas -llapack \ - -fopenmp - -LDFLAGS = -shared - -SOURCES = $(shell echo src/*.cpp) - -OBJECTS = $(SOURCES:.cpp=.o) - -TARGET = libfidimag.so - -all: $(TARGET) - -clean: - rm -rf $(OBJECTS) $(TARGET) *.dSYM - -$(TARGET) : $(OBJECTS) - $(CXX) $(CPPFLAGS) $(OBJECTS) -o $@ $(LDFLAGS) diff --git a/native/include/c_demagcoef.h b/native/include/c_demagcoef.h index 94e34483..60b21801 100644 --- a/native/include/c_demagcoef.h +++ b/native/include/c_demagcoef.h @@ -1,9 +1,9 @@ /* This file demag_oommf.h is taken from the OOMMF project (oommf/app/oxs/ext/demagcoef.h downloaded from http://math.nist.gov/oommf/dist/oommf12a5rc_20120928.tar.gz) -with slightly modifications (change OC_REALWIDE to double) +with slightly modifications (change OC_REALWIDE to double) and distributed under this license shown below. */ -/* License +/* License OOMMF - Object Oriented MicroMagnetic Framework @@ -130,49 +130,10 @@ double DemagNyzAsymptotic(double x, double y, double z, double dx,double dy,double dz); - //////////////////////////////////////////////////////////////////////////// // Routines to do accurate summation -static int AS_Compare(const void* px,const void* py) -{ - // Comparison based on absolute values - double x=fabs(*((const double *)px)); - double y=fabs(*((const double *)py)); - if(xy) return -1; - return 0; -} - - -static double -AccurateSum(int n,double *arr) -{ - // Order by decreasing magnitude - qsort(arr,n,sizeof(double),AS_Compare); - - // Add up using doubly compensated summation. If necessary, mark - // variables these "volatile" to protect against problems arising - // from extra precision. Also, don't expect the compiler to respect - // order with respect to parentheses at high levels of optimization, - // i.e., write "u=x; u-=(y-corr)" as opposed to "u=x-(y-corr)". - - double sum,corr,y,u,t,v,z,x,tmp; - - sum=arr[0]; corr=0; - for(int i=1;iy) return -1; + return 0; +} + + +double AccurateSum(int n,double *arr) { + // Order by decreasing magnitude + qsort(arr,n,sizeof(double), AS_Compare); + + // Add up using doubly compensated summation. If necessary, mark + // variables these "volatile" to protect against problems arising + // from extra precision. Also, don't expect the compiler to respect + // order with respect to parentheses at high levels of optimization, + // i.e., write "u=x; u-=(y-corr)" as opposed to "u=x-(y-corr)". + + double sum,corr,y,u,t,v,z,x,tmp; + + sum=arr[0]; corr=0; + for(int i=1;i 0. double result_sign=1.0; - if(x<0.0) - result_sign *= -1.0; - if(y<0.0) + if(x<0.0) + result_sign *= -1.0; + if(y<0.0) result_sign *= -1.0; x=fabs(x); y=fabs(y); z=fabs(z); // This function is even in z and /// odd in x and y. The fabs()'s simplify special case handling. double xsq=x*x,ysq=y*y,zsq=z*z; double R=xsq+ysq+zsq; - if(R<=0.0) + if(R<=0.0) return 0.0; else R=sqrt(R); @@ -424,7 +464,7 @@ double DemagNxxAsymptotic(double x, double y, double z, term5 *= 0.25; } - double term7 = 0.0; + double term7 = 0.0; { double b1 = 32*dx4 - 40*dx2dy2 - 40*dx2dz2 + 12*dy4 + 10*dy2dz2 + 12*dz4; double b2 = -240*dx4 + 580*dx2dy2 + 20*dx2dz2 - 202*dy4 - 75*dy2dz2 + 22*dz4; diff --git a/setup.py b/setup.py index 55ff5cb7..df09ba49 100644 --- a/setup.py +++ b/setup.py @@ -21,8 +21,7 @@ lib_paths = [LIB_DIR, os.path.join(MODULE_DIR, 'native')] com_inc = [numpy.get_include(), INCLUDE_DIR, os.path.join(MODULE_DIR, 'native', 'include')] com_libs = ['fidimag'] -com_args = ['-fopenmp'] - +com_args = [] if 'SUNDIALS_INC' in os.environ: com_inc.append(os.environ['SUNDIALS_INC'])