]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
quicktests: add dependency to target binary, add tbb test
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Nov 2013 16:24:21 +0000 (16:24 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Nov 2013 16:24:21 +0000 (16:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@31547 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/tests/quick_tests/CMakeLists.txt
deal.II/tests/quick_tests/tbb.cc [new file with mode: 0644]

index 6cc86dcdf30b394065548873cf260af9a6bf07b5..d0174546e4b6c29de402139bd109e3e6e7ad0b82 100644 (file)
@@ -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 (file)
index 0000000..0b3e8f6
--- /dev/null
@@ -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 <deal.II/base/thread_management.h>
+#include <deal.II/base/work_stream.h>
+#include <iostream>
+
+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<int>::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<int> v(3);
+  v[0] = 3;
+  v[1] = 5;
+  v[2] = 1;
+  int result = 0;
+  WorkStream::run(v.begin(),
+                 v.end(),
+                 &assemble,
+                 std_cxx1x::bind(&copy,
+                                 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();
+}

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.