sched_getcpu() and pthread_setaffinity_np() are non-portable
Reported by Yuri Victorovich, on FreeBSD. * configure.ac: Test for them. * spot/mc/mc_instanciator.hh: Only use them if they are present. * NEWS: Mention the fix.
This commit is contained in:
parent
5f49209caf
commit
2a408bbed1
3 changed files with 14 additions and 5 deletions
3
NEWS
3
NEWS
|
|
@ -5,6 +5,9 @@ New in spot 2.10.1.dev (not yet released)
|
|||
- twa_graph::purge_dead_states() now also removes edges labeled by
|
||||
bddfalse.
|
||||
|
||||
- only use sched_getcpu() and pthread_setaffinity_np() when they are
|
||||
available.
|
||||
|
||||
New in spot 2.10.1 (2021-11-19)
|
||||
|
||||
Build:
|
||||
|
|
|
|||
|
|
@ -148,7 +148,12 @@ CHECK_ATOMIC
|
|||
AX_CHECK_BUDDY
|
||||
|
||||
AC_CHECK_HEADERS([sys/times.h valgrind/memcheck.h spawn.h])
|
||||
AC_CHECK_FUNCS([times kill alarm sigaction])
|
||||
AC_CHECK_FUNCS([times kill alarm sigaction sched_getcpu])
|
||||
|
||||
oLIBS=$LIBS
|
||||
LIBS="$LIBS -lpthread"
|
||||
AC_CHECK_FUNCS([pthread_setaffinity_np])
|
||||
LIBS=$oLIBS
|
||||
|
||||
LT_CONFIG_LTDL_DIR([ltdl])
|
||||
LT_INIT([win32-dll])
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <spot/misc/common.hh>
|
||||
#include <spot/misc/_config.h>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
|
@ -31,7 +33,6 @@
|
|||
#include <spot/mc/cndfs.hh>
|
||||
#include <spot/mc/bloemen.hh>
|
||||
#include <spot/mc/bloemen_ec.hh>
|
||||
#include <spot/misc/common.hh>
|
||||
#include <spot/misc/timer.hh>
|
||||
|
||||
namespace spot
|
||||
|
|
@ -115,7 +116,7 @@ namespace spot
|
|||
{
|
||||
threads[i] = std::thread ([&swarmed, &iomutex, i, &barrier]
|
||||
{
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
#ifdef SPOT_HAVE_SCHED_GETCPU
|
||||
{
|
||||
std::lock_guard<std::mutex> iolock(iomutex);
|
||||
std::cout << "Thread #" << i
|
||||
|
|
@ -129,8 +130,8 @@ namespace spot
|
|||
swarmed[i]->run();
|
||||
});
|
||||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
// Pins threads to a dedicated core.
|
||||
#ifdef SPOT_PTHREAD_SETAFFINITY_NP
|
||||
// Pin threads to a dedicated core.
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(i, &cpuset);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue