Streamline Boost tests for compiled libraries and add documentation on Boost module usage
This commit is contained in:
@ -5,8 +5,17 @@ min_cmake_version: 2.8
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[mpi]
|
||||
source: ../../../modules/mpi.cmake
|
||||
|
||||
[python_interpreter]
|
||||
source: ../../../modules/python_interpreter.cmake
|
||||
|
||||
[python_libs]
|
||||
source: ../../../modules/python_libs.cmake
|
||||
|
||||
[boost]
|
||||
override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'chrono;timer;system'}
|
||||
override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'mpi;serialization;python'}
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
|
||||
[default_build_paths]
|
||||
|
@ -4,10 +4,5 @@ if(BUILD_CUSTOM_BOOST)
|
||||
add_dependencies(example custom_boost)
|
||||
endif()
|
||||
|
||||
set(_libs ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_SYSTEM_LIBRARY})
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(_libs ${_libs} rt)
|
||||
endif()
|
||||
|
||||
target_link_libraries(example ${_libs})
|
||||
target_link_libraries(example ${Boost_MPI_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} ${MPI_CXX_LIBRARIES}
|
||||
${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
|
||||
|
@ -1,13 +1,14 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/mpi/environment.hpp>
|
||||
#include <boost/mpi/communicator.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::timer::auto_cpu_timer t;
|
||||
using namespace boost::python;
|
||||
namespace mpi = boost::mpi;
|
||||
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
@ -17,10 +18,26 @@ int main()
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
try {
|
||||
Py_Initialize();
|
||||
|
||||
std::cout << "Measuring some timings..." << std::endl;
|
||||
for (long i = 0; i < 100000000; ++i)
|
||||
std::sqrt(123.456L); // burn some time
|
||||
object main_module((
|
||||
handle<>(borrowed(PyImport_AddModule("__main__")))));
|
||||
|
||||
object main_namespace = main_module.attr("__dict__");
|
||||
|
||||
handle<> ignored(( PyRun_String( "print \"Hello, World\"",
|
||||
Py_file_input,
|
||||
main_namespace.ptr(),
|
||||
main_namespace.ptr() ) ));
|
||||
} catch( error_already_set ) {
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
mpi::environment env;
|
||||
mpi::communicator world;
|
||||
std::cout << "I am process " << world.rank() << " of " << world.size()
|
||||
<< "." << std::endl;
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
|
Reference in New Issue
Block a user