Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions sycl/include/syclcompat/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ class device_ext : public sycl::device {
}

void get_device_info(device_info &out) const {
if (_dev_info) {
out = *_dev_info;
return;
}

std::lock_guard<std::mutex> lock(m_mutex);
device_info prop;
prop.set_name(get_info<sycl::info::device::name>().c_str());

Expand All @@ -439,8 +445,8 @@ class device_ext : public sycl::device {
// max_work_item_sizes is an enum class element
get_info<sycl::info::device::max_work_item_sizes>());
#else
// SYCL 2020-conformant code, max_work_item_sizes is a struct templated
// by an int
// SYCL 2020-conformant code, max_work_item_sizes is a struct
// templated by an int
get_info<sycl::info::device::max_work_item_sizes<3>>());
#endif
prop.set_host_unified_memory(has(sycl::aspect::usm_host_allocations));
Expand Down Expand Up @@ -512,8 +518,8 @@ Use 64 bits as memory_bus_width default value."
prop.set_max_nd_range_size(max_nd_range_size);
#endif

// Estimates max register size per work group, feel free to update the value
// according to device properties.
// Estimates max register size per work group, feel free to update the
// value according to device properties.
prop.set_max_register_size_per_work_group(65536);

prop.set_global_mem_cache_size(
Expand All @@ -526,13 +532,16 @@ Use 64 bits as memory_bus_width default value."
prop.set_image3d_max(get_info<sycl::info::device::image3d_max_width>(),
get_info<sycl::info::device::image3d_max_height>(),
get_info<sycl::info::device::image3d_max_height>());

_dev_info = prop;
out = prop;
}

device_info get_device_info() const {
device_info prop;
get_device_info(prop);
return prop;
if (!_dev_info) {
this->get_device_info(*_dev_info);
}
return _dev_info.value();
}

void reset(bool print_on_async_exceptions = false, bool in_order = true) {
Expand Down Expand Up @@ -683,6 +692,7 @@ Use 64 bits as memory_bus_width default value."
std::vector<std::shared_ptr<sycl::queue>> _queues;
mutable std::mutex m_mutex;
std::vector<sycl::event> _events;
mutable std::optional<device_info> _dev_info;
};

namespace detail {
Expand Down
11 changes: 9 additions & 2 deletions sycl/test-e2e/syclcompat/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,19 @@ void test_device_ext_api() {
auto major = dev_.get_major_version();
test_major_version(dev_, major);
dev_.get_minor_version();
dev_.get_max_compute_units();
dev_.get_max_clock_frequency();
dev_.get_integrated();

int max_cu = dev_.get_max_compute_units();
int max_wg_size = dev_.get_max_work_group_size();
size_t global_mem_size = dev_.get_global_mem_size();

syclcompat::device_info Info;
dev_.get_device_info(Info);
Info = dev_.get_device_info();
assert(Info.get_max_compute_units() == max_cu);
assert(Info.get_max_work_group_size() == max_wg_size);
assert(Info.get_global_mem_size() == global_mem_size);

dev_.reset();
auto QueuePtr = dev_.default_queue();
dev_.queues_wait_and_throw();
Expand Down