Skip to content

[SYCLomatic] When migrate the enum type to scoped enum class and fix … #2719

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

Open
wants to merge 1 commit into
base: SYCLomatic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions clang/runtime/dpct-rt/include/dpct/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ __SYCL_CONVERGENT__ extern SYCL_EXTERNAL __SYCL_EXPORT __attribute__((noduplicat
T __spirv_GroupNonUniformShuffleUp(__spv::Scope::Flag, T, unsigned) noexcept;
#endif

template <typename T> struct is_scoped_enum {
static constexpr bool value =
std::is_enum_v<T> && !std::is_convertible_v<T, std::underlying_type_t<T>>;
};
template <typename T>
inline constexpr bool is_scoped_enum_v = is_scoped_enum<T>::value;
template <class T>
std::enable_if_t<is_scoped_enum_v<T>, bool> operator==(const T &type,
int value) {
using underlying_t = std::underlying_type_t<T>;
return static_cast<underlying_t>(type) == value;
}
namespace dpct {
/// dim3 is used to store 3 component dimensions.
class dim3 {
Expand Down
2 changes: 2 additions & 0 deletions clang/test/dpct/cuPointerGetAttributes.cu
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ int main() {

// CHECK: sycl::usm::alloc memType;
CUmemorytype memType;

if (memType == 0) memType = CU_MEMORYTYPE_HOST;
void* hostPtr;
unsigned int isManaged;
int deviceID;
Expand Down