Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] PyTrilinos2: Switch to "primary tested" #13708

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PackagesList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TRIBITS_REPOSITORY_DEFINE_PACKAGES(
Panzer packages/panzer PT
CTrilinos packages/CTrilinos ST # Switched to ST to speed up checkin testing
PyTrilinos packages/PyTrilinos ST
PyTrilinos2 packages/PyTrilinos2 EX
PyTrilinos2 packages/PyTrilinos2 PT
WebTrilinos packages/WebTrilinos EX # Should be ST
NewPackage packages/new_package EX # Should be ST
Optika packages/optika EX
Expand Down
3 changes: 3 additions & 0 deletions TPLsList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ TRIBITS_REPOSITORY_DEFINE_TPLS(
SARMA "cmake/TPLs/" EX
CDT "cmake/TPLs/" EX
mpi_advance "cmake/TPLs/" EX
LLVM "cmake/TPLs/" EX
Binder "cmake/TPLs/" EX
pybind11 "cmake/TPLs/" EX
)

# NOTES:
Expand Down
8 changes: 8 additions & 0 deletions cmake/TPLs/FindTPLBinder.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SET(POTENTIAL_BINDER_BIN "$ENV{BINDER_ROOT}/bin")

FIND_PROGRAM(BINDER_EXECUTABLE REQUIRED
NAMES binder
HINTS ${POTENTIAL_BINDER_BIN} ${BINDER_PATH}
)

message(STATUS "Found Binder executable: ${BINDER_EXECUTABLE}")
7 changes: 7 additions & 0 deletions cmake/TPLs/FindTPLLLVM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
find_package(LLVM CONFIG)

IF (NOT LLVM_FOUND)
MESSAGE(FATAL_ERROR "LLVM was not found!")
ENDIF()

message(STATUS "Using LLVM includes in: ${LLVM_INCLUDE_DIRS}")
6 changes: 6 additions & 0 deletions cmake/TPLs/FindTPLpybind11.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11)

IF (NOT pybind11_FOUND)
MESSAGE(FATAL_ERROR "pybind11 was not found!")
ENDIF()
85 changes: 31 additions & 54 deletions packages/PyTrilinos2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# Set the package name
TRIBITS_PACKAGE(PyTrilinos2 DISABLE_STRONG_WARNINGS)

ASSERT_DEFINED(
BUILD_SHARED_LIBS
Python3_EXECUTABLE
Python3_VERSION_MAJOR
Python3_VERSION_MINOR
${PACKAGE_NAME}_ENABLE_MueLu
Tpetra_INST_OPENMP
BINDER_EXECUTABLE
)

###################################################################################################

IF(NOT BUILD_SHARED_LIBS)
MESSAGE(FATAL_ERROR "PyTrilinos2 can only be built with shared libraries. Building of shared libraries is currently set to OFF. To enable shared libraries please set the cache variable \"BUILD_SHARED_LIBS\" to ON")
MESSAGE(WARNING "PyTrilinos2 can be built with static linking, but might require building with position-independent code. If you encounter build errors please add \"-fPIC\" to CMAKE_C_FLAGS, CMAKE_C_FLAGS and CMAKE_Fortran_FLAGS.")
ENDIF()

# Set the package version number
Expand All @@ -28,17 +40,9 @@ TRIBITS_ADD_OPTION_AND_DEFINE(PyTrilinos2_BINDER_VERBOSE
"Increase the verbosity of binder."
OFF )

SET(PyTrilinos2_BINDER_NUM_FILES "150" CACHE STRING "Maxinum number of generated files by binder.")
###################################################################################################

MESSAGE("-- Python3_EXECUTABLE:")
IF(NOT DEFINED ${Python3_EXECUTABLE})
find_program(Python3_EXECUTABLE
NAMES python3 python
)
MESSAGE(" -- CMake has set: Python3_EXECUTABLE = ${Python3_EXECUTABLE}")
ELSE()
MESSAGE(" -- User has set: Python3_EXECUTABLE = ${Python3_EXECUTABLE}")
ENDIF()
SET(PyTrilinos2_BINDER_NUM_FILES "150" CACHE STRING "Maxinum number of generated files by binder.")

function(get_all_include_dirs LIBRARY_NAME all_include_dirs all_visited_libs)
if (TARGET ${LIBRARY_NAME})
Expand All @@ -64,15 +68,6 @@ endfunction()
FILE(GLOB PyTrilinos2PyFiles ${CMAKE_CURRENT_SOURCE_DIR}/python/*.py)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PyTrilinos2)

MESSAGE("-- PyTrilinos2_BINDER_EXECUTABLE:")
IF(NOT DEFINED PyTrilinos2_BINDER_EXECUTABLE)
find_program(PyTrilinos2_BINDER_EXECUTABLE
NAMES binder
)
MESSAGE(" -- CMake has set: PyTrilinos2_BINDER_EXECUTABLE = ${PyTrilinos2_BINDER_EXECUTABLE}")
ELSE()
MESSAGE(" -- User has set: PyTrilinos2_BINDER_EXECUTABLE = ${PyTrilinos2_BINDER_EXECUTABLE}")
ENDIF()
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/include_tmp)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include_tmp)
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/binder)
Expand Down Expand Up @@ -145,6 +140,7 @@ file(WRITE ${all_include_list} ${CONTENTS})
set(eti_files_with_dir "")
set(eti_files_without_dir "")

###################################################################################################
# Get ETI files for Tpetra:
file(GLOB tpetra_ETI_files
"${CMAKE_CURRENT_BINARY_DIR}/../tpetra/core/src/*.cpp"
Expand Down Expand Up @@ -209,10 +205,6 @@ add_custom_command(
add_custom_target(generate_include_name DEPENDS ${binder_include_name})
add_dependencies(generate_include_name generate_ETI_name)

ASSERT_DEFINED(
${PACKAGE_NAME}_ENABLE_MueLu
)

set(BINDER_OPTIONS "")
list(APPEND BINDER_OPTIONS --root-module PyTrilinos2)
list(APPEND BINDER_OPTIONS --prefix ${CMAKE_CURRENT_BINARY_DIR}/binder)
Expand Down Expand Up @@ -258,18 +250,24 @@ list(APPEND BINDER_OPTIONS -I${CMAKE_CURRENT_BINARY_DIR}/include_tmp/experimenta
list(APPEND BINDER_OPTIONS -I${CMAKE_CURRENT_BINARY_DIR}/src)
list(APPEND BINDER_OPTIONS -I${CMAKE_CURRENT_SOURCE_DIR}/src)
IF(NOT DEFINED PyTrilinos2_BINDER_GCC_TOOLCHAIN)
list(APPEND BINDER_OPTIONS -I${PyTrilinos2_BINDER_clang_include_dirs})
list(APPEND BINDER_OPTIONS -iwithsysroot${PyTrilinos2_BINDER_LibClang_include_dir})
list(APPEND BINDER_OPTIONS -I${LLVM_INCLUDE_DIRS})
list(APPEND BINDER_OPTIONS -iwithsysroot${LLVM_INSTALL_PREFIX}/lib/clang/${LLVM_VERSION}/include)
ELSE()
list(APPEND BINDER_OPTIONS --gcc-toolchain=${PyTrilinos2_BINDER_GCC_TOOLCHAIN})
ENDIF()
IF (Tpetra_INST_OPENMP)
list(APPEND BINDER_OPTIONS "-fopenmp")
ENDIF()
IF (NOT "${TPL_MPI_INCLUDE_DIRS}" MATCHES "")
list(APPEND BINDER_OPTIONS "-I${TPL_MPI_INCLUDE_DIRS}")
ENDIF()
list(APPEND BINDER_OPTIONS -DNDEBUG)

message("BINDER_OPTIONS='${BINDER_OPTIONS}'")

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/binder/PyTrilinos2.cpp
COMMAND ${PyTrilinos2_BINDER_EXECUTABLE} ${binder_include_name} ${BINDER_OPTIONS}
COMMAND ${BINDER_EXECUTABLE} ${binder_include_name} ${BINDER_OPTIONS}
DEPENDS ${binder_include_name} generate_include_name
)
add_custom_target(binder_call DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/binder/PyTrilinos2.cpp)
Expand All @@ -281,29 +279,14 @@ ELSE()
SET(PyTrilinos2_DEFAULT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
ENDIF()

###################################################################################################
# Set the PyTrilinos2 install prefix
SET(PyTrilinos2_INSTALL_PREFIX ${PyTrilinos2_DEFAULT_INSTALL_PREFIX}
CACHE PATH "The path prefix for where PyTrilinos2 will be installed, e.g. /usr/local")

# Get the python version
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} -c
"import sys; print(sys.version_info.major)"
OUTPUT_VARIABLE PYTHON_MAJOR_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} -c
"import sys; print(sys.version_info.minor)"
OUTPUT_VARIABLE PYTHON_MINOR_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

SET(PYTHON_VERSION ${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION})

SET(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION})

# Determine the install directory
SET(PyTrilinos2_INSTALL_DIR
${PyTrilinos2_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/PyTrilinos2
${PyTrilinos2_INSTALL_PREFIX}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/PyTrilinos2
CACHE PATH "The path where PyTrilinos2 will be installed"
)
MESSAGE(STATUS "PyTrilinos2 installation path: ${PyTrilinos2_INSTALL_DIR}")
Expand All @@ -312,16 +295,8 @@ INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/python/getTpetraTypeName.py
DESTINATION ${PyTrilinos2_INSTALL_DIR})

# Find the pybind11 CMake module
EXECUTE_PROCESS(COMMAND
${Python3_EXECUTABLE} -c "import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE pybind11_DIR
ERROR_VARIABLE pybind11_CMAKE_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
MESSAGE(STATUS "pybind11 CMake path: ${pybind11_DIR}")

find_package(pybind11 REQUIRED)
###################################################################################################
# mpi4py

EXECUTE_PROCESS(COMMAND
${Python3_EXECUTABLE} -c "import mpi4py; print(mpi4py.get_include())"
Expand All @@ -346,6 +321,8 @@ IF(NOT ${Mpi4Py_MPICXX} STREQUAL ${CMAKE_CXX_COMPILER})
MESSAGE(WARNING "the cpp compiler used to compile mpi4py ${Mpi4Py_MPICXX} is not consistent with CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
ENDIF()

###################################################################################################

ADD_SUBDIRECTORY( src )

#file (GLOB PyTrilinos2PyFilesSo "${CMAKE_CURRENT_BINARY_DIR}/src/*.so")
Expand Down
2 changes: 1 addition & 1 deletion packages/PyTrilinos2/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SET(LIB_REQUIRED_DEP_PACKAGES
SET(LIB_OPTIONAL_DEP_PACKAGES MueLu)
SET(TEST_REQUIRED_DEP_PACKAGES)
SET(TEST_OPTIONAL_DEP_PACKAGES)
SET(LIB_REQUIRED_DEP_TPLS)
SET(LIB_REQUIRED_DEP_TPLS LLVM Binder pybind11)
SET(LIB_OPTIONAL_DEP_TPLS)
SET(TEST_REQUIRED_DEP_TPLS)
SET(TEST_OPTIONAL_DEP_TPLS)
2 changes: 2 additions & 0 deletions packages/PyTrilinos2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ target_include_directories(PyTrilinos2 PUBLIC ${Mpi4Py_INCLUDE_DIR} ${CMAKE_CURR
target_compile_features(PyTrilinos2 PUBLIC cxx_std_14)

foreach(depPkg IN LISTS PyTrilinos2_LIB_ENABLED_DEPENDENCIES)
if (NOT (${depPkg} MATCHES "LLVM" OR ${depPkg} MATCHES "Binder" OR ${depPkg} MATCHES "pybind11"))
target_link_libraries(PyTrilinos2 PUBLIC ${depPkg}::all_libs)
endif()
endforeach()
target_link_libraries(PyTrilinos2 PUBLIC ${Trilinos_EXTRA_LINK_FLAGS})
set_target_properties(PyTrilinos2 PROPERTIES SUFFIX ".so")
Expand Down
Loading