Skip to content

Commit

Permalink
[SYCL][COMPAT] Extended device_info properties. (#13050)
Browse files Browse the repository at this point in the history
- Adds multiple properties to syclcompat's device_info class.
- Usage of `sycl::id` deprecated in favour of `sycl::range`.
- Refactored queue creation, implementation moved to a private method. 
- Device name truncated if it's name exceeds the maximum buffer size
(256 by default).

Minor:
- Updated format of device tests to match the current test style used
for other headers.
  • Loading branch information
Alcpz authored Apr 11, 2024
1 parent 92e2a76 commit d932fca
Show file tree
Hide file tree
Showing 4 changed files with 517 additions and 207 deletions.
57 changes: 44 additions & 13 deletions sycl/doc/syclcompat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,17 +681,18 @@ class device_info {
public:
const char *get_name();
char *get_name();
template <typename WorkItemSizesTy = sycl::id<3>,
template <typename WorkItemSizesTy = sycl::range<3>,
std::enable_if_t<std::is_same_v<WorkItemSizesTy, sycl::id<3>> ||
std::is_same_v<WorkItemSizesTy, int *>,
int> = 0>
auto get_max_work_item_sizes() const;
template <typename WorkItemSizesTy = sycl::id<3>,
template <typename WorkItemSizesTy = sycl::range<3>,
std::enable_if_t<std::is_same_v<WorkItemSizesTy, sycl::id<3>> ||
std::is_same_v<WorkItemSizesTy, int *>,
int> = 0>
auto get_max_work_item_sizes() const;
bool get_host_unified_memory() const;
int get_major_version() const;
int get_minor_version() const;
int get_integrated() const;
Expand All @@ -700,6 +701,7 @@ public:
int get_max_work_group_size() const;
int get_max_sub_group_size() const;
int get_max_work_items_per_compute_unit() const;
int get_max_register_size_per_work_group() const;
template <typename NDRangeSizeTy = size_t *,
std::enable_if_t<std::is_same_v<NDRangeSizeTy, size_t *> ||
std::is_same_v<NDRangeSizeTy, int *>,
Expand All @@ -713,8 +715,17 @@ public:
size_t get_global_mem_size() const;
size_t get_local_mem_size() const;
void set_name(const char *name);
void set_max_work_item_sizes(const sycl::id<3> max_work_item_sizes);
unsigned int get_memory_clock_rate() const;
unsigned int get_memory_bus_width() const;
uint32_t get_device_id() const;
std::array<unsigned char, 16> get_uuid() const;
unsigned int get_global_mem_cache_size() const;
void set_name(const char *name);
void set_max_work_item_sizes(const sycl::range<3> max_work_item_sizes);
[[deprecated]] void
set_max_work_item_sizes(const sycl::id<3> max_work_item_sizes);
void set_host_unified_memory(bool host_unified_memory);
void set_major_version(int major);
void set_minor_version(int minor);
void set_integrated(int integrated);
Expand All @@ -727,6 +738,13 @@ void set_name(const char *name);
void
set_max_work_items_per_compute_unit(int max_work_items_per_compute_unit);
void set_max_nd_range_size(int max_nd_range_size[]);
void set_memory_clock_rate(unsigned int memory_clock_rate);
void set_memory_bus_width(unsigned int memory_bus_width);
void
set_max_register_size_per_work_group(int max_register_size_per_work_group);
void set_device_id(uint32_t device_id);
void set_uuid(std::array<unsigned char, 16> uuid);
void set_global_mem_cache_size(unsigned int global_mem_cache_size);
};
```

Expand Down Expand Up @@ -797,6 +815,9 @@ destructor waits on a set of `sycl::event` which can be added to via
`add_event`. This is used, for example, to implement `syclcompat::free_async` to
schedule release of memory after a kernel or `mempcy`. SYCL device properties
can be queried through `device_ext` as well.
`device_ext` also provides the `has_capability_or_fail` member function, which
throws a `sycl::exception` if the device does not have the specified list of
`sycl::aspect`.
Users can manage queues through the `syclcompat::set_default_queue(sycl::queue q)`
free function, and the `device_ext` `set_saved_queue`, `set_default_queue`,
Expand All @@ -816,19 +837,26 @@ namespace syclcompat {
class device_ext : public sycl::device {
device_ext();
device_ext(const sycl::device &base);
device_ext(const sycl::device &base, bool print_on_async_exceptions = false,
bool in_order = true);
~device_ext();
bool is_native_host_atomic_supported();
int get_major_version();
int get_minor_version();
int get_max_compute_units();
int get_max_clock_frequency();
int get_integrated();
void get_device_info(device_info &out);
int get_major_version() const;
int get_minor_version() const;
int get_max_compute_units() const;
int get_max_clock_frequency() const;
int get_integrated() const;
int get_max_sub_group_size() const;
int get_max_register_size_per_work_group() const;
int get_max_work_group_size() const;
int get_mem_base_addr_align() const;
size_t get_global_mem_size() const;
void get_memory_info(size_t &free_memory, size_t &total_memory) const;
device_info get_device_info();
void reset();
void get_device_info(device_info &out) const;
device_info get_device_info() const;
void reset(bool print_on_async_exceptions = false, bool in_order = true);
sycl::queue *default_queue();
void set_default_queue(const sycl::queue &q);
Expand All @@ -839,6 +867,9 @@ class device_ext : public sycl::device {
void set_saved_queue(sycl::queue *q);
sycl::queue *get_saved_queue();
sycl::context get_context();
void
has_capability_or_fail(const std::initializer_list<sycl::aspect> &props) const;
};
} // syclcompat
Expand Down
Loading

0 comments on commit d932fca

Please sign in to comment.