diff --git a/Makefile.am b/Makefile.am index 7a9425238610c521efd08ecddc6709a84928429a..1bb3b11deee7360c65673b369c5a5733e9167807 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,10 @@ if STARPU_BUILD_STARPURM SUBDIRS += starpurm endif +if STARPU_BUILD_STARPUPY +SUBDIRS += starpupy +endif + if STARPU_BUILD_SC_HYPERVISOR SUBDIRS += sc_hypervisor endif diff --git a/configure.ac b/configure.ac index 738e6e4cbdf0d26cff74396ecfd31a6f7f27cbe3..92dd56294eac57268192a0c4ab3300abbe5f178f 100644 --- a/configure.ac +++ b/configure.ac @@ -3394,6 +3394,31 @@ AC_ARG_ENABLE(starpurm-examples, [AS_HELP_STRING([--enable-starpurm-examples], enable_starpurm_examples=$enableval, enable_starpurm_examples=no) AM_CONDITIONAL(STARPU_BUILD_STARPURM_EXAMPLES, [test x$enable_starpurm_examples = xyes]) +##################################### +# StarPUPy # +##################################### + +starpupy_support=no +AC_ARG_ENABLE(starpupy, [AS_HELP_STRING([--enable-starpupy], [enable StarPU python interface])], + enable_starpupy=$enableval, enable_starpupy=yes) +if test "x$enable_starpupy" != xno +then + starpupy_support=yes + AC_CHECK_PROGS([PYTHON], python3) + if test "$ac_cv_prog_PYTHON" == "" + then + AC_MSG_ERROR([python3 missing, cannot build StarPU python interface]) + fi + AC_SUBST(PYTHON) + AC_MSG_CHECKING(for python3 module joblib) + AC_PYTHON_MODULE(joblib,[joblib_avail=yes],[joblib_avail=no]) + AC_MSG_RESULT($joblib_avail) + if test "$joblib_avail" = "no" ; then + AC_MSG_ERROR([python3 module joblib missing, cannot build StarPU python interface]) + fi +fi +AM_CONDITIONAL(STARPU_BUILD_STARPUPY, [test x$starpupy_support = xyes]) + ########################################## # Documentation # ########################################## @@ -3555,6 +3580,10 @@ AC_CONFIG_COMMANDS([executable-scripts], [ test -e tools/starpu_paje_state_stats.R || ln -sf $ac_abs_top_srcdir/tools/starpu_paje_state_stats.R tools/starpu_paje_state_stats.R test -e tools/starpu_trace_state_stats.py || ln -sf $ac_abs_top_srcdir/tools/starpu_trace_state_stats.py tools/starpu_trace_state_stats.py chmod +x tools/starpu_trace_state_stats.py + chmod +x starpupy/tests/execute.sh + for x in starpupy/tests/starpu_py.sh starpupy/tests/starpu_py_parallel.sh; do + test -e $x || mkdir -p $(dirname $x) && ln -sf $ac_abs_top_srcdir/$x $(dirname $x) + done chmod +x julia/examples/execute.sh for x in julia/examples/check_deps/check_deps.sh julia/examples/mult/mult_starpu.sh julia/examples/mult/perf.sh julia/examples/variable/variable.sh julia/examples/task_insert_color/task_insert_color.sh julia/examples/vector_scal/vector_scal.sh julia/examples/mandelbrot/mandelbrot.sh julia/examples/callback/callback.sh julia/examples/dependency/task_dep.sh julia/examples/dependency/tag_dep.sh julia/examples/dependency/end_dep.sh julia/examples/axpy/axpy.sh julia/examples/gemm/gemm.sh julia/examples/cholesky/cholesky.sh; do test -e $x || mkdir -p $(dirname $x) && ln -sf $ac_abs_top_srcdir/$x $(dirname $x) @@ -3624,6 +3653,12 @@ AC_OUTPUT([ starpurm/src/Makefile starpurm/examples/Makefile starpurm/starpurm-1.3.pc + starpupy/src/setup.cfg + starpupy/src/setup.py + starpupy/Makefile + starpupy/src/Makefile + starpupy/tests/Makefile + starpupy/tests/execute.sh examples/Makefile examples/stencil/Makefile tests/Makefile @@ -3698,6 +3733,7 @@ AC_MSG_NOTICE([ Master-Slave MPI enabled: $use_mpi_master_slave FFT Support: $fft_support Resource Management enabled: $starpurm_support + Python Interface enabled: $starpupy_support OpenMP runtime support enabled: $enable_openmp Cluster support enabled: $enable_cluster SOCL enabled: $build_socl diff --git a/m4/libs.m4 b/m4/libs.m4 index 63b061afbf669b9e05d9f7b0fb33d2f073926590..19197d355262ba0dc5916317b1bfb4a33641592c 100644 --- a/m4/libs.m4 +++ b/m4/libs.m4 @@ -71,3 +71,15 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM( AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) ])dnl + +# AC_PYTHON_MODULE(modulename, [action-if-found], [action-if-not-found]) +# Check if the given python module is available +AC_DEFUN([AC_PYTHON_MODULE], + [ + echo "import $1" | $PYTHON - 2>/dev/null + if test $? -ne 0 ; then + $3 + else + $2 + fi +]) diff --git a/starpupy/Makefile.am b/starpupy/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..ecf1f667a334cb9e4400b9c15bfcec1a840795d1 --- /dev/null +++ b/starpupy/Makefile.am @@ -0,0 +1,21 @@ +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# + +include $(top_srcdir)/starpu-subdirtests.mk + +SUBDIRS = src +SUBDIRS += tests + diff --git a/starpupy/src/Makefile.am b/starpupy/src/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..47212e5cca5cf067aa9f4dd605b484f51560087c --- /dev/null +++ b/starpupy/src/Makefile.am @@ -0,0 +1,50 @@ +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# + +SUBDIRS = + +all: + $(MKDIR_P) starpu + for f in $(top_srcdir)/starpupy/src/starpu/*py ; do cp $$f starpu ; done + for f in $(top_srcdir)/starpupy/src/starpu/*c ; do cp $$f starpu ; done + $(PYTHON) setup.py build + +install: + @if test -d $(prefix)/lib/python* ; \ + then \ + chmod u+w $(prefix)/lib/python* ; \ + chmod u+w $(prefix)/lib/python*/site-packages ; \ + fi + $(PYTHON) setup.py install + +clean-local: + $(PYTHON) setup.py clean + rm -f starpu/*py starpu/*c + +distclean-local: + rm -rf build + +uninstall: + rm -rf $(prefix)/lib/python*/site-packages/starpu* + rm -rf $(prefix)/lib/python*/site-packages/tmp/starpu* + +EXTRA_DIST = \ + starpu/delay.py \ + starpu/__init__.py \ + starpu/intermedia.py \ + starpu/joblib.py \ + starpu/starpu_task_wrapper.c + diff --git a/starpupy/src/setup.cfg.in b/starpupy/src/setup.cfg.in new file mode 100644 index 0000000000000000000000000000000000000000..297c3375020d010daa90b78d329dce18cdcead4c --- /dev/null +++ b/starpupy/src/setup.cfg.in @@ -0,0 +1,23 @@ +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# +[build] +build-platlib=build +build-temp=build/tmp + +[install] +prefix=@prefix@ + + diff --git a/starpupy/src/setup.py.in b/starpupy/src/setup.py.in new file mode 100644 index 0000000000000000000000000000000000000000..95144ab1fc27235f8752a27b54a1283b7b04b478 --- /dev/null +++ b/starpupy/src/setup.py.in @@ -0,0 +1,35 @@ +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# +from distutils.core import setup, Extension + +starpupy = Extension('starpu.starpupy', + include_dirs = ['@STARPU_SRC_DIR@/include', '@STARPU_BUILD_DIR@/include'], + libraries = ['starpu-@STARPU_EFFECTIVE_VERSION@'], + library_dirs = ['@STARPU_BUILD_DIR@/src/.libs'], + sources = ['starpu/starpu_task_wrapper.c']) + +setup( + name = 'starpupy', + version = '0.5', + description = 'Python bindings for StarPU', + author = 'StarPU team', + author_email = 'starpu-devel@lists.gforge.inria.fr', + url = 'https://starpu.gitlabpages.inria.fr/', + license = 'GPL', + platforms = 'posix', + ext_modules = [starpupy], + packages = ['starpu'], + ) diff --git a/starpupy/src/starpu/Makefile b/starpupy/src/starpu/Makefile.old similarity index 85% rename from starpupy/src/starpu/Makefile rename to starpupy/src/starpu/Makefile.old index a65543b86f08e8ea271f3fe8a3123bb15ea93a16..0080f7d8270f376c95496e1eb2c3581d3b0abd28 100644 --- a/starpupy/src/starpu/Makefile +++ b/starpupy/src/starpu/Makefile.old @@ -6,7 +6,7 @@ LDLIBS += $(shell pkg-config --libs starpu-1.3) all: starpupy.so -starpupy.so: starpu_task_wrapper.c Makefile +starpupy.so: starpu_task_wrapper.c Makefile.old $(CC) -fPIC $(CFLAGS) $< -o $@ -shared $(CPPFLAGS) $(LDLIBS) clean: diff --git a/starpupy/tests/Makefile.am b/starpupy/tests/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..a70a8a43eec4c8c9db8a9d98ea3d7a90050758fa --- /dev/null +++ b/starpupy/tests/Makefile.am @@ -0,0 +1,30 @@ +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# +SUBDIRS = + +CLEANFILES = *.gcno *.gcda *.linkinfo + +examplebindir = $(libdir)/starpupy/examples + +TESTS = +TESTS += starpu_py.sh +TESTS += starpu_py_parallel.sh + +EXTRA_DIST = \ + starpu_py_parallel.py \ + starpu_py_parallel.sh \ + starpu_py.py \ + starpu_py.sh diff --git a/starpupy/tests/Makefile b/starpupy/tests/Makefile.old similarity index 100% rename from starpupy/tests/Makefile rename to starpupy/tests/Makefile.old diff --git a/starpupy/tests/execute.sh.in b/starpupy/tests/execute.sh.in new file mode 100755 index 0000000000000000000000000000000000000000..308b4146d9915358d0f01cba3e8b835c3f985c62 --- /dev/null +++ b/starpupy/tests/execute.sh.in @@ -0,0 +1,34 @@ +#!@REALBASH@ +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# + +set -x + +tstdir=@STARPU_SRC_DIR@/starpupy/tests + +modpath=@STARPU_BUILD_DIR@/src/.libs: +pypath=@STARPU_BUILD_DIR@/starpupy/src/build:$PYTHONPATH + +tstfile=$1 +if test ! -f $tstdir/$tstfile +then + echo "Error. File $tstdir/$tstfile not found" + exit 1 +fi +shift + +PYTHONPATH=$pypath LD_LIBRARY_PATH=$modpath @PYTHON@ $tstdir/$tstfile $* + diff --git a/starpupy/tests/starpu_py.sh b/starpupy/tests/starpu_py.sh new file mode 100755 index 0000000000000000000000000000000000000000..df367755d319a7ee0f863154965a11dc95fcf1b7 --- /dev/null +++ b/starpupy/tests/starpu_py.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# + +$(dirname $0)/execute.sh starpu_py.py + diff --git a/starpupy/tests/starpu_py_parallel.sh b/starpupy/tests/starpu_py_parallel.sh new file mode 100755 index 0000000000000000000000000000000000000000..601543c38ec454807a82dae4a624bd1ac19d2b60 --- /dev/null +++ b/starpupy/tests/starpu_py_parallel.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# StarPU --- Runtime system for heterogeneous multicore architectures. +# +# Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria +# +# StarPU is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# StarPU is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU Lesser General Public License in COPYING.LGPL for more details. +# + +$(dirname $0)/execute.sh starpu_py_parallel.py +