From 6c8a9a5cb1be19770c69129538978571a5b87dfd Mon Sep 17 00:00:00 2001 From: Tom Stitt Date: Thu, 4 Sep 2025 12:18:06 -0700 Subject: [PATCH] get a (cpu) build on toss4cray; adds a scripts dir with a script to do the build --- .gitignore | 2 ++ INSTALL.md | 22 +++++++++++++--------- pyranda/parcop/makefile | 9 ++++++--- pyranda/parcop/vendor.sh | 1 + requirements.txt | 2 +- scripts/toss_4_x86_64_ib_cray.sh | 24 ++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 13 deletions(-) create mode 100755 scripts/toss_4_x86_64_ib_cray.sh diff --git a/.gitignore b/.gitignore index 10015c9..c325b63 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ pyranda.egg-info *.o *.so *.a +pyranda/parcop/parcopmodule.c +pyranda/parcop/parcop-f2pywrappers2.f90 diff --git a/INSTALL.md b/INSTALL.md index 52a1741..8cae5be 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -46,6 +46,8 @@ You can also verify that you're in your venv by checking your `$PATH`: pip install . [--user] ``` +### + ## Installing without pip ``` @@ -53,27 +55,30 @@ pip install . [--user] python setup.py install ``` - ## Legacy Instructions - Manual Install -This process should work on any system and will allow for an arbitrary compiler to be used for +This process should work on any system and will allow for an arbitrary compiler to be used for the fortran and for the mpi4py. ### Step 1: Ensure python and numpy -#### Python- + +#### Python Though other versions of python may very well work, we recommend and support python 2.7, 3.5, and 3.6 for pyranda. -#### numpy- + +#### numpy As long as numpy is working with your version of python above, there will be no compability issues. This can be installed in a number of ways. http://www.numpy.org ### Step 2: Custom install of mpi4py This python package provides MPI bindings to python and may or may not exists on your system and python path. + #### Install mpi4py (this should work on most systems with a mpi compiler installed) ``` -wget https://bitbucket.org/mpi4py/mpi4py/downloads/mpi4py-3.0.0.tar.gz -tar xvzf mpi4py-3.0.0.tar.gz -cd mpi4py* +export version=4.1.0 +wget https://github.com/mpi4py/mpi4py/releases/download/$version/mpi4py-$version.tar.gz +tar xvzf mpi4py-$version.tar.gz +cd mpi4py-$version python setup.py build --mpicc=/where/you/have/mpicc python setup.py install --prefix=install_location_mpi4py ``` @@ -81,7 +86,7 @@ python setup.py install --prefix=install_location_mpi4py ** Add install_location_mpi4py/*/site_packages to PYTHONPATH ** ### Step 3: Pyranda build/install -A fortran compiler compatible with the mpicc used in mpi4py is used by default. +A fortran compiler compatible with the mpicc used in mpi4py is used by default. 2003 and above standards enforced and MPI libraries is required. ### Install pyranda ``` @@ -98,4 +103,3 @@ Trying navigating to pyranda/examples and running ``` python advection.py ``` - diff --git a/pyranda/parcop/makefile b/pyranda/parcop/makefile index 5749908..b238a31 100644 --- a/pyranda/parcop/makefile +++ b/pyranda/parcop/makefile @@ -34,9 +34,10 @@ intel.fflags = -fPIC -O3 -cpp # it's likely that mpiclang is using gfortran clang.fflags = $(gnu.fflags) ibm.linkflags = -qoffload -W@,-v -qsmp=omp -qinfo=omperrtrace -ibm.fflags = -fPIC -qxlf2003=polymorphic $(ibm.linkflags) -qsuffix=cpp=f90:f=f90 +ibm.fflags = -fPIC -qxlf2003=polymorphic $(ibm.linkflags) -qsuffix=cpp=f90:f=f90 ibm.lopts = -qmkshrobj pgi.fflags = -fPIC +cray.fflags = -ffree -efF -fPIC sys_type = $(call use-if,$(SYS_TYPE),$(shell uname)) python ?= $(call use-if,$($(compiler).$(sys_type).python),$(shell which python)) @@ -56,8 +57,9 @@ python.Iflags = -I$(shell $(python) -c "from sysconfig import get_config_var; p python.libdir = $(shell $(python) -c "from sysconfig import get_config_var; print(get_config_var('LIBDIR'))") python.version = $(shell $(python) -c "from sysconfig import get_config_var; print(get_config_var('VERSION'))") python.abiflag = $(shell $(python) -c "import sys; print(getattr(sys,'abiflags',''))") +# TODO: how should we do this so it's portable? #python.Lflags = -L$(python.libdir) -Wl,-R$(python.libdir) -python.Lflags = -L$(python.libdir) -Wl,-rpath $(python.libdir) +python.Lflags = -L$(python.libdir) -Wl,-rpath=$(python.libdir) python.lflags = -lpython$(python.version)$(python.abiflag) numpy.dir = $(shell $(python) -c "import numpy; print(numpy.__path__[0])") @@ -79,8 +81,9 @@ vpath %.c $(f2py.dir) %.o: %.f90 $(mpif90) $(fflags) -c $< +# TODO: is `-Wno-implicit...` portable? %.o: %.c - $(mpicc) -fPIC $(python.Iflags) $(numpy.Iflags) $(f2py.Iflags) -c $^ + $(mpicc) -fPIC $(python.Iflags) $(numpy.Iflags) $(f2py.Iflags) -Wno-implicit-function-declaration -c $^ all: parcop.so test_pent diff --git a/pyranda/parcop/vendor.sh b/pyranda/parcop/vendor.sh index 1899804..5599636 100755 --- a/pyranda/parcop/vendor.sh +++ b/pyranda/parcop/vendor.sh @@ -12,5 +12,6 @@ echo $info | grep -i "ibm" > /dev/null && { echo "ibm"; exit 0; } echo $info | grep -i "pgi" > /dev/null && { echo "pgi"; exit 0; } echo $info | grep -i "clang" > /dev/null && { echo "clang"; exit 0; } echo $info | grep -iE "gnu|gcc" > /dev/null && { echo "gnu"; exit 0; } +echo $info | grep -i "cray" > /dev/null && { echo "cray"; exit 0; } echo $default diff --git a/requirements.txt b/requirements.txt index 5e97625..5f0bf02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ matplotlib -numpy<2 +numpy scipy mpi4py diff --git a/scripts/toss_4_x86_64_ib_cray.sh b/scripts/toss_4_x86_64_ib_cray.sh new file mode 100755 index 0000000..28350ed --- /dev/null +++ b/scripts/toss_4_x86_64_ib_cray.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +test -e INSTALL.md || { echo "this must run from the root of pyranda"; exit 1; } + +version=4.1.0 +name=mpi4py-$version +mpicc=/usr/tce/packages/cray-mpich/cray-mpich-9.0.1-cce-20.0.0-magic/bin/mpicc + + +if [[ ! -d $name ]]; then + wget https://github.com/mpi4py/mpi4py/releases/download/$version/$name.tar.gz + tar xvzf $name.tar.gz +fi + +if [[ ! $(pip list | grep mpi4py) ]]; then + pushd $name + python3 setup.py build --mpicc=$mpicc + python3 setup.py install + popd +fi + +pip install -r requirements.txt + +pip install .