25 void test_queue(
const sham::DeviceScheduler_ptr &dev_sched,
sham::DeviceQueue &q) {
32 std::vector<u32> expected_acc = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
34 std::vector<u32> acc = b.copy_to_stdvec();
35 if (acc != expected_acc) {
39 "The chosen SYCL queue (name={}, device={}) cannot execute a basic kernel\n"
40 " expected acc = {}\n"
43 device.dev.get_info<sycl::info::device::name>(),
54 queues.push_back(std::make_unique<DeviceQueue>(
"main_queue",
ctx,
false));
73 void test_device_scheduler(
const sham::DeviceScheduler_ptr &dev_sched) {
74 for (
auto &q : dev_sched->
queues) {
79 std::string device_name = deviceref.
dev.get_info<sycl::info::device::name>();
81 std::exception_ptr eptr;
84 test_queue(dev_sched, qref);
86 "Backends",
"[Queue testing] name = ", device_name,
" -> working !");
88 eptr = std::current_exception();
93 "Backends",
"[Queue testing] name = ", device_name,
" -> not working !");
94 std::rethrow_exception(eptr);
98 logger::debug_ln(
"Backends",
"[Alloc testing] starting...");
106 ptr1024_dev.free_ptr();
109 ptr1024_host.free_ptr();
113 size_t GBval = 1024 * 1024 * 1024;
115 if (dev.prop.global_mem_size >
usize(3 * GBval)) {
117 if (dev.prop.max_mem_alloc_size_dev > 2 * GBval) {
121 ptr2G_dev.free_ptr();
122 }
catch (std::runtime_error &e) {
126 dev.dev.get_info<sycl::info::device::name>(),
127 " -> large device allocation (>2GB) not working !");
128 dev.prop.max_mem_alloc_size_dev =
i32_max;
132 if (dev.prop.max_mem_alloc_size_host > 2 * GBval) {
136 ptr2G_host.free_ptr();
137 }
catch (std::runtime_error &e) {
141 dev.dev.get_info<sycl::info::device::name>(),
142 " -> large host allocation (>2GB) not working !");
143 dev.prop.max_mem_alloc_size_host =
i32_max;
148 logger::debug_ln(
"Backends",
"[Alloc testing] done !");
std::uint32_t u32
32 bit unsigned integer
std::size_t usize
size_t alias
A buffer allocated in USM (Unified Shared Memory).
A class that represents a SYCL context.
std::shared_ptr< Device > device
A SYCL queue associated with a device and a context.
std::string queue_name
The name of this queue.
std::shared_ptr< DeviceContext > ctx
The device context of this queue.
bool in_order
Whether the queue is in order.
bool use_direct_comm()
Check if the context corresponding to the device scheduler should use direct communication.
DeviceScheduler(std::shared_ptr< DeviceContext > ctx)
Constructor.
std::shared_ptr< DeviceContext > ctx
Reference to the device context associated with this DeviceScheduler.
void print_info()
Print information about the DeviceScheduler.
DeviceQueue & get_queue(u32 id=0)
Get a reference to a DeviceQueue.
std::vector< std::unique_ptr< DeviceQueue > > queues
Vector of unique pointers to the DeviceQueues associated with this DeviceScheduler.
Represents a SYCL device.
sycl::device dev
The SYCL device object.
Class for holding a USM pointer.
static USMPtrHolder create(size_t sz, std::shared_ptr< DeviceScheduler > dev_sched, std::optional< size_t > alignment=std::nullopt)
Create a USM pointer holder.
This header file contains utility functions related to exception handling in the code.
namespace for backends this one is named only sham since shambackends is too long to write
void kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, u32 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
Submit a kernel to a SYCL queue.
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
constexpr i32 i32_max
i32 max value
void raw_ln(Types... var2)
Prints a log message with multiple arguments followed by a newline.
void debug_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
A class that references multiple buffers or similar objects.