From cef68fa9a3a095e1dbd9727021cdd94171a5c07d Mon Sep 17 00:00:00 2001 From: Lutz Gross <6036995+LutzGross@users.noreply.github.com> Date: Fri, 29 Dec 2023 18:17:04 +1000 Subject: [PATCH] adjustments for macOS --- SConstruct | 23 +++++----- scons/sees_kxr2xgw_options.py | 37 +++------------ scons/templates/homebrew_options.py | 70 +++++++++++++++++++++++++---- scripts/trilinos_mpi.sh | 4 +- scripts/trilinos_nompi.sh | 7 ++- site_scons/site_init.py | 4 +- 6 files changed, 87 insertions(+), 58 deletions(-) diff --git a/SConstruct b/SConstruct index a4bb7fa886..8b8b2c6c41 100644 --- a/SConstruct +++ b/SConstruct @@ -175,6 +175,7 @@ vars.AddVariables( EnumVariable('version_information', 'Instructs scons to create symlinks to the library files','0.0',allowed_values=version_info), BoolVariable('mpi4py', 'Compile with mpi4py.', False), BoolVariable('use_p4est', 'Compile with p4est.', True), + ('trilinos_dir', 'directory of trilions relative esys-escript ', 'trilinos_source15'), ('trilinos_LO', 'Manually specify the LO used by Trilinos.', ''), ('trilinos_GO', 'Manually specify the GO used by Trilinos.', '') ) @@ -340,6 +341,8 @@ sysheaderopt = '' # how to indicate that a header is a system header # env['CC'] might be a full path cxx_name=os.path.basename(env['CXX']) +# +# this should be done via import of an appropriate template: if cxx_name == 'icpc': # Intel compiler @@ -472,8 +475,7 @@ elif cxx_name == 'mpiicpc': sysheaderopt = "-isystem" if not ( env['build_trilinos'] == "False" or env['build_trilinos'] == 'never' ): - env['trilinos_prefix']=os.path.join(env['prefix'],'escript_trilinos') - print("") + env['trilinos_prefix']=os.path.join(env['prefix'],env['trilinos_dir']) if not env['cc'] == 'default ': os.environ['CC'] = env['cc'] if not env['cxx'] == 'default ': @@ -491,22 +493,23 @@ if not ( env['build_trilinos'] == "False" or env['build_trilinos'] == 'never' ): print(env['prefix']) print(env['CC']) print(env['CXX']) + SHARGS = env['prefix'] + " " + env['CC'] + " " + env['CXX'] + " " + OPENMPFLAG + " " + env['trilinos_prefix'] if env['trilinos_make'] == 'default': if env['mpi'] not in [ 'none', 'no', True]: - source=startdir+"/scripts/trilinos_mpi.sh" - dest=env['trilinos_build'] + "/trilinos_mpi.sh" - shutil.copy(source,dest) + source=startdir + "/scripts/trilinos_mpi.sh" + dest=env['trilinos_build'] + "/trilinos_mpi.sh " + shutil.copy(source, dest) print("Building (MPI) trilinos..............................") - configure="sh trilinos_mpi.sh " + env['prefix'] + " " + env['CC'] + " " + env['CXX'] + " " + OPENMPFLAG + configure="sh trilinos_mpi.sh " + SHARGS else: - source=startdir+"/scripts/trilinos_nompi.sh" + source=startdir + "/scripts/trilinos_nompi.sh" dest=env['trilinos_build'] + "/trilinos_nompi.sh" - shutil.copy(source,dest) + shutil.copy(source, dest) print("Building (no MPI) trilinos..............................") - configure="sh trilinos_nompi.sh " + env['prefix'] + " " + env['CC'] + " " + env['CXX'] + " " + OPENMPFLAG + configure="sh trilinos_nompi.sh " + SHARGS else: shutil.copy(env['trilinos_make'], "hostmake.sh") - configure="sh hostmake.sh " + env['prefix'] + " " + env['CC'] + " " + env['CXX'] + " " + OPENMPFLAG + configure="sh hostmake.sh " + SHARGS print("Running: "+configure) res=os.system(configure) diff --git a/scons/sees_kxr2xgw_options.py b/scons/sees_kxr2xgw_options.py index 50ba7007db..0b5fb8f0ae 100644 --- a/scons/sees_kxr2xgw_options.py +++ b/scons/sees_kxr2xgw_options.py @@ -19,6 +19,8 @@ # Refer to README_FIRST for usage instructions. # # install Xcode + line commands (start Xcode to accept licence conditions) + + # sudo port install clang-14 # sudo port select --set pygments py310-pygments # sudo port install scons @@ -50,39 +52,10 @@ # "-I/opt/local/include/libomp -L/opt/local/lib/libomp -fopenmp" ??? -escript_opts_version = 203 -openmp = True -#cxx_extra = '-Wimplicit-function-declaration -Wno-string-concatenation -fopenmp' # --target arm64-apple-macosx13.0.0' -# ld_extra='-v'# -L/Users/uqlgross/PycharmProjects/esys-escript.github.io/build/darwin/escriptcore/src' -boost_prefix = '/opt/local' -boost_libs = ['boost_python310-mt'] - -#cppunit_prefix = '/opt/local' -netcdf = 4 -netcdf_prefix = '/opt/local' -netcdf_libs=['netcdf_c++4', 'netcdf'] - -silo = False -silo_prefix = '/usr/local' -silo_libs = ['silo'] +from templates.homebrew_options import * -lapack = False -lapack_prefix = '/usr/local' - - -#tools_names = ['llvm-g++'] # -mp-14'] -compression_libs = ['boost_iostreams-mt'] - -umfpack = True -umfpack_prefix = '/opt/local' -build_trilinos = False - -#cxx_extra = '' -#ld_extra = '-v' -#cxx = "/opt/homebrew/bin/g++-12" -#cxx = "/usr/bin/clang++" +#cxx_extra = '-Wimplicit-function-declaration -Wno-string-concatenation -fopenmp' # --target arm64-apple-macosx13.0.0' +# ld_extra='-v'# -L/Users/uqlgross/PycharmProjects/esys-escript.github.io/build/darwin/escriptcore/src' -cxx = "/opt/local/bin/clang++-mp-14" -#cxx_extra = '-std=c++11' diff --git a/scons/templates/homebrew_options.py b/scons/templates/homebrew_options.py index 689ed63df7..febdbd5be0 100644 --- a/scons/templates/homebrew_options.py +++ b/scons/templates/homebrew_options.py @@ -18,13 +18,67 @@ # This is a template configuration file for escript on OS X homebrew. # Refer to README_FIRST for usage instructions. +import os escript_opts_version = 203 -mpi = 'OPENMPI' -mpi_prefix = '/usr/local' -mpi_libs = ['mpi_cxx', 'mpi', 'open-rte', 'open-pal'] -boost_prefix = '/usr/local' -cppunit_prefix = '/opt/local' -netcdf = True -netcdf_prefix = '/usr/local' -netcdf_libs = ['netcdf_c++', 'netcdf'] + +HOMEBREW_PREFIX = '/opt/homebrew' +import subprocess +p=subprocess.run([os.path.join(HOMEBREW_PREFIX, 'bin', 'python3'), '-V'], capture_output=True, text=True) +subversion=p.stdout.split(' ')[1].split('.')[1] +print(f'Complied for Python 3.{subversion}.') +mpi = 'no' +#mpi_prefix = '/usr/local' +#mpi_libs = ['mpi_cxx', 'mpi', 'open-rte', 'open-pal'] +import glob +GCC=glob.glob(os.path.join(HOMEBREW_PREFIX, 'bin', 'gcc-[0-9]*')) +GCC=[ os.path.join(HOMEBREW_PREFIX, 'bin', 'g++-13') ] + +assert len(GCC) > 0, "unable to find gcc compiler in "+ os.path.join(HOMEBREW_PREFIX, 'bin') +cxx = GCC[0] +cc = os.path.join(HOMEBREW_PREFIX, 'bin', 'gcc-13') +print(f"c++ compiler is {cxx}") + + +cppunit_prefix = HOMEBREW_PREFIX + +openmp = True + +boost_prefix = HOMEBREW_PREFIX +boost_libs = [f'boost_python{subversion}-mt'] +compression_libs = ['boost_iostreams-mt'] +#============================================================ +netcdf = 4 +netcdf_prefix = HOMEBREW_PREFIX +netcdf_libs=['netcdf_c++4', 'netcdf'] +#=========================================================== +silo = True +silo_prefix = HOMEBREW_PREFIX +silo_libs = ['silo'] + + +lapack =True +lapack_prefix = os.path.join(HOMEBREW_PREFIX, 'lapack' ) + + +#tools_names = ['llvm-g++'] # -mp-14'] + + +umfpack = True +umfpack_prefix = '/opt/local' +build_trilinos = True + +#cxx_extra = '' +#ld_extra = '-v' +#cxx = "/opt/homebrew/bin/g++-12" +#cxx = "/usr/bin/clang++" + +#cxx = "/opt/local/bin/clang++-mp-14" +#cxx_extra = '-std=c++11' + +# LDFLAGS = "-L/opt/homebrew/opt/lapack/lib" +# CPPFLAGS = "-I/opt/homebrew/opt/lapack/include" + + +#------- + diff --git a/scripts/trilinos_mpi.sh b/scripts/trilinos_mpi.sh index 3352b1f842..0402e01d83 100644 --- a/scripts/trilinos_mpi.sh +++ b/scripts/trilinos_mpi.sh @@ -2,7 +2,7 @@ rm -f CMakeCache.txt -TRI_INSTALL_PREFIX=$1"/escript_trilinos" +TRI_INSTALL_PREFIX=$1 cmake \ -D CMAKE_INSTALL_PREFIX=$TRI_INSTALL_PREFIX \ @@ -55,4 +55,4 @@ cmake \ -D Amesos2_ENABLE_Basker=ON \ -D Tpetra_INST_SERIAL:BOOL=ON \ -D Trilinos_ENABLE_TESTS=OFF \ - ../trilinos_source + $5 diff --git a/scripts/trilinos_nompi.sh b/scripts/trilinos_nompi.sh index 3ff6579a07..0acd2a96ed 100644 --- a/scripts/trilinos_nompi.sh +++ b/scripts/trilinos_nompi.sh @@ -5,18 +5,17 @@ rm -f CMakeCache.txt TRI_INSTALL_PREFIX=$1"/escript_trilinos" cmake \ - -D CMAKE_INSTALL_PREFIX=$TRI_INSTALL_PREFIX \ + -D CMAKE_INSTALL_PREFIX=$TRI_INSTALL_PREFIX\ -D Trilinos_ENABLE_CXX11=ON \ -D Trilinos_ENABLE_Fortran=OFF \ -D CMAKE_C_COMPILER=$2 \ -D CMAKE_CXX_COMPILER=$3 \ - -D CMAKE_CXX_FLAGS=" -Wno-unused-parameter" \ + -D CMAKE_CXX_FLAGS="-std=c++17 -Wno-unused-parameter" \ -D BUILD_SHARED_LIBS=ON \ -D TPL_ENABLE_BLAS=ON \ -D TPL_ENABLE_Boost=ON \ -D TPL_ENABLE_Cholmod=OFF \ -D TPL_ENABLE_SCALAPACK=OFF \ - -D SCALAPACK_LIBRARY_NAMES='libscalapack-openmpi.so' \ -D TPL_ENABLE_ParMETIS=OFF \ -D TPL_ENABLE_MUMPS=OFF \ -D TPL_ENABLE_SuperLU=OFF \ @@ -49,5 +48,5 @@ cmake \ -D Amesos2_ENABLE_Basker=ON \ -D Tpetra_INST_SERIAL:BOOL=ON \ -D Trilinos_ENABLE_TESTS=OFF \ - ../trilinos_source + $5 #-D TPL_Cholmod_LIBRARIES='libcholmod.so;libamd.so;libcolamd.so' \ \ No newline at end of file diff --git a/site_scons/site_init.py b/site_scons/site_init.py index 4bcd4cc442..22f9b8a4ec 100644 --- a/site_scons/site_init.py +++ b/site_scons/site_init.py @@ -230,7 +230,7 @@ def runPyUnitTest(target, source, env): if os.name=="nt": if env['usempi']: app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\ - "FINLEY_TEST_DATA,PATH %s\pythonMPIredirect.exe %s"\ + "FINLEY_TEST_DATA,PATH %s pythonMPIredirect.exe %s"\ %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn) else: app = "cd "+ pn +" & "+sys.executable + " " + sn @@ -259,7 +259,7 @@ def runPyExample(target, source, env): if os.name=="nt": if env['usempi']: app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\ - "FINLEY_TEST_DATA,PATH %s\pythonMPIredirect.exe %s"\ + "FINLEY_TEST_DATA,PATH %s pythonMPIredirect.exe %s"\ %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn) else: app = "cd "+ pn +" & "+sys.executable + " " + sn