Skip to content

Commit fe6230b

Browse files
committed
[SYCL][COMPAT] Addressed comments in #10774
- Added const variable: device name buffer size (device_info::NAME_BUFFER_SIZE). - get_major_version and get_minor_version calls follow the same convention as the other get_ functions. - Removed default handler when creating a queue with `print_on_async_exceptions` set to false. - device_fixt: .h -> .hpp - Removed non-existing friend function free_async. - Improved Readme.md with latest changes. - Fixed syclcompat include statement.
1 parent b4099c6 commit fe6230b

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

sycl/doc/syclcompat/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ through the main header, `syclcompat.hpp`. Note that `syclcompat.hpp` does not
5050
import the <sycl/sycl.hpp> header.
5151

5252
``` cpp
53-
#include <sycl/syclcompat.hpp>
53+
#include <syclcompat.hpp>
5454
```
5555

5656
This document presents the public API under the [Features](#features) section,
@@ -768,8 +768,8 @@ The exposed functionalities include creation and destruction of queues, through
768768
`syclcompat::create_queue` and `syclcompat::destroy_queue`, and providing the
769769
ability to wait for submitted kernels using `syclcompat::wait` or
770770
`syclcompat::wait_and_throw`. Any async errors will be output to `stderr` if
771-
`print_on_async_exceptions`. Synchronous exceptions have to be managed by users
772-
independently of what is set in this parameter.
771+
`print_on_async_exceptions`, and will have the default behavior otherwise, which calls `std:terminate`. Synchronous exceptions have to be managed
772+
by users independently of what is set in this parameter.
773773
774774
Devices are managed through a helper class, `device_ext`. The `device_ext` class
775775
associates a vector of `sycl::queues` with its `sycl::device`. The `device_ext`
@@ -1159,7 +1159,7 @@ using this library:
11591159
#include <cassert>
11601160
#include <iostream>
11611161
1162-
#include <sycl/syclcompat.hpp>
1162+
#include <syclcompat.hpp>
11631163
#include <sycl/sycl.hpp>
11641164
11651165
/**

sycl/include/syclcompat/device.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ class device_info {
143143
size_t get_global_mem_size() const { return _global_mem_size; }
144144
size_t get_local_mem_size() const { return _local_mem_size; }
145145
// set interface
146-
void set_name(const char *name) { std::strncpy(_name, name, 256); }
146+
void set_name(const char *name) {
147+
std::strncpy(_name, name, device_info::NAME_BUFFER_SIZE);
148+
}
147149
void set_max_work_item_sizes(const sycl::id<3> max_work_item_sizes) {
148150
_max_work_item_sizes = max_work_item_sizes;
149151
for (int i = 0; i < 3; ++i)
@@ -180,7 +182,9 @@ class device_info {
180182
}
181183

182184
private:
183-
char _name[256];
185+
constexpr static size_t NAME_BUFFER_SIZE = 256;
186+
187+
char _name[device_info::NAME_BUFFER_SIZE];
184188
sycl::id<3> _max_work_item_sizes;
185189
int _max_work_item_sizes_i[3];
186190
int _major;
@@ -219,15 +223,11 @@ class device_ext : public sycl::device {
219223

220224
bool is_native_host_atomic_supported() { return 0; }
221225
int get_major_version() const {
222-
int major, minor;
223-
get_version(major, minor);
224-
return major;
226+
return get_device_info().get_major_version();
225227
}
226228

227229
int get_minor_version() const {
228-
int major, minor;
229-
get_version(major, minor);
230-
return minor;
230+
return get_device_info().get_minor_version();
231231
}
232232

233233
int get_max_compute_units() const {
@@ -324,15 +324,16 @@ class device_ext : public sycl::device {
324324
queue_ptr create_queue(bool print_on_async_exceptions = false,
325325
bool in_order = true) {
326326
std::lock_guard<std::mutex> lock(m_mutex);
327-
sycl::async_handler eh = {};
328327
sycl::property_list prop = {};
329-
if (print_on_async_exceptions) {
330-
eh = detail::exception_handler;
331-
}
332328
if (in_order) {
333329
prop = {sycl::property::queue::in_order()};
334330
}
335-
_queues.push_back(std::make_shared<sycl::queue>(_ctx, *this, eh, prop));
331+
if (print_on_async_exceptions) {
332+
_queues.push_back(std::make_shared<sycl::queue>(
333+
_ctx, *this, detail::exception_handler, prop));
334+
} else {
335+
_queues.push_back(std::make_shared<sycl::queue>(_ctx, *this, prop));
336+
}
336337
return _queues.back().get();
337338
}
338339
void destroy_queue(queue_ptr &queue) {
@@ -388,8 +389,6 @@ class device_ext : public sycl::device {
388389
std::lock_guard<std::mutex> lock(m_mutex);
389390
_events.push_back(event);
390391
}
391-
friend sycl::event free_async(const std::vector<void *> &,
392-
const std::vector<sycl::event> &, sycl::queue);
393392
queue_ptr _default_queue;
394393
queue_ptr _saved_queue;
395394
sycl::context _ctx;

sycl/test-e2e/syclcompat/device/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#include <syclcompat/device.hpp>
3636

37-
#include "device_fixt.h"
37+
#include "device_fixt.hpp"
3838

3939
int main() {
4040
/*

sycl/test-e2e/syclcompat/device/device_threaded.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#include <syclcompat/device.hpp>
3838

39-
#include "device_fixt.h"
39+
#include "device_fixt.hpp"
4040

4141
int main() {
4242
// Check a thread is able to select a non-default device

0 commit comments

Comments
 (0)