throw error(CL_INVALID_PROPERTY);
}
+ const auto notify = (!pfn_notify ? context::notify_action() :
+ [=](const char *s) {
+ pfn_notify(s, NULL, 0, user_data);
+ });
+
ret_error(r_errcode, CL_SUCCESS);
- return desc(new context(props, devs));
+ return desc(new context(props, devs, notify));
} catch (error &e) {
ret_error(r_errcode, e);
using namespace clover;
context::context(const property_list &props,
- const ref_vector<device> &devs) :
- props(props), devs(devs) {
+ const ref_vector<device> &devs,
+ const notify_action ¬ify) :
+ notify(notify), props(props), devs(devs) {
}
bool
typedef clover::property_list<cl_context_properties> property_list;
public:
- context(const property_list &props, const ref_vector<device> &devs);
+ typedef std::function<void (const char *)> notify_action;
+
+ context(const property_list &props, const ref_vector<device> &devs,
+ const notify_action ¬ify);
context(const context &ctx) = delete;
context &
device_range
devices() const;
+ const notify_action notify;
+
private:
property_list props;
const std::vector<intrusive_ref<device>> devs;
#include "core/event.hpp"
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
+#include "pipe/p_state.h"
using namespace clover;
+namespace {
+ void
+ debug_notify_callback(void *data,
+ unsigned *id,
+ enum pipe_debug_type type,
+ const char *fmt,
+ va_list args) {
+ const command_queue *queue = (const command_queue *)data;
+ char buffer[1024];
+ vsnprintf(buffer, sizeof(buffer), fmt, args);
+ queue->context().notify(buffer);
+ }
+}
+
command_queue::command_queue(clover::context &ctx, clover::device &dev,
cl_command_queue_properties props) :
context(ctx), device(dev), props(props) {
pipe = dev.pipe->context_create(dev.pipe, NULL, PIPE_CONTEXT_COMPUTE_ONLY);
if (!pipe)
throw error(CL_INVALID_DEVICE);
+
+ if (ctx.notify) {
+ struct pipe_debug_callback cb = { &debug_notify_callback, this };
+ if (pipe->set_debug_callback)
+ pipe->set_debug_callback(pipe, &cb);
+ }
}
command_queue::~command_queue() {