File: no-nsync.patch

package info (click to toggle)
onnxruntime 1.19.2%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 331,816 kB
  • sloc: cpp: 3,113,108; python: 172,090; ansic: 108,275; cs: 46,492; asm: 37,308; java: 10,249; javascript: 6,459; pascal: 4,025; sh: 3,117; xml: 609; objc: 283; makefile: 52
file content (219 lines) | stat: -rw-r--r-- 9,267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Description: Replace the use of nsync by pthread
Forwarded: not-needed
Origin: https://src.fedoraproject.org/rpms/onnxruntime/blob/f40/f/no-nsync.patch

--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1045,7 +1045,7 @@
         target_compile_options(${target_name} PRIVATE "-Wno-unused-parameter")
       endif()
       target_compile_definitions(${target_name} PUBLIC -DNSYNC_ATOMIC_CPP11)
-      onnxruntime_add_include_to_target(${target_name} nsync::nsync_cpp)
+#      onnxruntime_add_include_to_target(${target_name} nsync::nsync_cpp)
     endif()
     foreach(ORT_FLAG ${ORT_PROVIDER_FLAGS})
       target_compile_definitions(${target_name} PRIVATE ${ORT_FLAG})
@@ -1670,7 +1670,7 @@
     list(APPEND onnxruntime_EXTERNAL_LIBRARIES advapi32)
   endif()
 else()
-  list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync::nsync_cpp)
+#  list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync::nsync_cpp)
   list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${ICONV_LIB} ${CMAKE_DL_LIBS} Threads::Threads)
 endif()
 
--- a/cmake/external/onnxruntime_external_deps.cmake
+++ b/cmake/external/onnxruntime_external_deps.cmake
@@ -80,7 +80,7 @@
   )
 endif()
 
-if (NOT WIN32)
+if (FALSE AND NOT WIN32)
     FetchContent_Declare(
     google_nsync
     URL ${DEP_URL_google_nsync}
@@ -321,7 +321,7 @@
   onnxruntime_fetchcontent_makeavailable(google_benchmark)
 endif()
 
-if (NOT WIN32)
+if (FALSE AND NOT WIN32)
   #nsync tests failed on Mac Build
   set(NSYNC_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
   onnxruntime_fetchcontent_makeavailable(google_nsync)
--- a/cmake/onnxruntime_mlas.cmake
+++ b/cmake/onnxruntime_mlas.cmake
@@ -722,7 +722,7 @@
     target_link_libraries(onnxruntime_mlas_q4dq PRIVATE cpuinfo)
   endif()
   if(NOT WIN32)
-    target_link_libraries(onnxruntime_mlas_q4dq PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
+#    target_link_libraries(onnxruntime_mlas_q4dq PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
   endif()
   if (CMAKE_SYSTEM_NAME STREQUAL "Android")
     target_link_libraries(onnxruntime_mlas_q4dq PRIVATE ${android_shared_libs})
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -724,7 +724,7 @@
 else()
   target_compile_definitions(onnxruntime_test_utils PUBLIC -DNSYNC_ATOMIC_CPP11)
   target_include_directories(onnxruntime_test_utils PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
-  onnxruntime_add_include_to_target(onnxruntime_test_utils nsync::nsync_cpp)
+  #  onnxruntime_add_include_to_target(onnxruntime_test_utils nsync::nsync_cpp)
 endif()
 if (onnxruntime_USE_NCCL)
   target_include_directories(onnxruntime_test_utils PRIVATE ${NCCL_INCLUDE_DIRS})
@@ -760,7 +760,7 @@
     else()
       target_compile_definitions(onnx_test_runner_common PUBLIC -DNSYNC_ATOMIC_CPP11)
       target_include_directories(onnx_test_runner_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
-      onnxruntime_add_include_to_target(onnx_test_runner_common nsync::nsync_cpp)
+      # onnxruntime_add_include_to_target(onnx_test_runner_common nsync::nsync_cpp)
     endif()
     if (MSVC AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
       #TODO: fix the warnings, they are dangerous
@@ -1148,7 +1148,7 @@
       # "Global initializer calls a non-constexpr function." BENCHMARK_CAPTURE macro needs this.
       target_compile_options(onnxruntime_mlas_benchmark PRIVATE /wd26426)
     else()
-      target_link_libraries(onnxruntime_mlas_benchmark PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
+#      target_link_libraries(onnxruntime_mlas_benchmark PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
     endif()
     if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
       target_link_libraries(onnxruntime_mlas_benchmark PRIVATE cpuinfo)
@@ -1221,7 +1221,7 @@
             ${onnxruntime_EXTERNAL_LIBRARIES}
             ${GETOPT_LIB_WIDE} ${SYS_PATH_LIB} ${CMAKE_DL_LIBS})
       if(NOT WIN32)
-        list(APPEND onnxruntime_perf_test_libs nsync::nsync_cpp)
+	# list(APPEND onnxruntime_perf_test_libs nsync::nsync_cpp)
         if(onnxruntime_USE_SNPE)
           list(APPEND onnxruntime_perf_test_libs onnxruntime_providers_snpe)
         endif()
@@ -1258,7 +1258,7 @@
     # test inference using shared lib
     set(onnxruntime_shared_lib_test_LIBS onnxruntime_mocked_allocator onnxruntime_test_utils onnxruntime_common onnx_proto)
     if(NOT WIN32)
-      list(APPEND onnxruntime_shared_lib_test_LIBS nsync::nsync_cpp)
+      #list(APPEND onnxruntime_shared_lib_test_LIBS nsync::nsync_cpp)
       if(onnxruntime_USE_SNPE)
         list(APPEND onnxruntime_shared_lib_test_LIBS onnxruntime_providers_snpe)
       endif()
@@ -1406,9 +1406,9 @@
     if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
       target_link_libraries(onnxruntime_mlas_test PRIVATE cpuinfo)
     endif()
-    if(NOT WIN32)
-      target_link_libraries(onnxruntime_mlas_test PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
-    endif()
+    # if(NOT WIN32)
+    #   target_link_libraries(onnxruntime_mlas_test PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
+    # endif()
     if (CMAKE_SYSTEM_NAME STREQUAL "Android")
       target_link_libraries(onnxruntime_mlas_test PRIVATE ${android_shared_libs})
     endif()
@@ -1577,7 +1577,7 @@
 
     set(onnxruntime_customopregistration_test_LIBS custom_op_library onnxruntime_common onnxruntime_test_utils)
     if (NOT WIN32)
-      list(APPEND onnxruntime_customopregistration_test_LIBS nsync::nsync_cpp)
+      # list(APPEND onnxruntime_customopregistration_test_LIBS nsync::nsync_cpp)
     endif()
     if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
       list(APPEND onnxruntime_customopregistration_test_LIBS cpuinfo)
@@ -1708,9 +1708,9 @@
     list(APPEND onnxruntime_logging_apis_test_LIBS onnxruntime_session onnxruntime_util onnxruntime_framework onnxruntime_common onnxruntime_graph  onnxruntime_providers onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers iconv re2 libprotobuf-lite onnx_proto nsync_cpp)
      endif()
 
-  if(NOT WIN32)
-    list(APPEND onnxruntime_logging_apis_test_LIBS nsync::nsync_cpp ${CMAKE_DL_LIBS})
-  endif()
+  #if(NOT WIN32)
+  #  list(APPEND onnxruntime_logging_apis_test_LIBS nsync::nsync_cpp ${CMAKE_DL_LIBS})
+  #endif()
 
   AddTest(DYN
           TARGET onnxruntime_logging_apis_test
--- a/include/onnxruntime/core/platform/ort_mutex.h
+++ b/include/onnxruntime/core/platform/ort_mutex.h
@@ -102,13 +102,13 @@
 }
 }  // namespace onnxruntime
 #else
-#include "nsync.h"
+#include <pthread.h>
 #include <mutex>               //for unique_lock
 #include <condition_variable>  //for cv_status
 namespace onnxruntime {
 
 class OrtMutex {
-  nsync::nsync_mu data_ = NSYNC_MU_INIT;
+  pthread_mutex_t data_ = PTHREAD_MUTEX_INITIALIZER;
 
  public:
   constexpr OrtMutex() = default;
@@ -116,16 +116,16 @@
   OrtMutex(const OrtMutex&) = delete;
   OrtMutex& operator=(const OrtMutex&) = delete;
 
-  void lock() { nsync::nsync_mu_lock(&data_); }
-  bool try_lock() noexcept { return nsync::nsync_mu_trylock(&data_) == 0; }
-  void unlock() noexcept { nsync::nsync_mu_unlock(&data_); }
+  void lock() { pthread_mutex_lock(&data_); }
+  bool try_lock() noexcept { return pthread_mutex_lock(&data_) == 0; }
+  void unlock() noexcept { pthread_mutex_unlock(&data_); }
 
-  using native_handle_type = nsync::nsync_mu*;
+  using native_handle_type = pthread_mutex_t*;
   native_handle_type native_handle() { return &data_; }
 };
 
 class OrtCondVar {
-  nsync::nsync_cv native_cv_object = NSYNC_CV_INIT;
+  pthread_cond_t native_cv_object = PTHREAD_COND_INITIALIZER;
 
  public:
   constexpr OrtCondVar() noexcept = default;
@@ -134,8 +134,8 @@
   OrtCondVar(const OrtCondVar&) = delete;
   OrtCondVar& operator=(const OrtCondVar&) = delete;
 
-  void notify_one() noexcept { nsync::nsync_cv_signal(&native_cv_object); }
-  void notify_all() noexcept { nsync::nsync_cv_broadcast(&native_cv_object); }
+  void notify_one() noexcept { pthread_cond_signal(&native_cv_object); }
+  void notify_all() noexcept { pthread_cond_broadcast(&native_cv_object); }
 
   void wait(std::unique_lock<OrtMutex>& lk);
   template <class _Predicate>
@@ -151,7 +151,7 @@
    */
   template <class Rep, class Period>
   std::cv_status wait_for(std::unique_lock<OrtMutex>& cond_mutex, const std::chrono::duration<Rep, Period>& rel_time);
-  using native_handle_type = nsync::nsync_cv*;
+  using native_handle_type = pthread_cond_t*;
   native_handle_type native_handle() { return &native_cv_object; }
 
  private:
--- a/onnxruntime/core/platform/posix/ort_mutex.cc
+++ b/onnxruntime/core/platform/posix/ort_mutex.cc
@@ -27,7 +27,7 @@
     abs_deadline.tv_sec = ts_sec_max;
     abs_deadline.tv_nsec = 999999999;
   }
-  nsync::nsync_cv_wait_with_deadline(&native_cv_object, lk.mutex()->native_handle(), abs_deadline, nullptr);
+  pthread_cond_timedwait(&native_cv_object, lk.mutex()->native_handle(), &abs_deadline);
 }
 
 void OrtCondVar::wait(std::unique_lock<OrtMutex>& lk) {
@@ -36,7 +36,7 @@
     ORT_THROW("OrtCondVar wait failed: mutex not locked");
   }
 #endif
-  nsync::nsync_cv_wait(&native_cv_object, lk.mutex()->native_handle());
+  pthread_cond_wait(&native_cv_object, lk.mutex()->native_handle());
 }
 
-}  // namespace onnxruntime
\ No newline at end of file
+}  // namespace onnxruntime