Skip to content

Commit

Permalink
fixes to work on macOS + homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
LutzGross committed Jan 12, 2024
1 parent c7569fe commit d0912f6
Show file tree
Hide file tree
Showing 16 changed files with 376 additions and 444 deletions.
318 changes: 144 additions & 174 deletions SConstruct

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions cusplibrary/build/build-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,23 @@ def Environment():
env.Append(LINKFLAGS = getLINKFLAGS(env['mode'], env['backend'], env['hostspblas'], env.subst('$LINK')))

# silence unknown pragma warnings
env.Append(CFLAGS = ['-Wno-unknown-pragmas','-Wno-unused-local-typedefs'])
env.Append(CXXFLAGS = ['-Wno-unknown-pragmas','-Wno-unused-local-typedefs'])
env.AppendUnique(CFLAGS = ['-Wno-unknown-pragmas','-Wno-unused-local-typedefs'])
env.AppendUnique(CXXFLAGS = ['-Wno-unknown-pragmas','-Wno-unused-local-typedefs'])

# get CUDA paths
(cuda_exe_path,cuda_lib_path,cuda_inc_path) = get_cuda_paths()
env.Append(LIBPATH = [cuda_lib_path])
env.Append(CPPPATH = [cuda_inc_path])
env.AppendUnique(LIBPATH = [cuda_lib_path])
env.AppendUnique(CPPPATH = [cuda_inc_path])

# link against backend-specific runtimes
# XXX we shouldn't have to link against cudart unless we're using the
# cuda runtime, but cudafe inserts some dependencies when compiling .cu files
# XXX ideally this gets handled in nvcc.py if possible
env.Append(LIBS = ['cudart','stdc++','m'])
env.AppendUnique(LIBS = ['cudart','stdc++','m'])

if env['backend'] == 'ocelot':
if os.name == 'posix':
env.Append(LIBPATH = ['/usr/local/lib'])
env.AppendUnique(LIBPATH = ['/usr/local/lib'])
else:
raise ValueError, "Unknown OS. What is the Ocelot library path?"
elif env['backend'] == 'omp':
Expand All @@ -327,9 +327,9 @@ def Environment():
intel_lib += '_lp64'

(mkl_lib_path,mkl_inc_path) = get_mkl_paths()
env.Append(CPPPATH = [mkl_inc_path])
env.Append(LIBPATH = [mkl_lib_path])
env.Append(LIBS = ['mkl_core', 'mkl_gnu_thread', intel_lib])
env.AppendUnique(CPPPATH = [mkl_inc_path])
env.AppendUnique(LIBPATH = [mkl_lib_path])
env.AppendUnique(LIBS = ['mkl_core', 'mkl_gnu_thread', intel_lib])

# set thrust include path
# this needs to come before the CUDA include path appended above,
Expand Down
2 changes: 2 additions & 0 deletions escriptcore/src/DataVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ namespace DataTypes
}
break;
default:
numCopy = 0;
std::stringstream mess;
mess << "Error - (copySliceFrom) Invalid slice region rank: " << region.size();
throw DataException(mess.str());
Expand Down Expand Up @@ -418,6 +419,7 @@ namespace DataTypes
}
break;
default:
numCopy = 0;
std::stringstream mess;
mess << "Error - (copySliceFrom) Invalid slice region rank: " << region.size();
throw DataException(mess.str());
Expand Down
9 changes: 6 additions & 3 deletions escriptcore/src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ if env['netcdf']:
escriptlibs += env['netcdf_libs']
if env['trilinos']:
escriptlibs += env['trilinos_libs']


local_env.PrependUnique(LIBS = escriptlibs)


Expand All @@ -156,7 +154,7 @@ lib = local_env.SharedLibrary(module_name, sources + nonped)
lib_inst = local_env.Install(local_env['libinstall'], lib)

if IS_OSX:
env['escript_libs'] = [lib_inst] + escriptlibs
env['escript_libs'] = [lib_inst] + escriptlibs + []
else:
env['escript_libs'] = [module_name] + escriptlibs

Expand All @@ -172,9 +170,14 @@ else:
py_lib_name = module_name + 'cpp'
py_lib = py_env.PythonModule(py_lib_name, 'escriptcpp.cpp')

for k in py_env.keys():
if k.endswith('COMSTR'):
py_env[k] = "Building $TARGET"

mod_path = Dir('escriptcore', local_env['pyinstall'])
mod_inst = py_env.Install(mod_path, py_lib)

build = env.Alias('build_escript', [hdr_inst, lib, py_lib])
env.Alias('install_escript', [build, lib_inst, mod_inst])


120 changes: 60 additions & 60 deletions oxley/src/OxleyDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2423,7 +2423,7 @@ escript::Data OxleyDomain::finaliseRhs(escript::Data& rhs)
// const scalar_type one = static_cast<scalar_type> (1.0);

#ifdef OXLEY_ENABLE_DEBUG_IZ_EXTRA
#ifdef ESYS_TRILINOS_14
//#ifdef ESYS_TRILINOS_14
rhs.print();
std::cout << "f: " << std::endl;
typedef typename Tpetra::MultiVector<real_t,esys_trilinos::LO,esys_trilinos::GO,esys_trilinos::NT>::dual_view_type::host_mirror_space host_execution_space;
Expand All @@ -2448,31 +2448,31 @@ escript::Data OxleyDomain::finaliseRhs(escript::Data& rhs)
std::cout << std::endl;
std::cout << "cZ has dimensions " << cZ->getGlobalNumRows() << "x" << cZ->getGlobalNumCols() << std::endl;
std::cout << "Performing the multiplication" << std::endl;
#else
rhs.print();
std::cout << "f: " << std::endl;
auto tmpa_result_view = fc.getLocalViewHost();
auto tmpa_result_view_1d = Kokkos::subview(tmpa_result_view, Kokkos::ALL(), 0);
for(int i = 0; i < n; i++)
{
std::cout << "[" << i << ":" << tmpa_result_view_1d(i) << "]";
if(i < n-1)
std::cout << std::endl;
}
std::cout << std::endl;
std::cout << "g: " << std::endl;
auto tmpb_result_view = gc.getLocalViewHost();
auto tmpb_result_view_1d = Kokkos::subview(tmpb_result_view, Kokkos::ALL(), 0);
for(int i = 0; i < h; i++)
{
std::cout << "[" << i << ":" << tmpb_result_view_1d(i) << "]";
if(i < n-1)
std::cout << std::endl;
}
std::cout << std::endl;
std::cout << "cZ has dimensions " << cZ->getGlobalNumRows() << "x" << cZ->getGlobalNumCols() << std::endl;
std::cout << "Performing the multiplication" << std::endl;
#endif
//#else
// rhs.print();
// std::cout << "f: " << std::endl;
// auto tmpa_result_view = fc.getLocalViewHost();
// auto tmpa_result_view_1d = Kokkos::subview(tmpa_result_view, Kokkos::ALL(), 0);
// for(int i = 0; i < n; i++)
// {
// std::cout << "[" << i << ":" << tmpa_result_view_1d(i) << "]";
// if(i < n-1)
// std::cout << std::endl;
// }
// std::cout << std::endl;
// std::cout << "g: " << std::endl;
// auto tmpb_result_view = gc.getLocalViewHost();
// auto tmpb_result_view_1d = Kokkos::subview(tmpb_result_view, Kokkos::ALL(), 0);
// for(int i = 0; i < h; i++)
// {
// std::cout << "[" << i << ":" << tmpb_result_view_1d(i) << "]";
// if(i < n-1)
// std::cout << std::endl;
// }
// std::cout << std::endl;
// std::cout << "cZ has dimensions " << cZ->getGlobalNumRows() << "x" << cZ->getGlobalNumCols() << std::endl;
// std::cout << "Performing the multiplication" << std::endl;
//#endif
#endif

// auto one = Teuchos::ScalarTraits<cplx_t>::one();
Expand All @@ -2486,11 +2486,11 @@ escript::Data OxleyDomain::finaliseRhs(escript::Data& rhs)
std::cout << cZ->getGlobalNumCols() << "x" << cZ->getGlobalNumRows() << std::endl;
#endif

#ifdef ESYS_TRILINOS_14
//#ifdef ESYS_TRILINOS_14
auto result_view = fc.getLocalViewHost(Tpetra::Access::ReadOnly);
#else
auto result_view = fc.getLocalViewHost();
#endif
//#else
//auto result_view = fc.getLocalViewHost();
//#endif
auto result_view_1d = Kokkos::subview(result_view, Kokkos::ALL(), 0);

escript::FunctionSpace new_fs = escript::FunctionSpace(rhs.getFunctionSpace().getDomain(), DegreesOfFreedom);
Expand Down Expand Up @@ -2571,7 +2571,7 @@ escript::Data OxleyDomain::finaliseRhs(escript::Data& rhs)
}

#ifdef OXLEY_ENABLE_DEBUG_IZ_EXTRA
#ifdef ESYS_TRILINOS_14
//#ifdef ESYS_TRILINOS_14
rhs.print();
std::cout << "f: " << std::endl;
typedef typename Tpetra::MultiVector<real_t,esys_trilinos::LO,esys_trilinos::GO,esys_trilinos::NT>::dual_view_type::host_mirror_space host_execution_space;
Expand All @@ -2596,31 +2596,31 @@ escript::Data OxleyDomain::finaliseRhs(escript::Data& rhs)
std::cout << std::endl;
std::cout << "rZ has dimensions " << rZ->getGlobalNumRows() << "x" << rZ->getGlobalNumCols() << std::endl;
std::cout << "Performing the multiplication" << std::endl;
#else
rhs.print();
std::cout << "f: " << std::endl;
auto tmpa_result_view = fr.getLocalViewHost();
auto tmpa_result_view_1d = Kokkos::subview(tmpa_result_view, Kokkos::ALL(), 0);
for(int i = 0; i < n; i++)
{
std::cout << "[" << i << ":" << tmpa_result_view_1d(i) << "]";
if(i < n-1)
std::cout << std::endl;
}
std::cout << std::endl;
std::cout << "g: " << std::endl;
auto tmpb_result_view = gr.getLocalViewHost();
auto tmpb_result_view_1d = Kokkos::subview(tmpb_result_view, Kokkos::ALL(), 0);
for(int i = 0; i < h; i++)
{
std::cout << "[" << i << ":" << tmpb_result_view_1d(i) << "]";
if(i < n-1)
std::cout << std::endl;
}
std::cout << std::endl;
std::cout << "rZ has dimensions " << rZ->getGlobalNumRows() << "x" << rZ->getGlobalNumCols() << std::endl;
std::cout << "Performing the multiplication" << std::endl;
#endif
//#else
// rhs.print();
// std::cout << "f: " << std::endl;
// auto tmpa_result_view = fr.getLocalViewHost();
// auto tmpa_result_view_1d = Kokkos::subview(tmpa_result_view, Kokkos::ALL(), 0);
// for(int i = 0; i < n; i++)
// {
// std::cout << "[" << i << ":" << tmpa_result_view_1d(i) << "]";
// if(i < n-1)
// std::cout << std::endl;
// }
// std::cout << std::endl;
// std::cout << "g: " << std::endl;
// auto tmpb_result_view = gr.getLocalViewHost();
// auto tmpb_result_view_1d = Kokkos::subview(tmpb_result_view, Kokkos::ALL(), 0);
// for(int i = 0; i < h; i++)
// {
// std::cout << "[" << i << ":" << tmpb_result_view_1d(i) << "]";
// if(i < n-1)
// std::cout << std::endl;
// }
// std::cout << std::endl;
// std::cout << "rZ has dimensions " << rZ->getGlobalNumRows() << "x" << rZ->getGlobalNumCols() << std::endl;
// std::cout << "Performing the multiplication" << std::endl;
//#endif
#endif

const real_t alpha = Teuchos::ScalarTraits<real_t>::one();
Expand All @@ -2634,11 +2634,11 @@ escript::Data OxleyDomain::finaliseRhs(escript::Data& rhs)
std::cout << gr.description() << std::endl;
#endif

#ifdef ESYS_TRILINOS_14
//#ifdef ESYS_TRILINOS_14
auto result_view = fr.getLocalViewHost(Tpetra::Access::ReadOnly);
#else
auto result_view = fr.getLocalViewHost();
#endif
//#else
//auto result_view = fr.getLocalViewHost();
//#endif

auto result_view_1d = Kokkos::subview(result_view, Kokkos::ALL(), 0);

Expand Down
2 changes: 1 addition & 1 deletion scons/templates/README_FIRST
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ compressed_files = False
Enable reading compressed binary grids in ripley? (requires boost iostreams)
DEFAULT: True

compression_libs = 'boost_iostreams-mt'
compression_libs = ['boost_iostreams-mt']
Compression libraries to link with. DEFAULT: 'boost_iostreams'

disable_boost_numpy = False
Expand Down
57 changes: 32 additions & 25 deletions scons/templates/homebrew_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
# This is a template configuration file for escript on OS X homebrew.
# Refer to README_FIRST for usage instructions.


#If you need to have llvm first in your PATH, run:
# echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
#
#For compilers to find llvm you may need to set:
# export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
# export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

import os
escript_opts_version = 203

Expand All @@ -37,21 +45,28 @@
"Versions", f"3.{subversion}", "include", f"python3.{subversion}" )

mpi = 'no'
#mpi_prefix = '/usr/local'
#mpi_libs = ['mpi_cxx', 'mpi', 'open-rte', 'open-pal']
import glob
GCC=[ os.path.join(HOMEBREW_PREFIX, 'bin', 'g++-13') ]
cxx_extra = "-Wno-error=maybe-uninitialized"

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}")

cxx = '/opt/homebrew/opt/llvm/bin/clang++'
cxx_extra = ["-Wno-error=uninitialized",
"-Wno-error=implicit-function-declaration",
"-Wno-error=unused-but-set-variable",
"-Wno-error=return-stack-address",
"-Wno-error=inconsistent-missing-override",
"-Wno-error=unused-function"]

cc = '/opt/homebrew/opt/llvm/bin/clang'
cc_extra = ["-Wno-error=unused-but-set-variable",
"-Wno-error=deprecated-non-prototype" ]
cc_optim = ["-O3" ]

print(f"c++ compiler is {cxx}")
domains = ('finley', 'ripley','speckley')

cppunit_prefix = HOMEBREW_PREFIX

openmp = True
omp_flags = ["-fopenmp"]
omp_ldflags = ["-fopenmp"]

boost_prefix = HOMEBREW_PREFIX
boost_libs = [f'boost_python3{subversion}-mt']
Expand All @@ -63,29 +78,21 @@
#===========================================================
silo = True
silo_prefix = HOMEBREW_PREFIX
silo_libs = ['siloh5']
silo_libs = ['siloh5', 'hdf5' ]
ld_extra = ' -lz '

zlib = True
zlib_prefix = HOMEBREW_PREFIX+"/Cellar/zlib/1.3"
zlib_libs = [ 'zlib']

lapack =False
lapack_prefix = os.path.join(HOMEBREW_PREFIX, 'lapack' )

umfpack = True
umfpack_prefix = HOMEBREW_PREFIX
umfpack_prefix = [ HOMEBREW_PREFIX+"/include/suitesparse", HOMEBREW_PREFIX+"/lib/" ]

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"


#-------
ld_extra = ["-L/opt/homebrew/opt/llvm/lib", "-lz" ]


3 changes: 2 additions & 1 deletion scripts/trilinos_nompi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ cmake \
-D Trilinos_ENABLE_CXX11=ON \
-D Trilinos_ENABLE_Fortran=OFF \
-D CMAKE_C_COMPILER=$2 \
-D CMAKE_C_FLAGS=" -Wno-error=implicit-function-declaration " \
-D CMAKE_CXX_COMPILER=$3 \
-D CMAKE_CXX_FLAGS=" -Wno-unused-parameter" \
-D CMAKE_CXX_FLAGS=" -Wno-unused-parameter -Wno-error=implicit-function-declaration " \
-D BUILD_SHARED_LIBS=ON \
-D TPL_ENABLE_BLAS=ON \
-D TPL_ENABLE_Boost=ON \
Expand Down
Loading

0 comments on commit d0912f6

Please sign in to comment.