gemini-code-assist[bot] commented on code in PR #19996:
URL: https://github.com/apache/tvm/pull/19996#discussion_r3571623101
##########
src/s_tir/meta_schedule/postproc/verify_gpu_code.cc:
##########
@@ -147,6 +149,11 @@ class VerifyGPUCodeNode : public PostprocNode {
}
bool Apply(const s_tir::Schedule& sch) final {
+#ifdef _WIN32
+ // The lowering pipeline below is not safe to run concurrently on Windows.
+ static std::mutex lowering_mutex;
+ std::lock_guard<std::mutex> lock(lowering_mutex);
+#endif
Review Comment:

Using a local static `std::mutex` with a non-trivial destructor can lead to
destruction order issues or crashes during program exit (especially on Windows
when TVM is built/loaded as a DLL).
To avoid exit-time destruction issues, use a static pointer to `std::mutex`
which has a trivial destructor and is safely leaked on exit.
```suggestion
#ifdef _WIN32
// The lowering pipeline below is not safe to run concurrently on
Windows.
static std::mutex* lowering_mutex = new std::mutex();
std::lock_guard<std::mutex> lock(*lowering_mutex);
#endif
```
##########
tests/python/s_tir/meta_schedule/test_meta_schedule_search_strategy.py:
##########
@@ -271,6 +308,55 @@ def _schedule_matmul_empty(sch: Schedule):
assert num_trials_each_iter == [1, 0, 0, 0, 0]
[email protected](sys.platform != "win32", reason="Windows-specific
concurrency regression")
+def test_evolutionary_search_cuda_postprocessors_thread_safe():
Review Comment:

The test only generates measure candidates (which runs the TIR lowering
pipeline) and does not compile or execute code on actual GPU hardware.
Therefore, it does not require a CUDA runtime/driver and can run on any
platform.
Removing the `@pytest.mark.skipif` decorator allows this test to run on all
platforms, providing broader test coverage and preventing future regressions
across all operating systems.
```suggestion
def test_evolutionary_search_cuda_postprocessors_thread_safe():
```
##########
tests/python/s_tir/meta_schedule/test_meta_schedule_search_strategy.py:
##########
@@ -19,6 +19,8 @@
# pylint: disable=missing-function-docstring
+import sys
+
import pytest
Review Comment:

If the `skipif` decorator is removed from the test below, `sys` is no longer
used in this file and its import can be removed.
```suggestion
import pytest
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]