@@ -56,7 +56,7 @@ class interop_handle {
56
56
#else
57
57
(void )Acc;
58
58
// we believe this won't be ever called on device side
59
- return nullptr ;
59
+ return 0 ;
60
60
#endif
61
61
}
62
62
@@ -89,7 +89,7 @@ class interop_handle {
89
89
getNativeQueue ());
90
90
#else
91
91
// we believe this won't be ever called on device side
92
- return nullptr ;
92
+ return 0 ;
93
93
#endif
94
94
}
95
95
@@ -104,7 +104,7 @@ class interop_handle {
104
104
getNativeDevice ());
105
105
#else
106
106
// we believe this won't be ever called on device side
107
- return nullptr ;
107
+ return 0 ;
108
108
#endif
109
109
}
110
110
@@ -119,7 +119,7 @@ class interop_handle {
119
119
getNativeContext ());
120
120
#else
121
121
// we believe this won't be ever called on device side
122
- return nullptr ;
122
+ return 0 ;
123
123
#endif
124
124
}
125
125
@@ -142,8 +142,26 @@ class interop_handle {
142
142
auto getMemImpl (detail::Requirement *Req) const ->
143
143
typename interop<BackendName,
144
144
accessor<DataT, Dims, Mode, Target, IsPlh>>::type {
145
- return reinterpret_cast <typename interop<
146
- BackendName, accessor<DataT, Dims, Mode, Target, IsPlh>>::type>(
145
+ /*
146
+ Do not update this cast: a C-style cast is required here.
147
+
148
+ This function tries to cast pi_native_handle to the native handle type.
149
+ pi_native_handle is a typedef of uintptr_t. It is used to store opaque
150
+ pointers, such as cl_device, and integer handles, such as CUdevice. To
151
+ convert a uintptr_t to a pointer type, such as cl_device, reinterpret_cast
152
+ must be used. However, reinterpret_cast cannot be used to convert
153
+ uintptr_t to a different integer type, such as CUdevice. For this,
154
+ static_cast must be used. This function must employ a cast that is capable
155
+ of reinterpret_cast and static_cast depending on the arguments passed to
156
+ it. A C-style cast will achieve this. The compiler will attempt to
157
+ interpret it as a static_cast, and will fall back to reinterpret_cast
158
+ where appropriate.
159
+
160
+ https://en.cppreference.com/w/cpp/language/reinterpret_cast
161
+ https://en.cppreference.com/w/cpp/language/explicit_cast
162
+ */
163
+ return (typename interop<BackendName,
164
+ accessor<DataT, Dims, Mode, Target, IsPlh>>::type)(
147
165
getNativeMem (Req));
148
166
}
149
167
0 commit comments