commit
f8e6119f5d
8 changed files with 46 additions and 18 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,3 +14,4 @@
|
||||||
/sharp_oracle.inc
|
/sharp_oracle.inc
|
||||||
|
|
||||||
/python/libsharp/libsharp.c
|
/python/libsharp/libsharp.c
|
||||||
|
/python/libsharp/libsharp_mpi.c
|
||||||
|
|
15
Makefile
15
Makefile
|
@ -19,6 +19,8 @@ include libfftpack/planck.make
|
||||||
include libsharp/planck.make
|
include libsharp/planck.make
|
||||||
include docsrc/planck.make
|
include docsrc/planck.make
|
||||||
|
|
||||||
|
CYTHON_MODULES=python/libsharp/libsharp.so $(if $(MPI_CFLAGS), python/libsharp/libsharp_mpi.so)
|
||||||
|
|
||||||
$(all_lib): %: | $(LIBDIR)_mkdir
|
$(all_lib): %: | $(LIBDIR)_mkdir
|
||||||
@echo "# creating library $*"
|
@echo "# creating library $*"
|
||||||
$(ARCREATE) $@ $^
|
$(ARCREATE) $@ $^
|
||||||
|
@ -62,10 +64,15 @@ perftest: compile_all
|
||||||
genclean:
|
genclean:
|
||||||
rm libsharp/sharp_legendre.c || exit 0
|
rm libsharp/sharp_legendre.c || exit 0
|
||||||
|
|
||||||
python/libsharp/libsharp.so: python/libsharp/libsharp.pyx $(LIB_libsharp)
|
$(CYTHON_MODULES): %.so: %.pyx
|
||||||
|
ifndef PIC_CFLAGS
|
||||||
|
$(error Python extension must be built using the --enable-pic configure option.)
|
||||||
|
endif
|
||||||
cython $<
|
cython $<
|
||||||
$(CC) -fPIC `python-config --cflags` -I$(INCDIR) -o python/libsharp/libsharp.o -c python/libsharp/libsharp.c
|
$(CC) $(DEBUG_CFLAGS) $(OPENMP_CFLAGS) $(PIC_CFLAGS) `python-config --cflags` -I$(INCDIR) -o $(<:.pyx=.o) -c $(<:.pyx=.c)
|
||||||
$(CL) -shared python/libsharp/libsharp.o -L$(LIBDIR) -lsharp -lfftpack -lc_utils `python-config --libs` -o $@
|
$(CL) -shared $(<:.pyx=.o) $(OPENMP_CFLAGS) $(CYTHON_OBJ) -L$(LIBDIR) -lsharp -lfftpack -lc_utils -L`python-config --prefix`/lib `python-config --ldflags` -o $@
|
||||||
|
|
||||||
pytest: python/libsharp/libsharp.so
|
python: $(all_lib) hdrcopy $(CYTHON_MODULES)
|
||||||
|
|
||||||
|
pytest: python
|
||||||
cd python && nosetests --nocapture libsharp/tests/test_sht.py
|
cd python && nosetests --nocapture libsharp/tests/test_sht.py
|
||||||
|
|
|
@ -5,5 +5,8 @@ CL=@CC@
|
||||||
CCFLAGS_NO_C=@CCFLAGS_NO_C@
|
CCFLAGS_NO_C=@CCFLAGS_NO_C@
|
||||||
CCFLAGS=$(CCFLAGS_NO_C) -c
|
CCFLAGS=$(CCFLAGS_NO_C) -c
|
||||||
CLFLAGS=-L. -L$(LIBDIR) @LDCCFLAGS@ -lm
|
CLFLAGS=-L. -L$(LIBDIR) @LDCCFLAGS@ -lm
|
||||||
|
DEBUG_CFLAGS=@DEBUG_CFLAGS@
|
||||||
|
MPI_CFLAGS=@MPI_CFLAGS@
|
||||||
|
OPENMP_CFLAGS=@OPENMP_CFLAGS@
|
||||||
|
PIC_CFLAGS=@PIC_CFLAGS@
|
||||||
ARCREATE=@ARCREATE@
|
ARCREATE=@ARCREATE@
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
BLDROOT = $(SRCROOT)/build.$(SHARP_TARGET)
|
BLDROOT = $(SRCROOT)/build.$(SHARP_TARGET)
|
||||||
PREFIX = $(SRCROOT)/$(SHARP_TARGET)
|
PREFIX = $(SRCROOT)/$(SHARP_TARGET)
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
INCDIR = $(PREFIX)/include
|
INCDIR = $(PREFIX)/include
|
||||||
LIBDIR = $(PREFIX)/lib
|
LIBDIR = $(PREFIX)/lib
|
||||||
DOCDIR = $(SRCROOT)/doc
|
DOCDIR = $(SRCROOT)/doc
|
||||||
|
PYTHONDIR = $(SRCROOT)/python/libsharp
|
||||||
|
|
||||||
# do not use any suffix rules
|
# do not use any suffix rules
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
@ -26,6 +27,7 @@ $(BLDROOT)/%.o : $(SRCROOT)/%.cc | echo_config
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BLDROOT) $(PREFIX) $(DOCDIR) autom4te.cache/ config.log config.status
|
rm -rf $(BLDROOT) $(PREFIX) $(DOCDIR) autom4te.cache/ config.log config.status
|
||||||
|
rm -rf $(PYTHONDIR)/*.c $(PYTHONDIR)/*.o $(PYTHONDIR)/*.so
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f config/config.auto
|
rm -f config/config.auto
|
||||||
|
|
14
configure.ac
14
configure.ac
|
@ -82,20 +82,20 @@ case $system in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CCFLAGS="$CCFLAGS $OPENMP_CFLAGS"
|
|
||||||
|
|
||||||
if test $ENABLE_DEBUG = yes; then
|
if test $ENABLE_DEBUG = yes; then
|
||||||
CCFLAGS="$CCFLAGS -g"
|
DEBUG_CFLAGS="-g"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test $ENABLE_PIC = yes; then
|
if test $ENABLE_PIC = yes; then
|
||||||
CCFLAGS="$CCFLAGS -fPIC"
|
PIC_CFLAGS="-fPIC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test $ENABLE_MPI = yes; then
|
if test $ENABLE_MPI = yes; then
|
||||||
CCFLAGS="$CCFLAGS -DUSE_MPI"
|
MPI_CFLAGS="-DUSE_MPI"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CCFLAGS="$CCFLAGS $DEBUG_CFLAGS $OPENMP_CFLAGS $PIC_CFLAGS $MPI_CFLAGS"
|
||||||
|
|
||||||
CCFLAGS_NO_C="$CCFLAGS $CPPFLAGS"
|
CCFLAGS_NO_C="$CCFLAGS $CPPFLAGS"
|
||||||
|
|
||||||
LDCCFLAGS="$LDFLAGS $CCFLAGS"
|
LDCCFLAGS="$LDFLAGS $CCFLAGS"
|
||||||
|
@ -104,6 +104,10 @@ AC_SUBST(SILENT_RULE)
|
||||||
AC_SUBST(CC)
|
AC_SUBST(CC)
|
||||||
AC_SUBST(CCFLAGS_NO_C)
|
AC_SUBST(CCFLAGS_NO_C)
|
||||||
AC_SUBST(LDCCFLAGS)
|
AC_SUBST(LDCCFLAGS)
|
||||||
|
AC_SUBST(DEBUG_CFLAGS)
|
||||||
|
AC_SUBST(MPI_CFLAGS)
|
||||||
|
AC_SUBST(OPENMP_CFLAGS)
|
||||||
|
AC_SUBST(PIC_CFLAGS)
|
||||||
AC_SUBST(ARCREATE)
|
AC_SUBST(ARCREATE)
|
||||||
|
|
||||||
AC_OUTPUT(config/config.auto)
|
AC_OUTPUT(config/config.auto)
|
||||||
|
|
|
@ -27,7 +27,7 @@ cdef extern from "sharp.h":
|
||||||
void sharp_destroy_geom_info(sharp_geom_info *info)
|
void sharp_destroy_geom_info(sharp_geom_info *info)
|
||||||
|
|
||||||
ptrdiff_t sharp_map_size(sharp_geom_info *info)
|
ptrdiff_t sharp_map_size(sharp_geom_info *info)
|
||||||
ptrdiff_t sharp_alm_count(sharp_alm_info *self);
|
ptrdiff_t sharp_alm_count(sharp_alm_info *self)
|
||||||
|
|
||||||
|
|
||||||
ctypedef enum sharp_jobtype:
|
ctypedef enum sharp_jobtype:
|
||||||
|
|
|
@ -105,7 +105,8 @@ def sht(jobtype, geom_info ginfo, alm_info ainfo, double[:, :, ::1] input,
|
||||||
from mpi4py import MPI
|
from mpi4py import MPI
|
||||||
if not isinstance(comm, MPI.Comm):
|
if not isinstance(comm, MPI.Comm):
|
||||||
raise TypeError('comm must be an mpi4py communicator')
|
raise TypeError('comm must be an mpi4py communicator')
|
||||||
comm_ptr = <void*><size_t>MPI._addressof(comm)
|
from .libsharp_mpi import _addressof
|
||||||
|
comm_ptr = <void*><size_t>_addressof(comm)
|
||||||
with nogil:
|
with nogil:
|
||||||
r = sharp_execute_mpi_maybe (
|
r = sharp_execute_mpi_maybe (
|
||||||
comm_ptr, jobtype_i,
|
comm_ptr, jobtype_i,
|
||||||
|
|
10
python/libsharp/libsharp_mpi.pyx
Normal file
10
python/libsharp/libsharp_mpi.pyx
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from mpi4py.MPI cimport Comm
|
||||||
|
cdef extern from "Python.h":
|
||||||
|
object PyLong_FromVoidPtr(void*)
|
||||||
|
|
||||||
|
# For compatibility with mpi4py <= 1.3.1
|
||||||
|
# Newer versions could use the MPI._addressof function
|
||||||
|
def _addressof(comm):
|
||||||
|
cdef void *ptr = NULL
|
||||||
|
ptr = <void*>&(<Comm>comm).ob_mpi
|
||||||
|
return PyLong_FromVoidPtr(ptr)
|
Loading…
Add table
Add a link
Reference in a new issue