-
Notifications
You must be signed in to change notification settings - Fork 19
Fix Windows compatibility issues #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,7 +116,7 @@ struct sycl_backend::impl { | |
| sycl::context sycl_context; | ||
| std::vector<sycl::queue> queues; | ||
| std::optional<detail::thread_queue> submission_thread; | ||
| std::atomic_flag active_async_error_check = false; | ||
| std::atomic_flag active_async_error_check; // since c++20 atomic_flag is set to clear by default (false) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change necessary? |
||
|
|
||
| device_state() = default; | ||
| explicit device_state(const sycl::device& dev) : sycl_device(dev), sycl_context(sycl_device) {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,24 +20,76 @@ | |
|
|
||
| #include <fmt/format.h> | ||
|
|
||
| #if !defined(_MSC_VER) | ||
| #if __has_include(<cxxabi.h>) | ||
| // Required for kernel name demangling in Clang | ||
| #include <cxxabi.h> | ||
| #endif | ||
|
|
||
|
|
||
| namespace celerity::detail::utils { | ||
|
|
||
| #if !__has_include(<cxxabi.h>) | ||
| static std::string msvc_undecorate_type_name(std::string s) { | ||
| static constexpr const char* ptr_suffixes[] = { | ||
| " * __ptr64", | ||
| " * __ptr32", | ||
| " *", | ||
| " & __ptr64", | ||
| " &", | ||
| " && __ptr64", | ||
| " &&", | ||
| }; | ||
| for(const char* suffix : ptr_suffixes) { | ||
| std::string_view sv(suffix); | ||
| if(s.size() >= sv.size() && s.compare(s.size() - sv.size(), sv.size(), sv) == 0) { | ||
| s.erase(s.size() - sv.size()); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| static constexpr const char* cv_suffixes[] = { | ||
| " const volatile", | ||
| " volatile", | ||
| " const", | ||
| }; | ||
| for(const char* suffix : cv_suffixes) { | ||
| std::string_view sv(suffix); | ||
| if(s.size() >= sv.size() && s.compare(s.size() - sv.size(), sv.size(), sv) == 0) { | ||
| s.erase(s.size() - sv.size()); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| static constexpr const char* prefixes[] = { | ||
| "class ", | ||
| "struct ", | ||
| "union ", | ||
| "enum ", | ||
| }; | ||
| for(const char* prefix : prefixes) { | ||
| std::string_view sv(prefix); | ||
| if(s.compare(0, sv.size(), sv) == 0) { | ||
| s.erase(0, sv.size()); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return s; | ||
| } | ||
| #endif | ||
|
|
||
| std::string get_simplified_type_name_from_pointer(const std::type_info& pointer_type_info) { | ||
| #if !defined(_MSC_VER) | ||
| // This type of demangling can be done if the abi header is available. This also works for Clang on Windows, if | ||
| // compiled with Itanium ABI on Windows (e.g. MinGW/MSYS2). MSVC | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MSVC ? |
||
| #if __has_include(<cxxabi.h>) | ||
| const std::unique_ptr<char, void (*)(void*)> demangle_buffer(abi::__cxa_demangle(pointer_type_info.name(), nullptr, nullptr, nullptr), std::free); | ||
| std::string demangled_type_name = demangle_buffer.get(); | ||
| #else | ||
| std::string demangled_type_name = pointer_type_info.name(); | ||
| #endif | ||
|
|
||
| // get rid of the pointer "*" | ||
| if(!demangled_type_name.empty() && demangled_type_name.back() == '*') { demangled_type_name.pop_back(); } | ||
| #else | ||
| std::string demangled_type_name = msvc_undecorate_type_name(pointer_type_info.name()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this kind of assumes that anything not fulfilling |
||
| #endif | ||
|
|
||
| if(demangled_type_name.length() < 2) return demangled_type_name; | ||
| bool templated = false; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generally a good idea, but usually done right before
windows.his included. Is there a reason why it is in this particular spot?