From 5ea599979a5f5c301180314b815422855d9349ba Mon Sep 17 00:00:00 2001 From: maier Date: Sat, 20 Jul 2013 08:25:44 +0000 Subject: [PATCH] add test_affinity program, refactor slightly git-svn-id: https://svn.dealii.org/trunk@30073 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 5 -- deal.II/cmake/scripts/CMakeLists.txt | 10 ++++ deal.II/cmake/setup_custom_targets.cmake | 46 ---------------- deal.II/contrib/CMakeLists.txt | 4 +- deal.II/contrib/test_affinity/CMakeLists.txt | 55 +++++++++++++++++++ .../contrib/test_affinity/test_affinity.cc | 28 ++++++++++ deal.II/doc/CMakeLists.txt | 5 ++ deal.II/source/CMakeLists.txt | 6 +- 8 files changed, 106 insertions(+), 53 deletions(-) delete mode 100644 deal.II/cmake/setup_custom_targets.cmake create mode 100644 deal.II/contrib/test_affinity/CMakeLists.txt create mode 100644 deal.II/contrib/test_affinity/test_affinity.cc diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index dfb99c96a4..70f155cec6 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -133,11 +133,6 @@ ADD_SUBDIRECTORY(cmake/config) # has to be included after source ADD_SUBDIRECTORY(contrib) # has to be included after source ADD_SUBDIRECTORY(examples) -# -# Define some custom targets for convenience -# -INCLUDE(setup_custom_targets) - # # And finally, print the configuration: # diff --git a/deal.II/cmake/scripts/CMakeLists.txt b/deal.II/cmake/scripts/CMakeLists.txt index c1be97fb3f..5ac93c43cc 100644 --- a/deal.II/cmake/scripts/CMakeLists.txt +++ b/deal.II/cmake/scripts/CMakeLists.txt @@ -67,6 +67,16 @@ IF(DEAL_II_COMPONENT_COMPAT_FILES) ) ENDIF() + # + # A custom target with the same name as the component: + # + ADD_CUSTOM_TARGET(compat_files + DEPENDS + expand_instantiations + make_dependencies + report_features + ) + IF(NOT CMAKE_CROSSCOMPILING) ADD_CUSTOM_TARGET(run_report_features COMMAND report_features) ENDIF() diff --git a/deal.II/cmake/setup_custom_targets.cmake b/deal.II/cmake/setup_custom_targets.cmake deleted file mode 100644 index 10bcb7dbea..0000000000 --- a/deal.II/cmake/setup_custom_targets.cmake +++ /dev/null @@ -1,46 +0,0 @@ -## --------------------------------------------------------------------- -## $Id$ -## -## Copyright (C) 2012 - 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. -## -## --------------------------------------------------------------------- - -# -# Setup some convenience custom targets for the build system: -# - - -######################################################################## -# # -# Custom targets for library, documentation and compat_files comp.: # -# # -######################################################################## - -ADD_CUSTOM_TARGET(library) -FOREACH(_build ${DEAL_II_BUILD_TYPES}) - ADD_DEPENDENCIES(library ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}) -ENDFOREACH() - -IF(DEAL_II_COMPONENT_DOCUMENTATION) - ADD_CUSTOM_TARGET(documentation - DEPENDS doxygen - ) -ENDIF() - -IF(DEAL_II_COMPONENT_COMPAT_FILES) - ADD_CUSTOM_TARGET(compat_files - DEPENDS - expand_instantiations - make_dependencies - report_features - ) -ENDIF() diff --git a/deal.II/contrib/CMakeLists.txt b/deal.II/contrib/CMakeLists.txt index 75fe322493..045394df87 100644 --- a/deal.II/contrib/CMakeLists.txt +++ b/deal.II/contrib/CMakeLists.txt @@ -19,6 +19,8 @@ IF(DEAL_II_COMPONENT_MESH_CONVERTER) ENDIF() IF(DEAL_II_COMPONENT_PARAMETER_GUI) - ADD_SUBDIRECTorY(parameter_gui) + ADD_SUBDIRECTORY(parameter_gui) ENDIF() +ADD_SUBDIRECTORY(test_affinity) + diff --git a/deal.II/contrib/test_affinity/CMakeLists.txt b/deal.II/contrib/test_affinity/CMakeLists.txt new file mode 100644 index 0000000000..0a737d4ae3 --- /dev/null +++ b/deal.II/contrib/test_affinity/CMakeLists.txt @@ -0,0 +1,55 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## 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. +## +## --------------------------------------------------------------------- + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# FIND_PACKAGE(deal.II 8.0 REQUIRED) +# DEAL_II_SETUP_CACHED_VARIABLES() +# PROJECT(test_affinity) +ADD_EXECUTABLE(test_affinity + test_affinity.cc + ) +#DEAL_II_SETUP_TARGET() + +IF(CMAKE_BUILD_TYPE MATCHES "Debug") + SET(_build "DEBUG") +ELSE() + SET(_build "RELEASE") +ENDIF() + +SET_TARGET_PROPERTIES(test_affinity PROPERTIES + LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}" + COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}" + LINKER_LANGUAGE "CXX" + ) + +TARGET_LINK_LIBRARIES(test_affinity ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}) + +IF(NOT CMAKE_CROSSCOMPILING) + ADD_CUSTOM_TARGET(run_test_affinity COMMAND test_affinity) +ENDIF() + +# IF("${DEAL_II_EXECUTABLE_RELDIR}" STREQUAL "") +# SET(DEAL_II_EXECUTABLE_RELDIR "bin") +# ENDIF() + +# INSTALL(TARGETS test_affinity +# RUNTIME +# DESTINATION ${DEAL_II_EXECUTABLE_RELDIR} +# COMPONENT mesh_converter +# ) + diff --git a/deal.II/contrib/test_affinity/test_affinity.cc b/deal.II/contrib/test_affinity/test_affinity.cc new file mode 100644 index 0000000000..6e326b65df --- /dev/null +++ b/deal.II/contrib/test_affinity/test_affinity.cc @@ -0,0 +1,28 @@ +#include + +int main () +{ + // we need this, otherwise gcc will not link against deal.II + dealii::Triangulation<2> test; + + cpu_set_t my_set; + CPU_ZERO(&my_set); + + unsigned int len = sizeof(my_set); + int ret = sched_getaffinity(0, len, &my_set); + + if (ret!=0) + { + printf("sched_getaffinity() failed, return value: %d\n", ret); + return -1; + } + + unsigned int bits_set = CPU_COUNT(&my_set); + + if (bits_set==1) + { + printf("Warning: sched_getaffinity() returns that we can only use one CPU.\n"); + return 1; + } + printf("ncpus=%d, mask=%08X\n", bits_set, *(unsigned int*)(&my_set)); +} diff --git a/deal.II/doc/CMakeLists.txt b/deal.II/doc/CMakeLists.txt index 14c195045a..eeb7064928 100644 --- a/deal.II/doc/CMakeLists.txt +++ b/deal.II/doc/CMakeLists.txt @@ -46,6 +46,11 @@ IF(DEAL_II_COMPONENT_DOCUMENTATION) # ADD_SUBDIRECTORY(doxygen) + # + # A custom target with the same name as the component: + # + ADD_CUSTOM_TARGET(documentation DEPENDS doxygen) + # # Install the static elements of the html documentation: # diff --git a/deal.II/source/CMakeLists.txt b/deal.II/source/CMakeLists.txt index fcd61d8a46..96c55ff3db 100644 --- a/deal.II/source/CMakeLists.txt +++ b/deal.II/source/CMakeLists.txt @@ -50,6 +50,8 @@ ADD_SUBDIRECTORY(matrix_free) ADD_SUBDIRECTORY(meshworker) +ADD_CUSTOM_TARGET(library) + FOREACH(build ${DEAL_II_BUILD_TYPES}) STRING(TOLOWER ${build} build_lowercase) @@ -65,6 +67,8 @@ FOREACH(build ${DEAL_II_BUILD_TYPES}) ${deal_ii_objects_${build_lowercase}} ) + ADD_DEPENDENCIES(library ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}) + SET_TARGET_PROPERTIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX} PROPERTIES VERSION "${DEAL_II_PACKAGE_VERSION}" @@ -74,7 +78,7 @@ FOREACH(build ${DEAL_II_BUILD_TYPES}) # a C++ library is still ABI backwards compatible :-] # SOVERSION "${DEAL_II_PACKAGE_VERSION}" - LINK_FLAGS "${DEAL_II_SHARED_LINKER_FLAGS_${build}}" + LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}" COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${build}}" COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${build}}" INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${DEAL_II_LIBRARY_RELDIR}" -- 2.39.5