From: heister Date: Tue, 5 Nov 2013 16:24:21 +0000 (+0000) Subject: quicktests: add dependency to target binary, add tbb test X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38de522eecf84821c3a8a857a14d8d56211fcfe6;p=dealii-svn.git quicktests: add dependency to target binary, add tbb test git-svn-id: https://svn.dealii.org/trunk@31547 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/tests/quick_tests/CMakeLists.txt b/deal.II/tests/quick_tests/CMakeLists.txt index 6cc86dcdf3..d0174546e4 100644 --- a/deal.II/tests/quick_tests/CMakeLists.txt +++ b/deal.II/tests/quick_tests/CMakeLists.txt @@ -37,11 +37,13 @@ MACRO(make_quicktest test_basename build_name mpi_run) IF(NOT ${mpi_run} EQUAL "") ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK + DEPENDS ${_target} COMMAND mpirun -n ${mpi_run} ./${_target} > ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK 2>&1 || (rm ${_target}-OK && exit 1) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) ELSE() ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK + DEPENDS ${_target} COMMAND ./${_target} > ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK 2>&1 || (rm ${_target}-OK && exit 1) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -76,6 +78,11 @@ IF (DEAL_II_WITH_MPI) make_quicktest("mpi" ${_mybuild} 2) ENDIF() +# Test if TBB works correctly +IF (DEAL_II_WITH_THREADS) + make_quicktest("tbb" ${_mybuild} "") +ENDIF() + # Test p4est. This test exposes a bug in OpenMPI 1.3 and 1.4 # Update to OpenMPI 1.5 or newer. IF (DEAL_II_WITH_P4EST) diff --git a/deal.II/tests/quick_tests/tbb.cc b/deal.II/tests/quick_tests/tbb.cc new file mode 100644 index 0000000000..0b3e8f63f1 --- /dev/null +++ b/deal.II/tests/quick_tests/tbb.cc @@ -0,0 +1,87 @@ +// --------------------------------------------------------------------- +// $Id: affinity.cc 31527 2013-11-03 09:58:45Z maier $ +// +// Copyright (C) 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +// test Threads::new_task and WorkStream::run + +#include +#include +#include + +using namespace dealii; + +void add_one(unsigned int &var) +{ + var += 1; +} + +void test1() +{ + unsigned int tmp = 1; + Threads::Task<> task = Threads::new_task (&add_one,tmp); + task.join(); + if (tmp!=2) + exit(1); +} + +struct scratch_data +{ +}; + +struct copy_data +{ + int value; +}; + + +void assemble(const std::vector::iterator &it, + scratch_data &scratch, + copy_data &data) +{ + std::cout << "hello!" << std::endl; + + data.value +=(*it)*(*it); +} + +void copy(int & value, const copy_data &data) +{ + value += data.value; +} + +void test2() +{ + std::vector v(3); + v[0] = 3; + v[1] = 5; + v[2] = 1; + int result = 0; + WorkStream::run(v.begin(), + v.end(), + &assemble, + std_cxx1x::bind(©, + std_cxx1x::ref(result), + std_cxx1x::_1), + scratch_data(), copy_data()); + std::cout << "result: " << result << std::endl; + + if (result != (3*3+5*5+1*1)) + exit(2); +} + +int main () +{ + test1(); + test2(); +}