Skip to content

Commit d932fca

Browse files
authored
[SYCL][COMPAT] Extended device_info properties. (#13050)
- 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.
1 parent 92e2a76 commit d932fca

File tree

4 files changed

+517
-207
lines changed

4 files changed

+517
-207
lines changed

sycl/doc/syclcompat/README.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -681,17 +681,18 @@ class device_info {
681681
public:
682682
const char *get_name();
683683
char *get_name();
684-
template <typename WorkItemSizesTy = sycl::id<3>,
684+
template <typename WorkItemSizesTy = sycl::range<3>,
685685
std::enable_if_t<std::is_same_v<WorkItemSizesTy, sycl::id<3>> ||
686686
std::is_same_v<WorkItemSizesTy, int *>,
687687
int> = 0>
688688
auto get_max_work_item_sizes() const;
689689
690-
template <typename WorkItemSizesTy = sycl::id<3>,
690+
template <typename WorkItemSizesTy = sycl::range<3>,
691691
std::enable_if_t<std::is_same_v<WorkItemSizesTy, sycl::id<3>> ||
692692
std::is_same_v<WorkItemSizesTy, int *>,
693693
int> = 0>
694694
auto get_max_work_item_sizes() const;
695+
bool get_host_unified_memory() const;
695696
int get_major_version() const;
696697
int get_minor_version() const;
697698
int get_integrated() const;
@@ -700,6 +701,7 @@ public:
700701
int get_max_work_group_size() const;
701702
int get_max_sub_group_size() const;
702703
int get_max_work_items_per_compute_unit() const;
704+
int get_max_register_size_per_work_group() const;
703705
template <typename NDRangeSizeTy = size_t *,
704706
std::enable_if_t<std::is_same_v<NDRangeSizeTy, size_t *> ||
705707
std::is_same_v<NDRangeSizeTy, int *>,
@@ -713,8 +715,17 @@ public:
713715
size_t get_global_mem_size() const;
714716
size_t get_local_mem_size() const;
715717
716-
void set_name(const char *name);
717-
void set_max_work_item_sizes(const sycl::id<3> max_work_item_sizes);
718+
unsigned int get_memory_clock_rate() const;
719+
unsigned int get_memory_bus_width() const;
720+
uint32_t get_device_id() const;
721+
std::array<unsigned char, 16> get_uuid() const;
722+
unsigned int get_global_mem_cache_size() const;
723+
724+
void set_name(const char *name);
725+
void set_max_work_item_sizes(const sycl::range<3> max_work_item_sizes);
726+
[[deprecated]] void
727+
set_max_work_item_sizes(const sycl::id<3> max_work_item_sizes);
728+
void set_host_unified_memory(bool host_unified_memory);
718729
void set_major_version(int major);
719730
void set_minor_version(int minor);
720731
void set_integrated(int integrated);
@@ -727,6 +738,13 @@ void set_name(const char *name);
727738
void
728739
set_max_work_items_per_compute_unit(int max_work_items_per_compute_unit);
729740
void set_max_nd_range_size(int max_nd_range_size[]);
741+
void set_memory_clock_rate(unsigned int memory_clock_rate);
742+
void set_memory_bus_width(unsigned int memory_bus_width);
743+
void
744+
set_max_register_size_per_work_group(int max_register_size_per_work_group);
745+
void set_device_id(uint32_t device_id);
746+
void set_uuid(std::array<unsigned char, 16> uuid);
747+
void set_global_mem_cache_size(unsigned int global_mem_cache_size);
730748
};
731749
```
732750

@@ -797,6 +815,9 @@ destructor waits on a set of `sycl::event` which can be added to via
797815
`add_event`. This is used, for example, to implement `syclcompat::free_async` to
798816
schedule release of memory after a kernel or `mempcy`. SYCL device properties
799817
can be queried through `device_ext` as well.
818+
`device_ext` also provides the `has_capability_or_fail` member function, which
819+
throws a `sycl::exception` if the device does not have the specified list of
820+
`sycl::aspect`.
800821
801822
Users can manage queues through the `syclcompat::set_default_queue(sycl::queue q)`
802823
free function, and the `device_ext` `set_saved_queue`, `set_default_queue`,
@@ -816,19 +837,26 @@ namespace syclcompat {
816837
817838
class device_ext : public sycl::device {
818839
device_ext();
819-
device_ext(const sycl::device &base);
840+
device_ext(const sycl::device &base, bool print_on_async_exceptions = false,
841+
bool in_order = true);
820842
~device_ext();
821843
822844
bool is_native_host_atomic_supported();
823-
int get_major_version();
824-
int get_minor_version();
825-
int get_max_compute_units();
826-
int get_max_clock_frequency();
827-
int get_integrated();
828-
void get_device_info(device_info &out);
845+
int get_major_version() const;
846+
int get_minor_version() const;
847+
int get_max_compute_units() const;
848+
int get_max_clock_frequency() const;
849+
int get_integrated() const;
850+
int get_max_sub_group_size() const;
851+
int get_max_register_size_per_work_group() const;
852+
int get_max_work_group_size() const;
853+
int get_mem_base_addr_align() const;
854+
size_t get_global_mem_size() const;
855+
void get_memory_info(size_t &free_memory, size_t &total_memory) const;
829856
830-
device_info get_device_info();
831-
void reset();
857+
void get_device_info(device_info &out) const;
858+
device_info get_device_info() const;
859+
void reset(bool print_on_async_exceptions = false, bool in_order = true);
832860
833861
sycl::queue *default_queue();
834862
void set_default_queue(const sycl::queue &q);
@@ -839,6 +867,9 @@ class device_ext : public sycl::device {
839867
void set_saved_queue(sycl::queue *q);
840868
sycl::queue *get_saved_queue();
841869
sycl::context get_context();
870+
871+
void
872+
has_capability_or_fail(const std::initializer_list<sycl::aspect> &props) const;
842873
};
843874
844875
} // syclcompat

0 commit comments

Comments
 (0)