Remove nsync
Description
- Remove the onnxruntime::OrtMutex class and replace it with ~absl::Mutex~ std::mutex.
- After this change, most source files will not include <Windows.h> indirectly.
Motivation and Context
To reduce the number of deps we have, and address some Github issues that are related to build ONNX Runtime from source. In PR #3000 , I added a custom implementation of std::mutex . It was mainly because at that time std::mutex's default constructor was not trivial on Windows. If you had such a mutex as a global var, it could not be initialized at compile time. Then VC++ team fixed this issue. Therefore we don't need this custom implementation anymore.
This PR also removes nsync. I ran several models tests on Linux. I didn't see any perf difference. This PR also reverts PR #21005 , which is no longer needed since conda has updated its msvc runtime DLL.
This PR unblocks #22173 and resolves #22092 . We have a lot of open issues with nsync. This PR can resolve all of them.
I hit a blocker in Web CI pipeline. Then Yulong and I had a meeting and discussed it. We found the root cause, but the fix is non-trivial. Instead, I will wait his ES6 change getting merged first.
I updated this PR to use std::mutex instead. Originally I tried to use absl::mutex.
/azp run ONNX Runtime Web CI Pipeline
Azure Pipelines successfully started running 1 pipeline(s).
/azp run Windows CPU CI Pipeline
Azure Pipelines successfully started running 1 pipeline(s).
General comment. It would save us a lot of refactoring and preserve lots of flexibility if we simply refactored OrtMutex or typedefed as absl::Mutex. Also could continue to use std::lock_guard. Then most of the code would remain the same, and we could change it to something else as the circumstances require.
I reworked the PR. absl::Mutex cannot be used with std::lock_guard. So I changed the type to std::mutex . As we no longer use a custom type of mutex, I think we no longer need to have an extra typedef . Though this PR changed 110 files. All the changes were done by a simple bash script. If in the future we want to introduce a custom mutex type back, I volunteer to help.
For reference, the code changes were generated by the following commands:
git rm include/onnxruntime/core/platform/ort_mutex.h -f
git rm onnxruntime/core/platform/posix/ort_mutex.cc -f
find . -type f -exec sed -i 's/onnxruntime::OrtMutex/std::mutex/g' {} \;
find . -type f -exec sed -i 's/OrtMutex/std::mutex/g' {} \;
find . -type f -exec sed -i 's/onnxruntime::OrtCondVar/std::condition_variable/g' {} \;
find . -type f -exec sed -i 's/OrtCondVar/std::condition_variable/g' {} \;
find . -type f -exec sed -i 's/#include "core\/platform\/ort_mutex.h"/#include <mutex>/g' {} \;
find . -type f -exec sed -i 's/#include <core\/platform\/ort_mutex.h>/#include <mutex>/g' {} \;
FYI there are still some leftovers for nsync https://github.com/microsoft/onnxruntime/blob/ae628b935b819bab164645dcec341f9c5b83a545/cmake/onnxruntime_webassembly.cmake#L241 https://github.com/microsoft/onnxruntime/blob/main/cmake/patches/nsync/nsync_1.26.0.patch
@fs-eire , can we delete the WASM64 build option and all related cmake code? The feature never went to production and currently it does not have owner . If we still need this feature, we can rebuild it.
Yes I am OK to remove it.