Skip to content

Commit

Permalink
Allow using pkg-config search, fix test_arena_constaints
Browse files Browse the repository at this point in the history
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
  • Loading branch information
isaevil committed Jul 26, 2023
1 parent 274f0ef commit 6d3c952
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ if (NOT BUILD_SHARED_LIBS)
message(WARNING "You are building oneTBB as a static library. This is highly discouraged and such configuration is not supported. Consider building a dynamic library to avoid unforeseen issues.")
endif()

# Prevent searching HWLOC by pkg-config on macOS
if (APPLE)
set(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH ON)
endif()

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
message(STATUS "CMAKE_BUILD_TYPE is not specified. Using default: ${CMAKE_BUILD_TYPE}")
Expand Down
2 changes: 1 addition & 1 deletion src/tbbbind/tbb_bind.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Intel Corporation
Copyright (c) 2019-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
11 changes: 10 additions & 1 deletion test/common/common_arena_constraints.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Intel Corporation
Copyright (c) 2019-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,6 +89,7 @@ int get_processors_group_count() { return 1; }
#define __HWLOC_HYBRID_CPUS_INTERFACES_VALID (!_WIN32 || _WIN64)

#define __HYBRID_CPUS_TESTING __HWLOC_HYBRID_CPUS_INTERFACES_PRESENT && __HWLOC_HYBRID_CPUS_INTERFACES_VALID
#define __HWLOC_CPUBIND_PRESENT (!__APPLE__)

// Macro to check hwloc interfaces return codes
#define hwloc_require_ex(command, ...) \
Expand Down Expand Up @@ -179,12 +180,16 @@ class system_info {
#endif
hwloc_require_ex(hwloc_topology_load, topology);

#if __HWLOC_CPUBIND_PRESENT
if ( get_processors_group_count() > 1 ) {
process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
} else {
process_cpuset = hwloc_bitmap_alloc();
hwloc_require_ex(hwloc_get_cpubind, topology, process_cpuset, 0);
}
#else
process_cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
#endif

hwloc_obj_t current_numa_node = nullptr;
index_info current_node_info{};
Expand Down Expand Up @@ -349,7 +354,11 @@ class system_info {
static affinity_mask allocate_current_affinity_mask() {
affinity_mask result = hwloc_bitmap_alloc();
instance().memory_handler.insert(result);
#if __HWLOC_CPUBIND_PRESENT
hwloc_require_ex(hwloc_get_cpubind, instance().topology, result, HWLOC_CPUBIND_THREAD);
#else
hwloc_bitmap_copy(result, hwloc_topology_get_complete_cpuset(instance().topology));
#endif
REQUIRE_MESSAGE(!hwloc_bitmap_iszero(result), "Empty current affinity mask.");
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions test/tbb/test_arena_constraints.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Intel Corporation
Copyright (c) 2019-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@

#include "tbb/parallel_for.h"

#if __TBB_HWLOC_VALID_ENVIRONMENT
#if __TBB_HWLOC_VALID_ENVIRONMENT && __HWLOC_CPUBIND_PRESENT
//! Test affinity and default_concurrency correctness for all available constraints.
//! \brief \ref error_guessing
TEST_CASE("Test affinity and default_concurrency correctness for all available constraints.") {
Expand Down Expand Up @@ -87,7 +87,7 @@ TEST_CASE("Test constraints propagation during arenas copy construction") {
test_constraints_affinity_and_concurrency(constraints, copied_affinity);
}
}
#endif /*__TBB_HWLOC_VALID_ENVIRONMENT*/
#endif /*__TBB_HWLOC_VALID_ENVIRONMENT && __HWLOC_CPUBIND_PRESENT */

// The test cannot be stabilized with TBB malloc under Thread Sanitizer
#if !__TBB_USE_THREAD_SANITIZER
Expand Down

0 comments on commit 6d3c952

Please sign in to comment.