Commit fb66bdf6 authored by Markus Holzer's avatar Markus Holzer Committed by Dominik Thoennes
Browse files

load pybind11 after finding python libraries

also clean up some old leftovers nearby
parent 2724c85f
This diff is collapsed.
[submodule "extern/pybind11"]
path = extern/pybind11
url = https://github.com/pybind/pybind11.git
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
## [Unreleased] ## [Unreleased]
- Python Coupling now build upon pybind11. Boost.Python is no longer supported
- lbm module dropped from python coupling due to deprecation for a long time
- geometry, postprocessing and timeloop dropped from python coupling due to its low usage
- PEP8-ification of Python API. This means all keyword arguments are now in snake_case and not in CamelCase as before.
## [4.1] - 2019-04-19 ## [4.1] - 2019-04-19
### Added ### Added
- Galerkin coarsening for Multigrid - Galerkin coarsening for Multigrid
......
...@@ -75,8 +75,6 @@ option ( WALBERLA_BUILD_WITH_GCOV "Enables gcov" ...@@ -75,8 +75,6 @@ option ( WALBERLA_BUILD_WITH_GCOV "Enables gcov"
option ( WALBERLA_BUILD_WITH_LTO "Enable link time optimizations" ) option ( WALBERLA_BUILD_WITH_LTO "Enable link time optimizations" )
option ( WALBERLA_BUILD_WITH_OPENMP "Enable OpenMP support" ) option ( WALBERLA_BUILD_WITH_OPENMP "Enable OpenMP support" )
option ( WALBERLA_BUILD_WITH_PYTHON "Support for embedding Python" ) option ( WALBERLA_BUILD_WITH_PYTHON "Support for embedding Python" )
option ( WALBERLA_BUILD_WITH_PYTHON_MODULE "Build waLBerla python module" )
option ( WALBERLA_BUILD_WITH_PYTHON_LBM "Include LBM module into python module" OFF )
option ( WALBERLA_BUILD_WITH_CODEGEN "Enable pystencils code generation" OFF ) option ( WALBERLA_BUILD_WITH_CODEGEN "Enable pystencils code generation" OFF )
...@@ -100,6 +98,8 @@ option ( WALBERLA_OPTIMIZE_FOR_LOCALHOST "Enable compiler optimizations spcif ...@@ -100,6 +98,8 @@ option ( WALBERLA_OPTIMIZE_FOR_LOCALHOST "Enable compiler optimizations spcif
option ( WALBERLA_LOG_SKIPPED "Log skipped cmake targets" ON ) option ( WALBERLA_LOG_SKIPPED "Log skipped cmake targets" ON )
option ( WALBERLA_GIT_SUBMODULE_AUTO "Check submodules during cmake run" ON )
# Installation Directory # Installation Directory
set ( CMAKE_INSTALL_PREFIX /usr/local/waLBerla CACHE STRING "The default installation directory." ) set ( CMAKE_INSTALL_PREFIX /usr/local/waLBerla CACHE STRING "The default installation directory." )
...@@ -315,7 +315,6 @@ if( WALBERLA_CXX_COMPILER_IS_IBM ) ...@@ -315,7 +315,6 @@ if( WALBERLA_CXX_COMPILER_IS_IBM )
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1586-267" ) # 1586-267 (I) Inlining of specified subprogram failed due to the presence of a C++ exception handler add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1586-267" ) # 1586-267 (I) Inlining of specified subprogram failed due to the presence of a C++ exception handler
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1586-266" ) # 1586-266 (I) Inlining of specified subprogram failed due to the presence of a global label add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1586-266" ) # 1586-266 (I) Inlining of specified subprogram failed due to the presence of a global label
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1540-0724" ) # 1540-0724 (W) The non-type template argument "2147483648" of type "T" has wrapped [coming from boost/integer_traits.hpp] add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1540-0724" ) # 1540-0724 (W) The non-type template argument "2147483648" of type "T" has wrapped [coming from boost/integer_traits.hpp]
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1540-0095" ) # 1540-0095 (W) The friend function declaration ... [coming from boost/mpl/map/aux_/map0.hpp]
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1500-030" ) # 1500-030: (I) INFORMATION: [...] Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192. add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1500-030" ) # 1500-030: (I) INFORMATION: [...] Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
add_flag ( CMAKE_C_FLAGS "-qsuppress=1500-030" ) # 1500-030: (I) INFORMATION: [...] Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192. add_flag ( CMAKE_C_FLAGS "-qsuppress=1500-030" ) # 1500-030: (I) INFORMATION: [...] Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
endif() endif()
...@@ -587,53 +586,56 @@ endif() ...@@ -587,53 +586,56 @@ endif()
############################################################################################################################# #############################################################################################################################
if ( WALBERLA_BUILD_WITH_PYTHON ) if ( WALBERLA_BUILD_WITH_PYTHON )
set ( waLBerla_REQUIRED_MIN_PYTHON_VERSION "2.7") find_package( PythonInterp 3.6 QUIET REQUIRED)
find_package( PythonInterp 3 QUIET) # search for Python3 first
find_package( PythonInterp QUIET) # fallback to any Python version
find_package( PythonLibs QUIET REQUIRED) find_package( PythonLibs QUIET REQUIRED)
if( PYTHONLIBS_VERSION_STRING VERSION_LESS ${waLBerla_REQUIRED_MIN_PYTHON_VERSION} )
message( FATAL_ERROR "Found old python library: ${PYTHONLIBS_VERSION_STRING} need at least ${waLBerla_REQUIRED_MIN_PYTHON_VERSION}" )
endif()
option( WALBERLA_USE_PYTHON_DEBUG_LIBRARY "Make use of the python debug library" OFF )
if( WALBERLA_USE_PYTHON_DEBUG_LIBRARY )
# you have to make sure this matches the settings you compiled boost with!
add_definitions( "-DBOOST_DEBUG_PYTHON" )
endif()
if( NOT (PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR ) ) if( NOT (PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR ) )
message( FATAL_ERROR "Couldn't find any python library" ) message( FATAL_ERROR "Couldn't find any python library" )
endif() endif()
SET( WALBERLA_BUILD_WITH_PYTHON 1 ) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pybind11; print(pybind11._version.__version__)"
include_directories( ${PYTHON_INCLUDE_DIR} ) OUTPUT_VARIABLE pybind11_VERSION ERROR_QUIET RESULT_VARIABLE pybind11_VERSION_RESULT)
list ( APPEND SERVICE_LIBS ${PYTHON_LIBRARY} ) string(STRIP "${pybind11_VERSION}" pybind11_VERSION)
if(pybind11_VERSION_RESULT EQUAL "0" AND pybind11_VERSION VERSION_GREATER_EQUAL "2.6.0")
if( NOT WALBERLA_CXX_COMPILER_IS_MSVC ) execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11 --cmakedir
list ( APPEND SERVICE_LIBS -lutil ) OUTPUT_VARIABLE PYBIND11_CMAKE_PATH)
endif() string(STRIP "${PYBIND11_CMAKE_PATH}" PYBIND11_CMAKE_PATH)
find_package(pybind11 PATHS "${PYBIND11_CMAKE_PATH}" NO_DEFAULT_PATH REQUIRED)
if ( WALBERLA_BUILD_WITH_PYTHON_MODULE ) else()
# a python module is a shared library - so everything has to be compiled to position independent code find_package(Git QUIET)
# otherwise linking the static libs into the shared lib will result in errors if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
if( NOT WALBERLA_CXX_COMPILER_IS_MSVC ) # Update submodules as needed
add_flag ( CMAKE_CXX_FLAGS "-fPIC" ) if(WALBERLA_GIT_SUBMODULE_AUTO)
add_flag ( CMAKE_C_FLAGS "-fPIC" ) message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif() endif()
endif()
if( MSVC10 ) if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/pybind11/CMakeLists.txt")
include(CMakeDependentOption) if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
CMAKE_DEPENDENT_OPTION( PYTHON_FIXED_HYPOT_REDEFINITION "fixed _hypot redefinition by python" OFF "WALBERLA_BUILD_WITH_PYTHON" OFF ) message(FATAL_ERROR "Please update git submodules or install pybind11 via pip.")
if( NOT PYTHON_FIXED_HYPOT_REDEFINITION ) else()
message( WARNING "Make sure you modified your pyconfig.h that _hypot is not redefined -> see: http://connect.microsoft.com/VisualStudio/feedback/details/633988/warning-in-math-h-line-162-re-nonstandard-extensions-used" ) message(FATAL_ERROR "Please install pybind11 via pip or download it to ${PROJECT_SOURCE_DIR}/extern/pybind11.")
endif()
endif() endif()
add_subdirectory(extern/pybind11)
# if pybind11 was installed into ${PYTHON_INCLUDE_DIR} (e.g. by pip), that will have a higher priority than the Git submodule unless we reorder the search path
# introduced in 2.6.0 (https://github.com/pybind/pybind11/issues/2709), fixed in 2.6.2 (https://github.com/pybind/pybind11/pull/2716)
set_property( TARGET pybind11::pybind11
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_SOURCE_DIR}/extern/pybind11/include" "${PYTHON_INCLUDE_DIR}")
endif() endif()
# a python module is a shared library - so everything has to be compiled to position independent code
# otherwise linking the static libs into the shared lib will result in errors
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(WALBERLA_BUILD_DOC) if(WALBERLA_BUILD_DOC)
# Sphinx documentation # Sphinx documentation
...@@ -659,16 +661,6 @@ else() ...@@ -659,16 +661,6 @@ else()
list ( APPEND waLBerla_OPTIONAL_BOOST_COMPONENTS system ) list ( APPEND waLBerla_OPTIONAL_BOOST_COMPONENTS system )
endif() endif()
if ( WALBERLA_BUILD_WITH_PYTHON )
if( WALBERLA_CXX_COMPILER_IS_MSVC )
get_filename_component(PYTHON_REQUIRED_LIB ${PYTHON_LIBRARY} NAME_WE)
list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS ${PYTHON_REQUIRED_LIB} )
elseif( WALBERLA_USE_STD_FILESYSTEM OR WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM )
list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS system )
list( REMOVE_ITEM waLBerla_OPTIONAL_BOOST_COMPONENTS system )
endif()
endif()
# This variable is necessary, if the CMAKE version used is not aware of a more recent boost version (keep this up to date!) # This variable is necessary, if the CMAKE version used is not aware of a more recent boost version (keep this up to date!)
set ( Boost_ADDITIONAL_VERSIONS set ( Boost_ADDITIONAL_VERSIONS
"1.45" "1.45.0" "1.46" "1.46.0" "1.46.1" "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0" "1.45" "1.45.0" "1.46" "1.46.0" "1.46.1" "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0"
...@@ -727,18 +719,6 @@ if ( Boost_FOUND ) ...@@ -727,18 +719,6 @@ if ( Boost_FOUND )
endif() endif()
add_definitions ( -DBOOST_ALL_NO_LIB ) # Disable Boost auto-linking (CMAKE does that for us...) add_definitions ( -DBOOST_ALL_NO_LIB ) # Disable Boost auto-linking (CMAKE does that for us...)
#fix for static lib usage: http://stackoverflow.com/questions/11812463/boost-python-link-errors-under-windows-msvc10
if( PYTHONLIBS_FOUND AND Boost_USE_STATIC_LIBS)
add_definitions( -DBOOST_PYTHON_STATIC_LIB )
endif()
#fix for strange link behaviour of boost to python: boost only links to 'pyhton*.lib' and not to the absolute path
if( WIN32 AND PYTHONLIBS_FOUND )
get_filename_component( PYTHON_LIBRARY_DIR ${PYTHON_INCLUDE_DIR} PATH )
link_directories( ${PYTHON_LIBRARY_DIR}/libs )
list( APPEND LINK_DIRS ${PYTHON_LIBRARY_DIR}/libs )
endif()
set( WALBERLA_BUILD_WITH_BOOST TRUE CACHE INTERNAL "Build with Boost" ) set( WALBERLA_BUILD_WITH_BOOST TRUE CACHE INTERNAL "Build with Boost" )
else( Boost_FOUND ) else( Boost_FOUND )
if( (WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM OR WALBERLA_USE_STD_FILESYSTEM) AND (WALBERLA_USE_STD_EXPERIMENTAL_ANY OR WALBERLA_USE_STD_ANY) AND (WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL OR WALBERLA_USE_STD_OPTIONAL) AND NOT WALBERLA_BUILD_WITH_PYTHON) if( (WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM OR WALBERLA_USE_STD_FILESYSTEM) AND (WALBERLA_USE_STD_EXPERIMENTAL_ANY OR WALBERLA_USE_STD_ANY) AND (WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL OR WALBERLA_USE_STD_OPTIONAL) AND NOT WALBERLA_BUILD_WITH_PYTHON)
...@@ -754,31 +734,6 @@ else( Boost_FOUND ) ...@@ -754,31 +734,6 @@ else( Boost_FOUND )
endif( Boost_FOUND ) endif( Boost_FOUND )
# Check if Python3 found and look for according boost python library
if ( WALBERLA_BUILD_WITH_PYTHON AND NOT WALBERLA_CXX_COMPILER_IS_MSVC)
SET(_boost_MULTITHREADED "")
if (Boost_USE_MULTITHREADED OR Boost_USE_MULTITHREADED_LIBRARY)
SET(_boost_MULTITHREADED "-mt")
endif()
if( PYTHON_LIBRARY MATCHES "python3" )
string(REPLACE "." ";" VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
list(GET VERSION_LIST 0 PY_VER_MAJOR)
list(GET VERSION_LIST 1 PY_VER_MINOR)
find_library( BOOST_PYTHON_LIBRARY NAMES
boost_python${PY_VER_MAJOR}${PY_VER_MINOR}${_boost_MULTITHREADED}
boost_python-py${PY_VER_MAJOR}${PY_VER_MINOR}${_boost_MULTITHREADED}
boost_python${PY_VER_MAJOR}${_boost_MULTITHREADED}
boost_python${_boost_MULTITHREADED}
PATHS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH )
else()
find_library( BOOST_PYTHON_LIBRARY NAMES boost_python${_boost_MULTITHREADED}
PATHS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH )
endif()
message(STATUS "Using Boost Python Library ${BOOST_PYTHON_LIBRARY}" )
list ( APPEND SERVICE_LIBS ${BOOST_PYTHON_LIBRARY} )
endif()
############################################################################################################################ ############################################################################################################################
......
...@@ -32,6 +32,4 @@ endif() ...@@ -32,6 +32,4 @@ endif()
# Python module # Python module
if ( WALBERLA_BUILD_WITH_PYTHON ) if ( WALBERLA_BUILD_WITH_PYTHON )
add_subdirectory( pythonmodule ) add_subdirectory( pythonmodule )
# no else with "EXLUDE_FROM_ALL" here, since if WALBERLA_BUILD_WITH_PYTHON_MODULE is not activated
# waLBerla was build without -fPIC , so no linking into shared library is possible
endif() endif()
\ No newline at end of file
...@@ -15,7 +15,7 @@ add_subdirectory( PoiseuilleChannel ) ...@@ -15,7 +15,7 @@ add_subdirectory( PoiseuilleChannel )
add_subdirectory( ProbeVsExtraMessage ) add_subdirectory( ProbeVsExtraMessage )
add_subdirectory( SchaeferTurek ) add_subdirectory( SchaeferTurek )
add_subdirectory( UniformGrid ) add_subdirectory( UniformGrid )
if ( WALBERLA_BUILD_WITH_CODEGEN ) if ( WALBERLA_BUILD_WITH_CODEGEN AND WALBERLA_BUILD_WITH_PYTHON )
add_subdirectory( UniformGridGenerated ) add_subdirectory( UniformGridGenerated )
add_subdirectory( PhaseFieldAllenCahn ) add_subdirectory( PhaseFieldAllenCahn )
endif() endif()
......
...@@ -4,4 +4,4 @@ waLBerla_link_files_to_builddir( "*.py" ) ...@@ -4,4 +4,4 @@ waLBerla_link_files_to_builddir( "*.py" )
waLBerla_add_executable ( NAME FieldCommunication waLBerla_add_executable ( NAME FieldCommunication
DEPENDS blockforest core domain_decomposition field postprocessing sqlite ) DEPENDS blockforest core domain_decomposition field postprocessing sqlite python_coupling )
...@@ -36,7 +36,7 @@ class SingleMessageBufferedScheme ...@@ -36,7 +36,7 @@ class SingleMessageBufferedScheme
public: public:
typedef Stencil_T Stencil; typedef Stencil_T Stencil;
SingleMessageBufferedScheme( const weak_ptr_wrapper< StructuredBlockForest > & bf, const int tag = 17953 ) SingleMessageBufferedScheme( const weak_ptr< StructuredBlockForest > & bf, const int tag = 17953 )
: blockForest_( bf ), tag_( tag ) {} : blockForest_( bf ), tag_( tag ) {}
inline void addDataToCommunicate( const shared_ptr< communication::UniformPackInfo > &packInfo ) inline void addDataToCommunicate( const shared_ptr< communication::UniformPackInfo > &packInfo )
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
private: private:
std::vector< shared_ptr< UniformBufferedScheme< Stencil>> > schemes_; std::vector< shared_ptr< UniformBufferedScheme< Stencil>> > schemes_;
weak_ptr_wrapper< StructuredBlockForest > blockForest_; weak_ptr< StructuredBlockForest > blockForest_;
int tag_; int tag_;
}; };
......
...@@ -16,6 +16,7 @@ if (WALBERLA_BUILD_WITH_CUDA) ...@@ -16,6 +16,7 @@ if (WALBERLA_BUILD_WITH_CUDA)
waLBerla_add_executable(NAME benchmark_multiphase waLBerla_add_executable(NAME benchmark_multiphase
FILES benchmark_multiphase.cpp InitializerFunctions.cpp multiphase_codegen.py FILES benchmark_multiphase.cpp InitializerFunctions.cpp multiphase_codegen.py
DEPENDS blockforest core cuda field postprocessing lbm geometry timeloop gui BenchmarkPhaseFieldCodeGenGPU) DEPENDS blockforest core cuda field postprocessing lbm geometry timeloop gui BenchmarkPhaseFieldCodeGenGPU)
set_target_properties(benchmark_multiphase PROPERTIES CXX_VISIBILITY_PRESET hidden)
else () else ()
waLBerla_generate_target_from_python(NAME BenchmarkPhaseFieldCodeGenCPU waLBerla_generate_target_from_python(NAME BenchmarkPhaseFieldCodeGenCPU
FILE multiphase_codegen.py FILE multiphase_codegen.py
...@@ -31,5 +32,6 @@ else () ...@@ -31,5 +32,6 @@ else ()
waLBerla_add_executable(NAME benchmark_multiphase waLBerla_add_executable(NAME benchmark_multiphase
FILES benchmark_multiphase.cpp InitializerFunctions.cpp multiphase_codegen.py FILES benchmark_multiphase.cpp InitializerFunctions.cpp multiphase_codegen.py
DEPENDS blockforest core field postprocessing lbm geometry timeloop gui BenchmarkPhaseFieldCodeGenCPU) DEPENDS blockforest core field postprocessing lbm geometry timeloop gui BenchmarkPhaseFieldCodeGenCPU)
set_target_properties(benchmark_multiphase PROPERTIES CXX_VISIBILITY_PRESET hidden)
endif (WALBERLA_BUILD_WITH_CUDA) endif (WALBERLA_BUILD_WITH_CUDA)
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "field/communication/PackInfo.h" #include "field/communication/PackInfo.h"
#include "field/vtk/VTKWriter.h" #include "field/vtk/VTKWriter.h"
#include "python_coupling/DictWrapper.h"
namespace walberla namespace walberla
{ {
using PhaseField_T = GhostLayerField< real_t, 1 >; using PhaseField_T = GhostLayerField< real_t, 1 >;
......
...@@ -18,15 +18,12 @@ ...@@ -18,15 +18,12 @@
// //
//====================================================================================================================== //======================================================================================================================
#include "core/Environment.h"
#include "core/logging/Initialization.h"
#include "core/math/Constants.h" #include "core/math/Constants.h"
#include "field/FlagField.h" #include "field/FlagField.h"
#include "field/communication/PackInfo.h" #include "field/communication/PackInfo.h"
#include "field/vtk/VTKWriter.h" #include "field/vtk/VTKWriter.h"
#include "python_coupling/DictWrapper.h"
#pragma once #pragma once
namespace walberla namespace walberla
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "field/AddToStorage.h" #include "field/AddToStorage.h"
#include "field/FlagField.h" #include "field/FlagField.h"
#include "field/communication/PackInfo.h"
#include "field/python/Exports.h"
#include "field/vtk/VTKWriter.h" #include "field/vtk/VTKWriter.h"
#include "geometry/InitBoundaryHandling.h" #include "geometry/InitBoundaryHandling.h"
......
...@@ -27,8 +27,6 @@ class Scenario: ...@@ -27,8 +27,6 @@ class Scenario:
self.scenario = 1 # 1 rising bubble, 2 RTI self.scenario = 1 # 1 rising bubble, 2 RTI
self.config_dict = self.config() self.config_dict = self.config()
self.csv_file = "benchmark.csv"
@wlb.member_callback @wlb.member_callback
def config(self): def config(self):
return { return {
......
waLBerla_link_files_to_builddir( "*.prm" ) waLBerla_link_files_to_builddir( "*.prm" )
#waLBerla_link_files_to_builddir( "simulation_setup" ) waLBerla_link_files_to_builddir( "simulation_setup" )
foreach (config srt trt mrt smagorinsky entropic smagorinsky_noopt entropic_kbc_n4 foreach (config srt trt mrt smagorinsky entropic smagorinsky_noopt entropic_kbc_n4
...@@ -25,6 +25,7 @@ foreach (config srt trt mrt smagorinsky entropic smagorinsky_noopt entropic_kbc_ ...@@ -25,6 +25,7 @@ foreach (config srt trt mrt smagorinsky entropic smagorinsky_noopt entropic_kbc_
waLBerla_add_executable(NAME UniformGridBenchmarkGPU_${config} waLBerla_add_executable(NAME UniformGridBenchmarkGPU_${config}
FILES UniformGridGPU.cpp FILES UniformGridGPU.cpp
DEPENDS blockforest boundary core cuda domain_decomposition field geometry timeloop vtk gui UniformGridGPUGenerated_${config}) DEPENDS blockforest boundary core cuda domain_decomposition field geometry timeloop vtk gui UniformGridGPUGenerated_${config})
set_target_properties( UniformGridBenchmarkGPU_${config} PROPERTIES CXX_VISIBILITY_PRESET hidden)
endforeach () endforeach ()
...@@ -46,4 +47,5 @@ foreach (config srt trt mrt smagorinsky entropic) ...@@ -46,4 +47,5 @@ foreach (config srt trt mrt smagorinsky entropic)
waLBerla_add_executable(NAME UniformGridBenchmarkGPU_AA_${config} waLBerla_add_executable(NAME UniformGridBenchmarkGPU_AA_${config}
FILES UniformGridGPU_AA.cpp FILES UniformGridGPU_AA.cpp
DEPENDS blockforest boundary core cuda domain_decomposition field geometry timeloop vtk gui UniformGridGPUGenerated_AA_${config}) DEPENDS blockforest boundary core cuda domain_decomposition field geometry timeloop vtk gui UniformGridGPUGenerated_AA_${config})
set_target_properties( UniformGridBenchmarkGPU_AA_${config} PROPERTIES CXX_VISIBILITY_PRESET hidden)
endforeach () endforeach ()
...@@ -30,7 +30,7 @@ template<typename StencilType, typename GPUFieldType > ...@@ -30,7 +30,7 @@ template<typename StencilType, typename GPUFieldType >
class UniformGridGPU_Communication class UniformGridGPU_Communication
{ {
public: public:
explicit UniformGridGPU_Communication(weak_ptr_wrapper<StructuredBlockForest> bf, const BlockDataID & bdId, explicit UniformGridGPU_Communication(weak_ptr<StructuredBlockForest> bf, const BlockDataID & bdId,
CommunicationSchemeType commSchemeType, bool cudaEnabledMPI = false) CommunicationSchemeType commSchemeType, bool cudaEnabledMPI = false)
: _commSchemeType(commSchemeType), _cpuCommunicationScheme(nullptr), _gpuPackInfo(nullptr), : _commSchemeType(commSchemeType), _cpuCommunicationScheme(nullptr), _gpuPackInfo(nullptr),
_gpuCommunicationScheme(nullptr), _directScheme(nullptr) _gpuCommunicationScheme(nullptr), _directScheme(nullptr)
......
...@@ -15,6 +15,7 @@ foreach(config trt smagorinsky mrt entropic_kbc_n4 cumulant ) ...@@ -15,6 +15,7 @@ foreach(config trt smagorinsky mrt entropic_kbc_n4 cumulant )
waLBerla_add_executable ( NAME UniformGridBenchmarkGenerated_${config} waLBerla_add_executable ( NAME UniformGridBenchmarkGenerated_${config}
FILES UniformGridGenerated.cpp FILES UniformGridGenerated.cpp
DEPENDS blockforest boundary core domain_decomposition field geometry timeloop vtk gui DEPENDS blockforest boundary core domain_decomposition field geometry timeloop vtk gui
UniformGridGenerated_${config}) UniformGridGenerated_${config} python_coupling)
set_target_properties(UniformGridBenchmarkGenerated_${config} PROPERTIES CXX_VISIBILITY_PRESET hidden)
endforeach() endforeach()
# waLBerla Python module # waLBerla Python module
if ( WALBERLA_BUILD_WITH_PYTHON_MODULE ) if ( WALBERLA_BUILD_WITH_PYTHON )
if ( WALBERLA_BUILD_WITH_CUDA )
set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field geometry lbm postprocessing python_coupling timeloop vtk) set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field python_coupling timeloop vtk cuda)
if (WALBERLA_BUILD_WITH_CUDA) else()
set(PYTHON_MODULE_DEPENDENCIES ${PYTHON_MODULE_DEPENDENCIES} cuda) set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field python_coupling timeloop vtk)
endif()
if (WALBERLA_BUILD_WITH_OPENMESH)
set(PYTHON_MODULE_DEPENDENCIES ${PYTHON_MODULE_DEPENDENCIES} mesh pe)
endif() endif()
if( WALBERLA_CXX_COMPILER_IS_MSVC ) if( WALBERLA_CXX_COMPILER_IS_MSVC )
set ( pythonModules ${PYTHON_MODULE_DEPENDENCIES}) set ( pythonModules ${PYTHON_MODULE_DEPENDENCIES})
elseif( APPLE ) elseif( APPLE )
set ( pythonModules "-Wl,-force_load" ${PYTHON_MODULE_DEPENDENCIES}) set ( pythonModules "-Wl,-force_load" ${PYTHON_MODULE_DEPENDENCIES})
else() else()
set ( pythonModules "-Wl,-whole-archive" ${PYTHON_MODULE_DEPENDENCIES} "-Wl,-no-whole-archive" ) set ( pythonModules "-Wl,-whole-archive" ${PYTHON_MODULE_DEPENDENCIES} "-Wl,-no-whole-archive" )
endif() endif()
if( WALBERLA_BUILD_WITH_PYTHON_LBM ) add_library( walberla_cpp SHARED PythonModule.cpp )
add_library( walberla_cpp SHARED PythonModuleWithLbmModule.cpp )
else()
add_library( walberla_cpp SHARED PythonModule.cpp )
endif()
target_link_libraries( walberla_cpp ${WALBERLA_LINK_LIBRARIES_KEYWORD} ${pythonModules} ${SERVICE_LIBS} ) target_link_libraries( walberla_cpp ${WALBERLA_LINK_LIBRARIES_KEYWORD} ${pythonModules} ${SERVICE_LIBS} )
set_target_properties( walberla_cpp PROPERTIES PREFIX "")
if ( APPLE ) set_target_properties(
set_target_properties( walberla_cpp PROPERTIES SUFFIX ".so") walberla_cpp PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
endif() SUFFIX "${PYTHON_MODULE_EXTENSION}"
)
set_target_properties( walberla_cpp PROPERTIES MACOSX_RPATH TRUE ) set_target_properties( walberla_cpp PROPERTIES MACOSX_RPATH TRUE )
set_target_properties( walberla_cpp PROPERTIES CXX_VISIBILITY_PRESET hidden)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py )
add_custom_target( pythonModule ALL ${PYTHON_EXECUTABLE} setup.py build DEPENDS walberla_cpp ) add_custom_target( pythonModule ALL ${PYTHON_EXECUTABLE} setup.py build DEPENDS walberla_cpp )
add_custom_target( pythonModuleInstall ${PYTHON_EXECUTABLE} setup.py install DEPENDS walberla_cpp ) add_custom_target( pythonModuleInstall ${PYTHON_EXECUTABLE} setup.py install --user DEPENDS walberla_cpp )
add_test( NAME PythonModuleTest
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -v -s ${walberla_SOURCE_DIR}/python/waLBerla_tests )
endif() endif()
...@@ -15,125 +15,84 @@ ...@@ -15,125 +15,84 @@
// //
//! \file PythonModule.cpp //! \file PythonModule.cpp
//! \author Martin Bauer <martin.bauer@fau.de> //! \author Martin Bauer <martin.bauer@fau.de>
//! \author Markus Holzer <markus.holzer@fau.de>
// //
//====================================================================================================================== //======================================================================================================================
#include "python_coupling/PythonWrapper.h"
#include "waLBerlaDefinitions.h"
#include "blockforest/python/Exports.h"
#include "field/GhostLayerField.h" #include "field/GhostLayerField.h"
#include "field/python/Exports.h"
#include "mesh/python/Exports.h"
#include "geometry/python/Exports.h"
#include "postprocessing/python/Exports.h"
#include "python_coupling/Manager.h" #include "python_coupling/Manager.h"
#include "python_coupling/export/BlockForestExport.h"
#include "python_coupling/export/FieldExports.h"
#include "python_coupling/export/VTKExport.h"
#include "python_coupling/helper/ModuleInit.h" #include "python_coupling/helper/ModuleInit.h"
#include "stencil/all.h" #include "stencil/all.h"
#include "timeloop/python/Exports.h"
#include "vtk/python/Exports.h"
#ifdef WALBERLA_BUILD_WITH_CUDA #ifdef WALBERLA_BUILD_WITH_CUDA
#include "cuda/python/Exports.h" #include "python_coupling/export/CUDAExport.h"
#endif #endif
#include <boost/mpl/vector.hpp>
#include <boost/mpl/insert_range.hpp>
namespace bmpl = boost::mpl;
using namespace walberla; using namespace walberla;
typedef bmpl::vector<
Field<walberla::real_t,1>,
Field<walberla::real_t,2>,
Field<walberla::real_t,3>,
Field<walberla::real_t,4>,
Field<walberla::real_t,5>,
Field<walberla::real_t,6>,
Field<walberla::real_t,9>,
Field<walberla::real_t,15>,
Field<walberla::real_t,19>,
Field<walberla::real_t,27>,
Field<walberla::int8_t,1>,
Field<walberla::int16_t,1>,
Field<walberla::int32_t,1>,
Field<walberla::int64_t,1>,
Field<walberla::int64_t,2>,
Field<walberla::int64_t,3>,
Field<walberla::int64_t,4>,
Field<walberla::uint8_t,1>,