intel / intel/llvm

[SYCL] `platform()` return a platform with no device

Open
#4,544 3 comments 0 reactions 0 assignees View on GitHub
bug confirmed runtime
Dominant language
LLVM
Stars
1.5k
Forks
854
Avg merge
3d 17h
Merged PRs (30d)
137

Description

**Describe the bug**

The `sycl::plarform()` constructor return a platform with no device. This is forbidden by the spec. But maybe I do something wronrg...

**To Reproduce**

```
$cat foo.cpp
#include
namespace sycl = cl::sycl;
int main() {
#ifdef DEFAULT
sycl::platform P = sycl::platform(sycl::default_selector{});
#else
sycl::platform P = sycl::platform();
#endif
assert(!P.get_devices().empty());
}
$dpcpp foo.cpp
$./a.out
a.out: foo.cpp:10: int main(): Assertion `!P.get_devices().empty()' failed.
Aborted
```

**Environment (please complete the following information):**

- OS: Linux
- Target device and vendor: Intel GPU / OpenCL / Level 0
- DPC++ version: 2021.x.0.20210819

**Additional context**

`https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:platform-class` said for the `platform()` constructor:

>Constructs a SYCL platform instance that is a copy of the platform which contains the device returned by default_selector_v.

This doesn't seem to be the case here. As the spec said for `default_selector_v`:
>Since all implementations must support at least one device, this selector must always return a device.

But our platform is empty. Also, Compiling the code with `-DDEFAULT` behaves as expected and returns a platform with at least one device.

Don't hesitate if you have any questions,

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.