summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/state_trackers/clover
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/gallium/state_trackers/clover')
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/Makefile.sources16
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/api/context.cpp7
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/api/event.cpp3
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/api/memory.cpp213
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/api/transfer.cpp30
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/api/util.hpp11
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/context.cpp5
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/context.hpp7
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/error.hpp13
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/event.cpp49
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/event.hpp4
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/format.cpp6
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/kernel.hpp1
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/memory.cpp2
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/object.hpp2
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/platform.cpp8
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/platform.hpp2
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/core/queue.cpp26
-rw-r--r--lib/mesa/src/gallium/state_trackers/clover/util/functional.hpp36
19 files changed, 129 insertions, 312 deletions
diff --git a/lib/mesa/src/gallium/state_trackers/clover/Makefile.sources b/lib/mesa/src/gallium/state_trackers/clover/Makefile.sources
index 38f94981f..10bbda02d 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/Makefile.sources
+++ b/lib/mesa/src/gallium/state_trackers/clover/Makefile.sources
@@ -13,6 +13,7 @@ CPP_SOURCES := \
api/sampler.cpp \
api/transfer.cpp \
api/util.hpp \
+ core/compiler.hpp \
core/context.cpp \
core/context.hpp \
core/device.cpp \
@@ -53,16 +54,7 @@ CPP_SOURCES := \
util/tuple.hpp
LLVM_SOURCES := \
- llvm/codegen/bitcode.cpp \
- llvm/codegen/common.cpp \
- llvm/codegen/native.cpp \
- llvm/codegen.hpp \
- llvm/compat.hpp \
- llvm/invocation.cpp \
- llvm/invocation.hpp \
- llvm/metadata.hpp \
- llvm/util.hpp
+ llvm/invocation.cpp
-SPIRV_SOURCES := \
- spirv/invocation.cpp \
- spirv/invocation.hpp
+TGSI_SOURCES := \
+ tgsi/compiler.cpp
diff --git a/lib/mesa/src/gallium/state_trackers/clover/api/context.cpp b/lib/mesa/src/gallium/state_trackers/clover/api/context.cpp
index c0cd2d32b..021eea36f 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/api/context.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/api/context.cpp
@@ -45,13 +45,8 @@ clCreateContext(const cl_context_properties *d_props, cl_uint num_devs,
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, notify));
+ return desc(new context(props, devs));
} catch (error &e) {
ret_error(r_errcode, e);
diff --git a/lib/mesa/src/gallium/state_trackers/clover/api/event.cpp b/lib/mesa/src/gallium/state_trackers/clover/api/event.cpp
index 3f89644d0..5d1a0e52c 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/api/event.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/api/event.cpp
@@ -126,8 +126,7 @@ clSetEventCallback(cl_event d_ev, cl_int type,
void *user_data) try {
auto &ev = obj(d_ev);
- if (!pfn_notify ||
- (type != CL_COMPLETE && type != CL_SUBMITTED && type != CL_RUNNING))
+ if (!pfn_notify || type != CL_COMPLETE)
throw error(CL_INVALID_VALUE);
// Create a temporary soft event that depends on ev, with
diff --git a/lib/mesa/src/gallium/state_trackers/clover/api/memory.cpp b/lib/mesa/src/gallium/state_trackers/clover/api/memory.cpp
index df4b9baa1..1efb95b5c 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/api/memory.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/api/memory.cpp
@@ -28,58 +28,37 @@
using namespace clover;
namespace {
- cl_mem_flags
- validate_flags(cl_mem d_parent, cl_mem_flags d_flags) {
- const cl_mem_flags dev_access_flags =
- CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY;
- const cl_mem_flags host_ptr_flags =
- CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR;
- const cl_mem_flags host_access_flags =
- CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS;
- const cl_mem_flags valid_flags =
- dev_access_flags | host_access_flags | (d_parent ? 0 : host_ptr_flags);
-
- if ((d_flags & ~valid_flags) ||
- util_bitcount(d_flags & dev_access_flags) > 1 ||
- util_bitcount(d_flags & host_access_flags) > 1)
+ const cl_mem_flags dev_access_flags =
+ CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY;
+ const cl_mem_flags host_ptr_flags =
+ CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR;
+ const cl_mem_flags host_access_flags =
+ CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS;
+ const cl_mem_flags all_mem_flags =
+ dev_access_flags | host_ptr_flags | host_access_flags;
+
+ void
+ validate_flags(cl_mem_flags flags, cl_mem_flags valid) {
+ if ((flags & ~valid) ||
+ util_bitcount(flags & dev_access_flags) > 1 ||
+ util_bitcount(flags & host_access_flags) > 1)
throw error(CL_INVALID_VALUE);
- if ((d_flags & CL_MEM_USE_HOST_PTR) &&
- (d_flags & (CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)))
+ if ((flags & CL_MEM_USE_HOST_PTR) &&
+ (flags & (CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)))
throw error(CL_INVALID_VALUE);
-
- if (d_parent) {
- const auto &parent = obj(d_parent);
- const cl_mem_flags flags = (d_flags |
- (d_flags & dev_access_flags ? 0 :
- parent.flags() & dev_access_flags) |
- (d_flags & host_access_flags ? 0 :
- parent.flags() & host_access_flags) |
- (parent.flags() & host_ptr_flags));
-
- if (~flags & parent.flags() & (dev_access_flags & ~CL_MEM_READ_WRITE))
- throw error(CL_INVALID_VALUE);
-
- // Check if new host access flags cause a mismatch between
- // host-read/write-only.
- if (!(flags & CL_MEM_HOST_NO_ACCESS) &&
- (~flags & parent.flags() & host_access_flags))
- throw error(CL_INVALID_VALUE);
-
- return flags;
-
- } else {
- return d_flags | (d_flags & dev_access_flags ? 0 : CL_MEM_READ_WRITE);
- }
}
}
CLOVER_API cl_mem
clCreateBuffer(cl_context d_ctx, cl_mem_flags d_flags, size_t size,
void *host_ptr, cl_int *r_errcode) try {
- const cl_mem_flags flags = validate_flags(NULL, d_flags);
+ const cl_mem_flags flags = d_flags |
+ (d_flags & dev_access_flags ? 0 : CL_MEM_READ_WRITE);
auto &ctx = obj(d_ctx);
+ validate_flags(d_flags, all_mem_flags);
+
if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR |
CL_MEM_COPY_HOST_PTR)))
throw error(CL_INVALID_HOST_PTR);
@@ -103,7 +82,16 @@ clCreateSubBuffer(cl_mem d_mem, cl_mem_flags d_flags,
cl_buffer_create_type op,
const void *op_info, cl_int *r_errcode) try {
auto &parent = obj<root_buffer>(d_mem);
- const cl_mem_flags flags = validate_flags(d_mem, d_flags);
+ const cl_mem_flags flags = d_flags |
+ (d_flags & dev_access_flags ? 0 : parent.flags() & dev_access_flags) |
+ (d_flags & host_access_flags ? 0 : parent.flags() & host_access_flags) |
+ (parent.flags() & host_ptr_flags);
+
+ validate_flags(d_flags, dev_access_flags | host_access_flags);
+
+ if (~flags & parent.flags() &
+ ((dev_access_flags & ~CL_MEM_READ_WRITE) | host_access_flags))
+ throw error(CL_INVALID_VALUE);
if (op == CL_BUFFER_CREATE_TYPE_REGION) {
auto reg = reinterpret_cast<const cl_buffer_region *>(op_info);
@@ -129,90 +117,35 @@ clCreateSubBuffer(cl_mem d_mem, cl_mem_flags d_flags,
}
CLOVER_API cl_mem
-clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
- const cl_image_format *format,
- const cl_image_desc *desc,
- void *host_ptr, cl_int *r_errcode) try {
+clCreateImage2D(cl_context d_ctx, cl_mem_flags d_flags,
+ const cl_image_format *format,
+ size_t width, size_t height, size_t row_pitch,
+ void *host_ptr, cl_int *r_errcode) try {
+ const cl_mem_flags flags = d_flags |
+ (d_flags & dev_access_flags ? 0 : CL_MEM_READ_WRITE);
auto &ctx = obj(d_ctx);
+ validate_flags(d_flags, all_mem_flags);
+
if (!any_of(std::mem_fn(&device::image_support), ctx.devices()))
throw error(CL_INVALID_OPERATION);
if (!format)
throw error(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
- if (!desc)
- throw error(CL_INVALID_IMAGE_DESCRIPTOR);
-
- if (desc->image_array_size == 0 &&
- (desc->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
- desc->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY))
- throw error(CL_INVALID_IMAGE_DESCRIPTOR);
-
- if (!host_ptr &&
- (desc->image_row_pitch || desc->image_slice_pitch))
- throw error(CL_INVALID_IMAGE_DESCRIPTOR);
-
- if (desc->num_mip_levels || desc->num_samples)
- throw error(CL_INVALID_IMAGE_DESCRIPTOR);
-
- if (bool(desc->buffer) != (desc->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER))
- throw error(CL_INVALID_IMAGE_DESCRIPTOR);
+ if (width < 1 || height < 1)
+ throw error(CL_INVALID_IMAGE_SIZE);
- if (bool(host_ptr) != bool(d_flags & (CL_MEM_USE_HOST_PTR |
- CL_MEM_COPY_HOST_PTR)))
+ if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR |
+ CL_MEM_COPY_HOST_PTR)))
throw error(CL_INVALID_HOST_PTR);
- const cl_mem_flags flags = validate_flags(desc->buffer, d_flags);
-
- if (!supported_formats(ctx, desc->image_type).count(*format))
+ if (!supported_formats(ctx, CL_MEM_OBJECT_IMAGE2D).count(*format))
throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
ret_error(r_errcode, CL_SUCCESS);
-
- switch (desc->image_type) {
- case CL_MEM_OBJECT_IMAGE2D:
- if (!desc->image_width || !desc->image_height)
- throw error(CL_INVALID_IMAGE_SIZE);
-
- if (all_of([=](const device &dev) {
- const size_t max = 1 << dev.max_image_levels_2d();
- return (desc->image_width > max ||
- desc->image_height > max);
- }, ctx.devices()))
- throw error(CL_INVALID_IMAGE_SIZE);
-
- return new image2d(ctx, flags, format,
- desc->image_width, desc->image_height,
- desc->image_row_pitch, host_ptr);
-
- case CL_MEM_OBJECT_IMAGE3D:
- if (!desc->image_width || !desc->image_height || !desc->image_depth)
- throw error(CL_INVALID_IMAGE_SIZE);
-
- if (all_of([=](const device &dev) {
- const size_t max = 1 << dev.max_image_levels_3d();
- return (desc->image_width > max ||
- desc->image_height > max ||
- desc->image_depth > max);
- }, ctx.devices()))
- throw error(CL_INVALID_IMAGE_SIZE);
-
- return new image3d(ctx, flags, format,
- desc->image_width, desc->image_height,
- desc->image_depth, desc->image_row_pitch,
- desc->image_slice_pitch, host_ptr);
-
- case CL_MEM_OBJECT_IMAGE1D:
- case CL_MEM_OBJECT_IMAGE1D_ARRAY:
- case CL_MEM_OBJECT_IMAGE1D_BUFFER:
- case CL_MEM_OBJECT_IMAGE2D_ARRAY:
- // XXX - Not implemented.
- throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
-
- default:
- throw error(CL_INVALID_IMAGE_DESCRIPTOR);
- }
+ return new image2d(ctx, flags, format, width, height,
+ row_pitch, host_ptr);
} catch (error &e) {
ret_error(r_errcode, e);
@@ -220,26 +153,40 @@ clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
}
CLOVER_API cl_mem
-clCreateImage2D(cl_context d_ctx, cl_mem_flags d_flags,
- const cl_image_format *format,
- size_t width, size_t height, size_t row_pitch,
- void *host_ptr, cl_int *r_errcode) {
- const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE2D, width, height, 0, 0,
- row_pitch, 0, 0, 0, NULL };
-
- return clCreateImage(d_ctx, d_flags, format, &desc, host_ptr, r_errcode);
-}
-
-CLOVER_API cl_mem
clCreateImage3D(cl_context d_ctx, cl_mem_flags d_flags,
const cl_image_format *format,
size_t width, size_t height, size_t depth,
size_t row_pitch, size_t slice_pitch,
- void *host_ptr, cl_int *r_errcode) {
- const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE3D, width, height, depth, 0,
- row_pitch, slice_pitch, 0, 0, NULL };
+ void *host_ptr, cl_int *r_errcode) try {
+ const cl_mem_flags flags = d_flags |
+ (d_flags & dev_access_flags ? 0 : CL_MEM_READ_WRITE);
+ auto &ctx = obj(d_ctx);
+
+ validate_flags(d_flags, all_mem_flags);
+
+ if (!any_of(std::mem_fn(&device::image_support), ctx.devices()))
+ throw error(CL_INVALID_OPERATION);
+
+ if (!format)
+ throw error(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
+
+ if (width < 1 || height < 1 || depth < 2)
+ throw error(CL_INVALID_IMAGE_SIZE);
+
+ if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR |
+ CL_MEM_COPY_HOST_PTR)))
+ throw error(CL_INVALID_HOST_PTR);
- return clCreateImage(d_ctx, d_flags, format, &desc, host_ptr, r_errcode);
+ if (!supported_formats(ctx, CL_MEM_OBJECT_IMAGE3D).count(*format))
+ throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
+
+ ret_error(r_errcode, CL_SUCCESS);
+ return new image3d(ctx, flags, format, width, height, depth,
+ row_pitch, slice_pitch, host_ptr);
+
+} catch (error &e) {
+ ret_error(r_errcode, e);
+ return NULL;
}
CLOVER_API cl_int
@@ -249,7 +196,7 @@ clGetSupportedImageFormats(cl_context d_ctx, cl_mem_flags flags,
auto &ctx = obj(d_ctx);
auto formats = supported_formats(ctx, type);
- validate_flags(NULL, flags);
+ validate_flags(flags, all_mem_flags);
if (r_buf && !r_count)
throw error(CL_INVALID_VALUE);
@@ -405,6 +352,16 @@ clSetMemObjectDestructorCallback(cl_mem d_mem,
return e.get();
}
+CLOVER_API cl_mem
+clCreateImage(cl_context d_ctx, cl_mem_flags flags,
+ const cl_image_format *format,
+ const cl_image_desc *image_desc,
+ void *host_ptr, cl_int *r_errcode) {
+ CLOVER_NOT_SUPPORTED_UNTIL("1.2");
+ ret_error(r_errcode, CL_INVALID_OPERATION);
+ return NULL;
+}
+
CLOVER_API cl_int
clEnqueueFillBuffer(cl_command_queue command_queue, cl_mem buffer,
const void *pattern, size_t pattern_size,
diff --git a/lib/mesa/src/gallium/state_trackers/clover/api/transfer.cpp b/lib/mesa/src/gallium/state_trackers/clover/api/transfer.cpp
index 34559042a..f7046253b 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/api/transfer.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/api/transfer.cpp
@@ -295,9 +295,6 @@ clEnqueueReadBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
&mem, obj_origin, obj_pitch,
region));
- if (blocking)
- hev().wait_signalled();
-
ret_object(rd_ev, hev);
return CL_SUCCESS;
@@ -328,9 +325,6 @@ clEnqueueWriteBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
ptr, {}, obj_pitch,
region));
- if (blocking)
- hev().wait_signalled();
-
ret_object(rd_ev, hev);
return CL_SUCCESS;
@@ -368,9 +362,6 @@ clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
&mem, obj_origin, obj_pitch,
region));
- if (blocking)
- hev().wait_signalled();
-
ret_object(rd_ev, hev);
return CL_SUCCESS;
@@ -408,9 +399,6 @@ clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
ptr, host_origin, host_pitch,
region));
- if (blocking)
- hev().wait_signalled();
-
ret_object(rd_ev, hev);
return CL_SUCCESS;
@@ -516,9 +504,6 @@ clEnqueueReadImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
&img, src_origin, src_pitch,
region));
- if (blocking)
- hev().wait_signalled();
-
ret_object(rd_ev, hev);
return CL_SUCCESS;
@@ -553,9 +538,6 @@ clEnqueueWriteImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
ptr, {}, src_pitch,
region));
- if (blocking)
- hev().wait_signalled();
-
ret_object(rd_ev, hev);
return CL_SUCCESS;
@@ -685,11 +667,7 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
void *map = mem.resource(q).add_map(q, flags, blocking, obj_origin, region);
- auto hev = create<hard_event>(q, CL_COMMAND_MAP_BUFFER, deps);
- if (blocking)
- hev().wait_signalled();
-
- ret_object(rd_ev, hev);
+ ret_object(rd_ev, create<hard_event>(q, CL_COMMAND_MAP_BUFFER, deps));
ret_error(r_errcode, CL_SUCCESS);
return map;
@@ -717,11 +695,7 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
void *map = img.resource(q).add_map(q, flags, blocking, origin, region);
- auto hev = create<hard_event>(q, CL_COMMAND_MAP_IMAGE, deps);
- if (blocking)
- hev().wait_signalled();
-
- ret_object(rd_ev, hev);
+ ret_object(rd_ev, create<hard_event>(q, CL_COMMAND_MAP_IMAGE, deps));
ret_error(r_errcode, CL_SUCCESS);
return map;
diff --git a/lib/mesa/src/gallium/state_trackers/clover/api/util.hpp b/lib/mesa/src/gallium/state_trackers/clover/api/util.hpp
index 66bd12597..31e20e424 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/api/util.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/api/util.hpp
@@ -68,17 +68,6 @@ namespace clover {
*p = desc(v());
}
}
-
- ///
- /// Return an API object from an intrusive reference to a Clover object,
- /// incrementing the reference count of the object.
- ///
- template<typename T>
- typename T::descriptor_type *
- ret_object(const intrusive_ref<T> &v) {
- v().retain();
- return desc(v());
- }
}
#endif
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/context.cpp b/lib/mesa/src/gallium/state_trackers/clover/core/context.cpp
index c3e208293..bf4df39dc 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/context.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/context.cpp
@@ -25,9 +25,8 @@
using namespace clover;
context::context(const property_list &props,
- const ref_vector<device> &devs,
- const notify_action &notify) :
- notify(notify), props(props), devs(devs) {
+ const ref_vector<device> &devs) :
+ props(props), devs(devs) {
}
bool
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/context.hpp b/lib/mesa/src/gallium/state_trackers/clover/core/context.hpp
index 7b22ccae7..0ec4ff4a2 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/context.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/context.hpp
@@ -36,10 +36,7 @@ namespace clover {
typedef clover::property_list<cl_context_properties> property_list;
public:
- typedef std::function<void (const char *)> notify_action;
-
- context(const property_list &props, const ref_vector<device> &devs,
- const notify_action &notify);
+ context(const property_list &props, const ref_vector<device> &devs);
context(const context &ctx) = delete;
context &
@@ -56,8 +53,6 @@ namespace clover {
device_range
devices() const;
- const notify_action notify;
-
private:
property_list props;
const std::vector<intrusive_ref<device>> devs;
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/error.hpp b/lib/mesa/src/gallium/state_trackers/clover/core/error.hpp
index 0490c19a2..59a5af4c7 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/error.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/error.hpp
@@ -65,16 +65,11 @@ namespace clover {
cl_int code;
};
- class invalid_build_options_error : public error {
+ class compile_error : public error {
public:
- invalid_build_options_error(const std::string &what = "") :
- error(CL_INVALID_BUILD_OPTIONS, what) {}
- };
-
- class build_error : public error {
- public:
- build_error(const std::string &what = "") :
- error(CL_BUILD_PROGRAM_FAILURE, what) {}
+ compile_error(const std::string &what = "") :
+ error(CL_COMPILE_PROGRAM_FAILURE, what) {
+ }
};
template<typename O>
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/event.cpp b/lib/mesa/src/gallium/state_trackers/clover/core/event.cpp
index 3d313ce89..d75b83977 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/event.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/event.cpp
@@ -27,7 +27,7 @@ using namespace clover;
event::event(clover::context &ctx, const ref_vector<event> &deps,
action action_ok, action action_fail) :
- context(ctx), _wait_count(1), _status(0),
+ context(ctx), wait_count(1), _status(0),
action_ok(action_ok), action_fail(action_fail) {
for (auto &ev : deps)
ev.chain(*this);
@@ -41,22 +41,23 @@ event::trigger_self() {
std::lock_guard<std::mutex> lock(mutex);
std::vector<intrusive_ref<event>> evs;
- if (_wait_count && !--_wait_count)
+ if (!--wait_count)
std::swap(_chain, evs);
- cv.notify_all();
return evs;
}
void
-event::trigger() try {
- if (wait_count() == 1)
+event::trigger() {
+ auto evs = trigger_self();
+
+ if (signalled()) {
action_ok(*this);
+ cv.notify_all();
+ }
- for (event &ev : trigger_self())
+ for (event &ev : evs)
ev.trigger();
-} catch (error &e) {
- abort(e.get());
}
std::vector<intrusive_ref<event>>
@@ -65,30 +66,25 @@ event::abort_self(cl_int status) {
std::vector<intrusive_ref<event>> evs;
_status = status;
- _wait_count = 0;
std::swap(_chain, evs);
- cv.notify_all();
return evs;
}
void
event::abort(cl_int status) {
+ auto evs = abort_self(status);
+
action_fail(*this);
- for (event &ev : abort_self(status))
+ for (event &ev : evs)
ev.abort(status);
}
-unsigned
-event::wait_count() const {
- std::lock_guard<std::mutex> lock(mutex);
- return _wait_count;
-}
-
bool
event::signalled() const {
- return !wait_count();
+ std::lock_guard<std::mutex> lock(mutex);
+ return !wait_count;
}
cl_int
@@ -103,25 +99,20 @@ event::chain(event &ev) {
std::unique_lock<std::mutex> lock_ev(ev.mutex, std::defer_lock);
std::lock(lock, lock_ev);
- if (_wait_count) {
- ev._wait_count++;
+ if (wait_count) {
+ ev.wait_count++;
_chain.push_back(ev);
}
ev.deps.push_back(*this);
}
void
-event::wait_signalled() const {
- std::unique_lock<std::mutex> lock(mutex);
- cv.wait(lock, [=]{ return !_wait_count; });
-}
-
-void
event::wait() const {
for (event &ev : deps)
ev.wait();
- wait_signalled();
+ std::unique_lock<std::mutex> lock(mutex);
+ cv.wait(lock, [=]{ return !wait_count; });
}
hard_event::hard_event(command_queue &q, cl_command_type command,
@@ -150,7 +141,7 @@ hard_event::status() const {
else if (!_fence)
return CL_QUEUED;
- else if (!screen->fence_finish(screen, NULL, _fence, 0))
+ else if (!screen->fence_finish(screen, _fence, 0))
return CL_SUBMITTED;
else
@@ -177,7 +168,7 @@ hard_event::wait() const {
queue()->flush();
if (!_fence ||
- !screen->fence_finish(screen, NULL, _fence, PIPE_TIMEOUT_INFINITE))
+ !screen->fence_finish(screen, _fence, PIPE_TIMEOUT_INFINITE))
throw error(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
}
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/event.hpp b/lib/mesa/src/gallium/state_trackers/clover/core/event.hpp
index 03c97bcf4..6469e483c 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/event.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/event.hpp
@@ -69,7 +69,6 @@ namespace clover {
virtual cl_int status() const;
virtual command_queue *queue() const = 0;
virtual cl_command_type command() const = 0;
- void wait_signalled() const;
virtual void wait() const;
virtual struct pipe_fence_handle *fence() const {
@@ -86,9 +85,8 @@ namespace clover {
private:
std::vector<intrusive_ref<event>> trigger_self();
std::vector<intrusive_ref<event>> abort_self(cl_int status);
- unsigned wait_count() const;
- unsigned _wait_count;
+ unsigned wait_count;
cl_int _status;
action action_ok;
action action_fail;
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/format.cpp b/lib/mesa/src/gallium/state_trackers/clover/core/format.cpp
index dee1872c8..aee1cc9c7 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/format.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/format.cpp
@@ -147,12 +147,14 @@ namespace clover {
std::set<cl_image_format> s;
pipe_texture_target target = translate_target(type);
unsigned bindings = (PIPE_BIND_SAMPLER_VIEW |
- PIPE_BIND_COMPUTE_RESOURCE);
+ PIPE_BIND_COMPUTE_RESOURCE |
+ PIPE_BIND_TRANSFER_READ |
+ PIPE_BIND_TRANSFER_WRITE);
for (auto f : formats) {
if (all_of([=](const device &dev) {
return dev.pipe->is_format_supported(
- dev.pipe, f.second, target, 1, 1, bindings);
+ dev.pipe, f.second, target, 1, bindings);
}, ctx.devices()))
s.insert(f.first);
}
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/kernel.hpp b/lib/mesa/src/gallium/state_trackers/clover/core/kernel.hpp
index 5d46854d6..4ba6ff467 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/kernel.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/kernel.hpp
@@ -93,7 +93,6 @@ namespace clover {
/// Free any resources that were allocated in bind().
virtual void unbind(exec_context &ctx) = 0;
- virtual ~argument() {};
protected:
argument();
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/memory.cpp b/lib/mesa/src/gallium/state_trackers/clover/core/memory.cpp
index ed13d92c2..b852e6896 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/memory.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/memory.cpp
@@ -22,7 +22,7 @@
#include "core/memory.hpp"
#include "core/resource.hpp"
-#include "util/format/u_format.h"
+#include "util/u_format.h"
using namespace clover;
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/object.hpp b/lib/mesa/src/gallium/state_trackers/clover/core/object.hpp
index 8fc2175d2..e3a5ab7fa 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/object.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/object.hpp
@@ -51,7 +51,7 @@ namespace clover {
"ICD requires CL API objects to be standard layout.");
}
- const cl_icd_dispatch *dispatch;
+ const _cl_icd_dispatch *dispatch;
};
struct default_tag;
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/platform.cpp b/lib/mesa/src/gallium/state_trackers/clover/core/platform.cpp
index ddd63fc5a..328b71cdc 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/platform.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/platform.cpp
@@ -32,15 +32,9 @@ platform::platform() : adaptor_range(evals(), devs) {
for (pipe_loader_device *ldev : ldevs) {
try {
- if (ldev)
- devs.push_back(create<device>(*this, ldev));
+ devs.push_back(create<device>(*this, ldev));
} catch (error &) {
pipe_loader_release(&ldev, 1);
}
}
}
-
-std::string
-platform::supported_extensions() const {
- return "cl_khr_icd";
-}
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/platform.hpp b/lib/mesa/src/gallium/state_trackers/clover/core/platform.hpp
index b94434c98..e849645bb 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/platform.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/platform.hpp
@@ -40,8 +40,6 @@ namespace clover {
platform &
operator=(const platform &platform) = delete;
- std::string supported_extensions() const;
-
protected:
std::vector<intrusive_ref<device>> devs;
};
diff --git a/lib/mesa/src/gallium/state_trackers/clover/core/queue.cpp b/lib/mesa/src/gallium/state_trackers/clover/core/queue.cpp
index c91b97ad1..87f9dcc64 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/core/queue.cpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/core/queue.cpp
@@ -24,39 +24,15 @@
#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);
+ pipe = dev.pipe->context_create(dev.pipe, NULL);
if (!pipe)
throw error(CL_INVALID_DEVICE);
-
- if (ctx.notify) {
- struct pipe_debug_callback cb;
- memset(&cb, 0, sizeof(cb));
- cb.debug_message = &debug_notify_callback;
- cb.data = this;
- if (pipe->set_debug_callback)
- pipe->set_debug_callback(pipe, &cb);
- }
}
command_queue::~command_queue() {
diff --git a/lib/mesa/src/gallium/state_trackers/clover/util/functional.hpp b/lib/mesa/src/gallium/state_trackers/clover/util/functional.hpp
index fc281c5c7..ed69155c4 100644
--- a/lib/mesa/src/gallium/state_trackers/clover/util/functional.hpp
+++ b/lib/mesa/src/gallium/state_trackers/clover/util/functional.hpp
@@ -311,27 +311,6 @@ namespace clover {
}
};
- template<typename T>
- class equals_t {
- public:
- equals_t(T &&x) : x(x) {}
-
- template<typename S>
- bool
- operator()(S &&y) const {
- return x == y;
- }
-
- private:
- T x;
- };
-
- template<typename T>
- equals_t<T>
- equals(T &&x) {
- return { std::forward<T>(x) };
- }
-
class name_equals {
public:
name_equals(const std::string &name) : name(name) {
@@ -347,21 +326,6 @@ namespace clover {
const std::string &name;
};
- class id_equals {
- public:
- id_equals(const uint32_t id) : id(id) {
- }
-
- template<typename T>
- bool
- operator()(const T &x) const {
- return x.id == id;
- }
-
- private:
- const uint32_t id;
- };
-
template<typename T>
class key_equals_t {
public: