aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils/CMakeLists.txt
diff options
context:
space:
mode:
authorAaron Rossetto <aaron.rossetto@ni.com>2019-10-02 16:35:06 -0500
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:10 -0800
commit93d8c6f83b35ca08b009a02b7109e09f4e4e43b1 (patch)
tree622595b8753b7a8733ead4fa440888514d434cbe /host/lib/utils/CMakeLists.txt
parent1ee9529abdf32be8ff254114a108aeb14534cf98 (diff)
downloaduhd-93d8c6f83b35ca08b009a02b7109e09f4e4e43b1.tar.gz
uhd-93d8c6f83b35ca08b009a02b7109e09f4e4e43b1.tar.bz2
uhd-93d8c6f83b35ca08b009a02b7109e09f4e4e43b1.zip
uhd: Add thread affinity utility functions
Diffstat (limited to 'host/lib/utils/CMakeLists.txt')
-rw-r--r--host/lib/utils/CMakeLists.txt43
1 files changed, 43 insertions, 0 deletions
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt
index 74b292fbb..5c4478909 100644
--- a/host/lib/utils/CMakeLists.txt
+++ b/host/lib/utils/CMakeLists.txt
@@ -55,6 +55,10 @@ else()
set(THREAD_PRIO_DEFS HAVE_THREAD_PRIO_DUMMY)
endif()
+########################################################################
+# Setup defines for thread naming
+########################################################################
+
set(CMAKE_REQUIRED_LIBRARIES "pthread")
CHECK_CXX_SOURCE_COMPILES("
@@ -82,6 +86,45 @@ else()
list(APPEND THREAD_PRIO_DEFS HAVE_THREAD_SETNAME_DUMMY)
endif()
+########################################################################
+# Setup defines for thread affinitizing
+########################################################################
+
+CHECK_CXX_SOURCE_COMPILES("
+ #include <pthread.h>
+ int main(){
+ pthread_t pt;
+ cpu_set_t cs;
+ pthread_setaffinity_np(pt, sizeof(cpu_set_t), &cs);
+ return 0;
+ }
+ " HAVE_PTHREAD_SETAFFINITY_NP
+)
+
+if(CYGWIN)
+ set(HAVE_PTHREAD_SETAFFINITY_NP False)
+endif(CYGWIN)
+
+CHECK_CXX_SOURCE_COMPILES("
+ #include <windows.h>
+ int main(){
+ SetThreadAffinityMask(GetCurrentThread(), 0);
+ return 0;
+ }
+ " HAVE_WIN_SETTHREADAFFINITYMASK
+)
+if(HAVE_PTHREAD_SETAFFINITY_NP)
+ message(STATUS " Setting thread affinity is supported through pthread_setaffinity_np.")
+ list(APPEND THREAD_PRIO_DEFS HAVE_PTHREAD_SETAFFINITY_NP)
+ LIBUHD_APPEND_LIBS(pthread)
+elseif(HAVE_WIN_SETTHREADPRIORITY)
+ message(STATUS " Setting thread affinity is supported through windows SetThreadAffinityMask.")
+ list(APPEND THREAD_PRIO_DEFS HAVE_WIN_SETTHREADAFFINITYMASK)
+else()
+ message(STATUS " Setting thread affinity is not supported.")
+ list(APPEND THREAD_PRIO_DEFS HAVE_THREAD_SETAFFINITY_DUMMY)
+endif()
+
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/thread.cpp