Skip to content

Commit

Permalink
adjustments for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
LutzGross committed Dec 29, 2023
1 parent 46cbcaa commit cef68fa
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 58 deletions.
23 changes: 13 additions & 10 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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.', '')
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ':
Expand All @@ -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)
Expand Down
37 changes: 5 additions & 32 deletions scons/sees_kxr2xgw_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'

70 changes: 62 additions & 8 deletions scons/templates/homebrew_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


#-------


4 changes: 2 additions & 2 deletions scripts/trilinos_mpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -55,4 +55,4 @@ cmake \
-D Amesos2_ENABLE_Basker=ON \
-D Tpetra_INST_SERIAL:BOOL=ON \
-D Trilinos_ENABLE_TESTS=OFF \
../trilinos_source
$5
7 changes: 3 additions & 4 deletions scripts/trilinos_nompi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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' \
4 changes: 2 additions & 2 deletions site_scons/site_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cef68fa

Please sign in to comment.