Skip to content

Commit

Permalink
Add host accessors for pipes
Browse files Browse the repository at this point in the history
This is a SYCL extension.
  • Loading branch information
keryell committed Jun 14, 2018
1 parent 26ccc0d commit 6e5565f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ class accessor<DataType, 1, AccessMode, access::target::blocking_pipe> :
: accessor_detail { p.implementation, command_group_handler } { }


/** Construct a pipe accessor from a pipe outside of a normal
kernel, for example in host code
*/
accessor(pipe<DataType> &p)
: accessor_detail { p.implementation } { }


/// Make a reservation inside the pipe
pipe_reservation<accessor> reserve(std::size_t size) const {
return accessor_detail::reserve(size);
Expand Down
14 changes: 11 additions & 3 deletions include/CL/sycl/pipe/detail/pipe_accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ class pipe_accessor :

/** Construct a pipe accessor from an existing pipe
*/
pipe_accessor(const std::shared_ptr<detail::pipe<T>> &p,
handler &command_group_handler) :
implementation { p } {
pipe_accessor(const std::shared_ptr<detail::pipe<T>> &p)
: implementation { p } {
// TRISYCL_DUMP_T("Create a kernel pipe accessor write = "
// << is_write_access());
// Verify that the pipe is not already used in the requested mode
Expand All @@ -100,6 +99,15 @@ class pipe_accessor :
}


/** Construct a pipe accessor from an existing pipe
For now the handler is not used.
*/
pipe_accessor(const std::shared_ptr<detail::pipe<T>> &p,
handler &command_group_handler)
: pipe_accessor(p) {}


pipe_accessor() = default;


Expand Down
19 changes: 19 additions & 0 deletions include/CL/sycl/static_pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ class static_pipe
}


/** Get an accessor to the pipe with the required mode, outside of a
normal kernel, for example in host code
\param Mode is the requested access mode
\param Target is the type of pipe access required
*/
template <access::mode Mode,
access::target Target = access::target::pipe>
accessor<value_type, 1, Mode, Target>
get_access() {
static_assert(Target == access::target::pipe
|| Target == access::target::blocking_pipe,
"get_access(handler) with pipes can only deal with "
"access::pipe or access::blocking_pipe");
return { implementation };
}


/** Return the maximum number of elements that can fit in the pipe
This is a constexpr since the capacity is in the type.
Expand Down

0 comments on commit 6e5565f

Please sign in to comment.