Skip to content

Commit 6b2d66b

Browse files
[SYCL][Doc] Update SYCL_INTEL_data_flow_pipes extension for FPGA host… (#8789)
A continuation of #5838. Accompanying runtime change is #7468. Add a memory order parameter to device-side read/write members and default to sycl::memory_order::seq_cst. This parameter is in place but not being used at this moment, it's intended for the future work. Add host pipe read/write members with additional sycl::queue parameter. --------- Co-authored-by: Steffen Larsen <steffen.larsen@intel.com>
1 parent ea1d240 commit 6b2d66b

File tree

1 file changed

+86
-8
lines changed

1 file changed

+86
-8
lines changed

sycl/doc/extensions/supported/sycl_ext_intel_dataflow_pipes.asciidoc

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This document describes an extension that adds pipes to SYCL. Pipes are first i
3131

3232
== Notice
3333

34-
Copyright (c) 2019-2021 Intel Corporation. All rights reserved.
34+
Copyright (c) 2019-2023 Intel Corporation. All rights reserved.
3535

3636
== Status
3737

@@ -49,10 +49,25 @@ Revision: 3
4949
== Contact
5050
Michael Kinsner, Intel (michael 'dot' kinsner 'at' intel 'dot' com)
5151

52+
== Contributors
53+
54+
Michael Kinsner, Intel +
55+
Shuo Niu, Intel +
56+
Bo Lei, Intel +
57+
Marco Jacques, Intel +
58+
Joe Garvey, Intel +
59+
Aditi Kumaraswamy, Intel +
60+
Robert Ho, Intel +
61+
Sherry Yuan, Intel +
62+
Peter Colberg, Intel +
63+
Zibai Wang, Intel
64+
5265
== Dependencies
5366

5467
This extension is written against the SYCL 2020 specification, Revision 3.
5568

69+
It also depends on the `sycl_ext_oneapi_properties` extension.
70+
5671
The use of blocking pipe reads or writes requires support for https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/INTEL/SPV_INTEL_blocking_pipes.asciidoc[SPV_INTEL_blocking_pipes] if SPIR-V is used by an implementation.
5772

5873
== Overview
@@ -183,7 +198,7 @@ class pipe {
183198
// Non-blocking
184199
static DataT read( bool &Success );
185200
static void write( const DataT &Data, bool &Success );
186-
201+
187202
// Static members
188203
using value_type = DataT;
189204
size_t min_capacity = MinCapacity;
@@ -644,15 +659,15 @@ Automated mechanisms are possible to provide uniquification across calls, and co
644659

645660
The Intel FPGA experimental `pipe` class is implemented in `sycl/ext/intel/experimental/pipes.hpp` which is included in `sycl/ext/intel/fpga_extensions.hpp`.
646661

647-
In the experimental API version, read/write methods take in a property list as function argument, which can contain the latency control properties `latency_anchor_id` and/or `latency_constraint`.
662+
In the experimental API version, the device side read/write methods take in a property list as function argument, which can contain the latency control properties `latency_anchor_id` and/or `latency_constraint`.
648663

649664
* `sycl::ext::intel::experimental::latency_anchor_id<N>`, where `N` is an integer: An ID to associate with the current read/write function call, which can then be referenced by other `latency_constraint` properties elsewhere in the program to define relative latency constaints. ID must be unique within the application, and a diagnostic is required if that condition is not met.
650665
* `sycl::ext::intel::experimental::latency_constraint<A, B, C>`: A tuple of three values which cause the current read/write function call to act as an endpoint of a latency constraint relative to a specified `latency_anchor_id` defined by a different instruction.
651666
** `A` is an integer: The ID of the target anchor defined on a different instruction through a `latency_anchor_id` property.
652667
** `B` is an enum value: The type of control from the set {`latency_control_type::exact`, `latency_control_type::max`, `latency_control_type::min`}.
653668
** `C` is an integer: The relative clock cycle difference between the target anchor and the current function call, that the constraint should infer subject to the type of the control (exact, max, min).
654669

655-
=== Synopsis
670+
=== Device side pipe read/write
656671

657672
[source,c++]
658673
----
@@ -687,9 +702,8 @@ template <int Target, latency_control_type Type, int Cycle>
687702
inline constexpr latency_constraint_key::value_t<Target, Type, Cycle>
688703
latency_constraint;
689704
690-
template <typename Name,
691-
typename DataT,
692-
size_t MinCapacity = 0>
705+
template <class Name, class DataT, int32_t MinCapacity = 0,
706+
class PropertiesT = decltype(oneapi::experimental::properties{})>
693707
class pipe {
694708
// Blocking
695709
static DataT read();
@@ -716,7 +730,7 @@ class pipe {
716730
} // namespace sycl::ext::intel::experimental
717731
----
718732

719-
=== Usage
733+
=== Latency Control example
720734

721735
[source,c++]
722736
----
@@ -748,6 +762,69 @@ myQueue.submit([&](handler &cgh) {
748762
});
749763
----
750764

765+
== Host Side pipe read/write
766+
767+
If the read/write member functions of a pipe are called from the host side, a `sycl::queue` is added to the parameters. The `memory_order` parameter is also added to the parameters for future work.
768+
769+
[source,c++,Host pipe read write members,linenums]
770+
----
771+
template <class Name, class DataT, int32_t MinCapacity = 0,
772+
class PropertiesT = decltype(oneapi::experimental::properties{})>
773+
class pipe {
774+
// Blocking
775+
static _dataT read(queue &Q, memory_order Order = memory_order::seq_cst);
776+
static void write(queue &Q, const _dataT &Data, memory_order Order = memory_order::seq_cst);
777+
// Non-blocking
778+
static _dataT read(queue &Q, bool &Success, memory_order Order = memory_order::seq_cst);
779+
static void write(queue &Q, const _dataT &Data, bool &Success, memory_order Order = memory_order::seq_cst);
780+
}
781+
----
782+
783+
== Simple example of host-to-device write&read
784+
785+
[source,c++,First example,linenums]
786+
----
787+
using default_pipe_properties = decltype(sycl::ext::oneapi::experimental::properties(sycl::ext::intel::experimental::uses_valid<true>));
788+
789+
// Classes used to name the kernels
790+
class TestTask;
791+
class H2DPipeID;
792+
class D2HPipeID;
793+
794+
using H2DPipe = sycl::ext::intel::experimental::pipe<H2DPipeID, int, 10, default_pipe_properties>;
795+
using D2HPipe = sycl::ext::intel::experimental::pipe<D2HPipeID, int, 10, default_pipe_properties>;
796+
797+
struct BasicKernel {
798+
void operator()() const {
799+
auto a = H2DPipe::read();
800+
D2HPipe::write(a+1);
801+
}
802+
};
803+
804+
int main() {
805+
queue q(testconfig_selector{});
806+
H2DPipe::write(q, 1);
807+
808+
  q.submit([&](handler &h) {
809+
    h.single_task<TestTask>(BasicKernel{});
810+
  });
811+
auto b = D2HPipe::read(q);
812+
std::cout << b << std::endl; // It should print 2;
813+
}
814+
----
815+
816+
== Issues for experimental API
817+
818+
. Although the memory_order parameter hasn't been used in the implementation, the choice of seq_cst for the default value of the `sycl::memory_order` parameter of the read/write functions is still open for discussion. While seq_cst is more consistent with C++ atomics, it is a change from how pipes work today, which is equivalent to memory_order::relaxed. Another consideration is that SYCL 2020 atomic_ref uses a third approach where the default must be specified as a template parameter of the class itself.
819+
+
820+
--
821+
*RESOLUTION*: Not resolved. Still under discussion.
822+
--
823+
824+
== Future work
825+
826+
. In the future, the `sycl::memory_order` parameter of read/write functions will control how other memory accesses, including regular, non-atomic memory accesses, are to be ordered around the pipe read/write operation. The default memory order is `sycl::memory_order::seq_cst`. Currently, `sycl::memory_order` parameter is defined but not being used in the implementation.
827+
751828
== Feature test macro
752829

753830
This extension provides a feature-test macro as described in the core SYCL
@@ -776,6 +853,7 @@ extension's APIs the implementation supports.
776853
|2|2019-11-13|Michael Kinsner|Incorporate feedback
777854
|3|2020-04-27|Michael Kinsner|Clarify that pipe operations behave as-if they are relaxed atomic operations. Make SYCL2020 the baseline
778855
|4|2021-12-02|Shuo Niu|Add experimental latency control API
856+
|5|2023-03-27|Zibai Wang|Experimental API change only. Add memory order parameter and compile-time properties. Add host pipe read/write functions.
779857
|========================================
780858

781859
//************************************************************************

0 commit comments

Comments
 (0)