From 087417f5b05fc64f6d73a7a2ce9a8e86613b950e Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Fri, 27 Oct 2023 01:01:58 -0700 Subject: [PATCH] fix context for mingw --- src/context.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/context.cc b/src/context.cc index 12cdc3de900a..de718013ae91 100644 --- a/src/context.cc +++ b/src/context.cc @@ -114,13 +114,25 @@ DeviceOrd CUDAOrdinal(DeviceOrd device, bool) { #endif // defined(__MINGW32__) // handle alias +#if defined(__MINGW32__) + // mingw hangs on regex using rtools 430. Basic checks only. + bool is_sycl = (substr == "syc"); +#else + bool is_sycl = std::regex_match(input, std::regex("sycl(:cpu|:gpu)?(:-1|:[0-9]+)?")); +#endif // defined(__MINGW32__) + std::string s_device = input; - if (!std::regex_match(s_device, std::regex("sycl(:cpu|:gpu)?(:-1|:[0-9]+)?"))) { + if (!is_sycl) { s_device = std::regex_replace(s_device, std::regex{"gpu"}, DeviceSym::CUDA()); } auto split_it = std::find(s_device.cbegin(), s_device.cend(), ':'); - if (std::regex_match(s_device, std::regex("sycl:(cpu|gpu)?"))) split_it = s_device.cend(); + + // For these cases we need to move iterator to the end, not to look for a ordinal. + if ((s_device == "sycl:cpu") || + (s_device == "sycl:gpu")) { + split_it = s_device.cend(); + } // For s_device like "sycl:gpu:1" if (split_it != s_device.cend()) {