Skip to content

Commit a43c5bd

Browse files
[SYCL] Allow const device_global (#8642)
This commit default constructs the USM pointer member of a device_global without the device_image_scope property. This fixes an issue where the compiler would disallow device_global from being const. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent c39de71 commit a43c5bd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sycl/include/sycl/ext/oneapi/device_global/device_global.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ template <typename T, typename PropertyListT, typename = void>
4444
class device_global_base {
4545
protected:
4646
using pointer_t = typename decorated_global_ptr<T>::pointer;
47-
pointer_t usmptr;
47+
pointer_t usmptr{};
4848
pointer_t get_ptr() noexcept { return usmptr; }
4949
const pointer_t get_ptr() const noexcept { return usmptr; }
5050

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
2+
// expected-no-diagnostics
3+
4+
#include <sycl/sycl.hpp>
5+
6+
namespace experimental = sycl::ext::oneapi::experimental;
7+
8+
const experimental::device_global<int> DeviceGlobal;
9+
const experimental::device_global<int, decltype(experimental::properties{
10+
experimental::device_image_scope})>
11+
ScopedDeviceGlobal;

0 commit comments

Comments
 (0)