clover: Define a few convenience equality operators.
Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
@@ -40,7 +40,7 @@ clGetDeviceIDs(cl_platform_id d_platform, cl_device_type device_type,
|
||||
// Collect matching devices
|
||||
for (device &dev : platform) {
|
||||
if (((device_type & CL_DEVICE_TYPE_DEFAULT) &&
|
||||
&dev == &platform.front()) ||
|
||||
dev == platform.front()) ||
|
||||
(device_type & dev.type()))
|
||||
d_devs.push_back(desc(dev));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ clWaitForEvents(cl_uint num_evs, const cl_event *d_evs) try {
|
||||
auto evs = objs(d_evs, num_evs);
|
||||
|
||||
for (auto &ev : evs) {
|
||||
if (&ev.ctx != &evs.front().ctx)
|
||||
if (ev.ctx != evs.front().ctx)
|
||||
throw error(CL_INVALID_CONTEXT);
|
||||
|
||||
if (ev.status() < 0)
|
||||
@@ -199,7 +199,7 @@ clEnqueueWaitForEvents(cl_command_queue d_q, cl_uint num_evs,
|
||||
auto evs = objs(d_evs, num_evs);
|
||||
|
||||
for (auto &ev : evs) {
|
||||
if (&ev.ctx != &q.ctx)
|
||||
if (ev.ctx != q.ctx)
|
||||
throw error(CL_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,9 +202,9 @@ namespace {
|
||||
void
|
||||
validate_common(command_queue &q, kernel &kern,
|
||||
const ref_vector<event> &deps) {
|
||||
if (&kern.prog.ctx != &q.ctx ||
|
||||
if (kern.prog.ctx != q.ctx ||
|
||||
any_of([&](const event &ev) {
|
||||
return &ev.ctx != &q.ctx;
|
||||
return ev.ctx != q.ctx;
|
||||
}, deps))
|
||||
throw error(CL_INVALID_CONTEXT);
|
||||
|
||||
|
||||
@@ -36,6 +36,16 @@ context::has_device(device &dev) const {
|
||||
return std::count(devs.begin(), devs.end(), &dev);
|
||||
}
|
||||
|
||||
bool
|
||||
context::operator==(const context &ctx) const {
|
||||
return this == &ctx;
|
||||
}
|
||||
|
||||
bool
|
||||
context::operator!=(const context &ctx) const {
|
||||
return this != &ctx;
|
||||
}
|
||||
|
||||
const context::property_list &
|
||||
context::props() const {
|
||||
return _props;
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace clover {
|
||||
|
||||
bool has_device(device &dev) const;
|
||||
|
||||
bool
|
||||
operator==(const context &ctx) const;
|
||||
bool
|
||||
operator!=(const context &ctx) const;
|
||||
|
||||
const property_list &
|
||||
props() const;
|
||||
|
||||
|
||||
@@ -68,6 +68,11 @@ device::operator=(device dev) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool
|
||||
device::operator==(const device &dev) const {
|
||||
return this == &dev;
|
||||
}
|
||||
|
||||
cl_device_type
|
||||
device::type() const {
|
||||
switch (ldev->type) {
|
||||
|
||||
@@ -44,6 +44,9 @@ namespace clover {
|
||||
|
||||
device &operator=(device dev);
|
||||
|
||||
bool
|
||||
operator==(const device &dev) const;
|
||||
|
||||
cl_device_type type() const;
|
||||
cl_uint vendor_id() const;
|
||||
size_t max_images_read() const;
|
||||
|
||||
@@ -48,4 +48,15 @@ operator<(const cl_image_format &a, const cl_image_format &b) {
|
||||
a.image_channel_data_type < b.image_channel_data_type);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
operator==(const cl_image_format &a, const cl_image_format &b) {
|
||||
return (a.image_channel_order == b.image_channel_order &&
|
||||
a.image_channel_data_type == b.image_channel_data_type);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
operator!=(const cl_image_format &a, const cl_image_format &b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,6 +38,11 @@ memory_obj::~memory_obj() {
|
||||
_destroy_notify();
|
||||
}
|
||||
|
||||
bool
|
||||
memory_obj::operator==(const memory_obj &obj) const {
|
||||
return this == &obj;
|
||||
}
|
||||
|
||||
void
|
||||
memory_obj::destroy_notify(std::function<void ()> f) {
|
||||
_destroy_notify = f;
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace clover {
|
||||
public:
|
||||
virtual ~memory_obj();
|
||||
|
||||
bool
|
||||
operator==(const memory_obj &obj) const;
|
||||
|
||||
virtual cl_mem_object_type type() const = 0;
|
||||
virtual clover::resource &resource(command_queue &q) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user