0 if you don't. */
#cmakedefine HAVE_DECL_PTHREAD_SETAFFINITY_NP
+#cmakedefine HAVE_PTHREAD_NP_H
+
/* Define to 1 if you have the `malloc_info' function. */
#cmakedefine HAVE_MALLOC_INFO
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -isystem ${SQLITE3_INCLUDE_DIRS}")
endif()
+# BSD has the _np funcs in a _np header
+CHECK_INCLUDE_FILE(pthread_np.h HAVE_PTHREAD_NP_H)
+if (HAVE_PTHREAD_NP_H)
+ set (PTHREAD_NP_INC pthread_np.h)
+else ()
+ set (PTHREAD_NP_INC pthread.h)
+endif ()
+
+set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE")
+set (CMAKE_REQUIRED_LIBRARIES pthread)
+CHECK_CXX_SYMBOL_EXISTS(pthread_setaffinity_np ${PTHREAD_NP_INC} HAVE_DECL_PTHREAD_SETAFFINITY_NP)
+
CHECK_FUNCTION_EXISTS(malloc_info HAVE_MALLOC_INFO)
CHECK_FUNCTION_EXISTS(shmget HAVE_SHMGET)
set(HAVE_SHMGET ${HAVE_SHMGET} CACHE BOOL "shmget()")
#include <getopt.h>
#ifndef _WIN32
#include <pthread.h>
+#if defined(HAVE_PTHREAD_NP_H)
+#include <pthread_np.h>
+#endif
#include <unistd.h>
#endif
// Apply processor affinity (if available) to this thread.
bool affine(UNUSED int cpu) {
#ifdef HAVE_DECL_PTHREAD_SETAFFINITY_NP
+#if defined(__linux__)
cpu_set_t cpuset;
+#else // BSD
+ cpuset_t cpuset;
+#endif
CPU_ZERO(&cpuset);
assert(cpu >= 0 && cpu < CPU_SETSIZE);
" (default: streaming).\n");
printf(" -V Benchmark in vectored mode"
" (default: streaming).\n");
+#ifdef HAVE_DECL_PTHREAD_SETAFFINITY_NP
printf(" -T CPU,CPU,... Benchmark with threads on these CPUs.\n");
+#endif
printf(" -i DIR Don't compile, load from files in DIR"
" instead.\n");
printf(" -w DIR After compiling, save to files in DIR.\n");
static
void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
UNUSED unique_ptr<Grey> &grey) {
- const char options[] = "-b:c:Cd:e:E:G:hi:n:No:p:sT:Vw:z:";
+ const char options[] = "-b:c:Cd:e:E:G:hi:n:No:p:sVw:z:"
+#if HAVE_DECL_PTHREAD_SETAFFINITY_N
+ "T:" // add the thread flag
+#endif
+ ;
int in_sigfile = 0;
int do_per_scan = 0;
int do_echo_matches = 0;