Skip to content

Commit f4968f8

Browse files
committed
Improve code consistency and add some comments
1 parent ccb6761 commit f4968f8

File tree

4 files changed

+96
-65
lines changed

4 files changed

+96
-65
lines changed

sycl/doc/extensions/supported/sycl_ext_intel_dataflow_pipes.asciidoc

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ A pipe type is a specialization of the pipe class:
110110

111111
[source,c++,Pipe type def,linenums]
112112
----
113-
template <typename name,
114-
typename dataT,
115-
size_t min_capacity = 0>
113+
template <typename _name,
114+
typename _dataT,
115+
size_t _min_capacity = 0>
116116
class pipe;
117117
----
118118

@@ -131,7 +131,7 @@ using pipe<class bar, float, 5>;
131131

132132
The interface of a pipe is through static member functions, and instances of a pipe class cannot be instantiated. Allowing instances of pipe objects, when their type defines connectivity, would introduce an error prone secondary mechanism of reference.
133133

134-
The first template parameter, `name`, can be any type, and is typically expected to be a user defined class in a user namespace. The type only needs to be forward declared, and not defined.
134+
The first template parameter, `_name`, can be any type, and is typically expected to be a user defined class in a user namespace. The type only needs to be forward declared, and not defined.
135135

136136
Above this basic mechanism of {cpp} type being used to identify a pipe, additional layers can be built on top to contain the type in an object that can be passed by value. Because such mechanisms (e.g. `boost::hana::type`) can layer on top of the fundamental type-based mechanism described here, those mechanisms are not included in the extension specification.
137137

@@ -166,37 +166,37 @@ myQueue.submit([&](handler& cgh) {
166166

167167
== Read/write member functions, and pipe template parameters
168168

169-
The pipe class exposes static member functions for writing a data word to a pipe, and for reading a data word from a pipe. A data word in this context is the data type that the pipe contains (`dataT` pipe template argument).
169+
The pipe class exposes static member functions for writing a data word to a pipe, and for reading a data word from a pipe. A data word in this context is the data type that the pipe contains (`_dataT` pipe template argument).
170170

171171
Blocking and non-blocking forms of the read and write members are defined, with the form chosen based on overload resolution.
172172

173173
[source,c++,Read write members,linenums]
174174
----
175-
template <typename name,
176-
typename dataT,
177-
size_t min_capacity = 0>
175+
template <typename _name,
176+
typename _dataT,
177+
size_t _min_capacity = 0>
178178
class pipe {
179179
// Blocking
180-
static dataT read();
181-
static void write( const dataT &data );
180+
static _dataT read();
181+
static void write( const _dataT &Data );
182182
183183
// Non-blocking
184-
static dataT read( bool &success_code );
185-
static void write( const dataT &data, bool &success_code );
184+
static _dataT read( bool &Success );
185+
static void write( const _dataT &Data, bool &Success );
186186
187187
// Static members
188-
using value_type = dataT;
189-
size_t min_capacity = min_capacity;
188+
using value_type = _dataT;
189+
size_t min_capacity = _min_capacity;
190190
}
191191
----
192192

193193
The read and write member functions may be invoked within device code, or within a SYCL host program. Some interfaces may not be available on all devices/implementations, but the pipe definition itself does not gate availability. Instead, implementations should error if an unsupported pipe is used. See section <<device_queries>> for information on querying the availability of specific pipe features relative to a device.
194194

195195
The template parameters of the device type are defined as:
196196

197-
* `name`: Type that is the basis of pipe identification. Typically a user-defined class, in a user namespace. Forward declaration of the type is sufficient, and the type does not need to be defined.
198-
* `dataT`: The type of data word/packet contained within a pipe. This is the data type that is read during a successful `pipe::read` operation, or written during a successful `pipe::write` operation. The type must be standard layout and trivially copyable. This template parameter can be queried by using the `value_type` type alias.
199-
* `min_capacity`: User defined minimum number of words in units of `dataT` that the pipe must be able to store without any being read out. A minimum capacity is required in some algorithms to avoid deadlock, or for performance tuning. An implementation can include more capacity than this parameter, but not less. This template parameter can be queried by using the `min_capacity` static member.
197+
* `_name`: Type that is the basis of pipe identification. Typically a user-defined class, in a user namespace. Forward declaration of the type is sufficient, and the type does not need to be defined.
198+
* `_dataT`: The type of data word/packet contained within a pipe. This is the data type that is read during a successful `pipe::read` operation, or written during a successful `pipe::write` operation. The type must be standard layout and trivially copyable. This template parameter can be queried by using the `value_type` type alias.
199+
* `_min_capacity`: User defined minimum number of words in units of `_dataT` that the pipe must be able to store without any being read out. A minimum capacity is required in some algorithms to avoid deadlock, or for performance tuning. An implementation can include more capacity than this parameter, but not less. This template parameter can be queried by using the `min_capacity` static member.
200200

201201
== Pipe types and {cpp} scope
202202

@@ -260,12 +260,12 @@ Pipes expose two additional static member functions that are available within ho
260260

261261
[source,c++,Read write members,linenums]
262262
----
263-
template <typename name,
264-
typename dataT,
265-
size_t min_capacity = 0>
263+
template <typename _name,
264+
typename _dataT,
265+
size_t _min_capacity = 0>
266266
class pipe {
267267
template <pipe_property::writeable host_writeable>
268-
static dataT* map(size_t requested_size, size_t &mapped_size);
268+
static _dataT* map(size_t requested_size, size_t &mapped_size);
269269
270270
static size_t unmap(T* mapped_ptr, size_t size_to_unmap);
271271
}
@@ -382,22 +382,22 @@ The pipe class described above exposes both read and write static member functio
382382

383383
[source,c++,iopipes,linenums]
384384
----
385-
template <typename name,
386-
typename dataT,
387-
size_t min_capacity = 0>
385+
template <typename _name,
386+
typename _dataT,
387+
size_t _min_capacity = 0>
388388
class kernel_readable_io_pipe {
389389
public:
390-
static dataT read(); // Blocking
391-
static dataT read( bool &success_code ); // Non-blocking
390+
static _dataT read(); // Blocking
391+
static _dataT read( bool &Success ); // Non-blocking
392392
};
393393
394-
template <typename name,
395-
typename dataT,
396-
size_t min_capacity = 0>
394+
template <typename _name,
395+
typename _dataT,
396+
size_t _min_capacity = 0>
397397
class kernel_writeable_io_pipe {
398398
public:
399-
static void write( dataT data ); // Blocking
400-
static void write( dataT data, bool &success_code ); // Non-blocking
399+
static void write( _dataT Data ); // Blocking
400+
static void write( _dataT Data, bool &Success ); // Non-blocking
401401
}
402402
----
403403

@@ -687,31 +687,31 @@ inline constexpr latency_constraint_key::value_t<Target, Type, Cycle>
687687
} // namespace sycl::ext::oneapi::experimental
688688
689689
namespace sycl::ext::intel::experimental {
690-
template <typename name,
691-
typename dataT,
692-
size_t min_capacity = 0>
690+
template <typename _name,
691+
typename _dataT,
692+
size_t _min_capacity = 0>
693693
class pipe {
694694
// Blocking
695-
static dataT read();
695+
static _dataT read();
696696
697697
template <typename _propertiesT>
698-
static dataT read( _propertiesT Properties );
698+
static _dataT read( _propertiesT Properties );
699699
700-
static void write( const dataT &data);
700+
static void write( const _dataT &Data);
701701
702702
template <typename _propertiesT>
703-
static void write( const dataT &data, _propertiesT Properties );
703+
static void write( const _dataT &Data, _propertiesT Properties );
704704
705705
// Non-blocking
706-
static dataT read( bool &success_code );
706+
static _dataT read( bool &Success );
707707
708708
template <typename _propertiesT>
709-
static dataT read( bool &success_code, _propertiesT Properties );
709+
static _dataT read( bool &Success, _propertiesT Properties );
710710
711-
static void write( const dataT &data, bool &success_code );
711+
static void write( const _dataT &Data, bool &Success );
712712
713713
template <typename _propertiesT>
714-
static void write( const dataT &data, bool &success_code, _propertiesT Properties );
714+
static void write( const _dataT &Data, bool &Success, _propertiesT Properties );
715715
}
716716
} // namespace sycl::ext::intel::experimental
717717
----

sycl/include/sycl/ext/intel/experimental/fpga_lsu.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ template <class... _mem_access_params> class lsu final {
5555
check_space<_space>();
5656
check_load();
5757
#if defined(__SYCL_DEVICE_ONLY__) && __has_builtin(__builtin_intel_fpga_mem)
58+
// Get latency control properties
5859
using _latency_anchor_id_prop =
5960
typename GetOrDefaultValT<_propertiesT,
6061
oneapi::experimental::latency_anchor_id_key,
@@ -63,13 +64,15 @@ template <class... _mem_access_params> class lsu final {
6364
typename GetOrDefaultValT<_propertiesT,
6465
oneapi::experimental::latency_constraint_key,
6566
defaultLatencyConstraintProperty>::type;
67+
68+
// Get latency control property values
6669
static constexpr int32_t _anchor_id = _latency_anchor_id_prop::value;
6770
static constexpr int32_t _target_anchor = _latency_constraint_prop::target;
6871
static constexpr oneapi::experimental::latency_control_type _control_type =
6972
_latency_constraint_prop::type;
7073
static constexpr int32_t _relative_cycle = _latency_constraint_prop::cycle;
7174

72-
int32_t _control_type_code = 0; // latency_control_type::none
75+
int32_t _control_type_code = 0; // latency_control_type::none is default
7376
if constexpr (_control_type ==
7477
oneapi::experimental::latency_control_type::exact) {
7578
_control_type_code = 1;
@@ -84,6 +87,7 @@ template <class... _mem_access_params> class lsu final {
8487
return *__latency_control_mem_wrapper((_T *)Ptr, _anchor_id, _target_anchor,
8588
_control_type_code, _relative_cycle);
8689
#else
90+
(void)Properties;
8791
return *Ptr;
8892
#endif
8993
}
@@ -99,6 +103,7 @@ template <class... _mem_access_params> class lsu final {
99103
check_space<_space>();
100104
check_store();
101105
#if defined(__SYCL_DEVICE_ONLY__) && __has_builtin(__builtin_intel_fpga_mem)
106+
// Get latency control properties
102107
using _latency_anchor_id_prop =
103108
typename GetOrDefaultValT<_propertiesT,
104109
oneapi::experimental::latency_anchor_id_key,
@@ -107,13 +112,15 @@ template <class... _mem_access_params> class lsu final {
107112
typename GetOrDefaultValT<_propertiesT,
108113
oneapi::experimental::latency_constraint_key,
109114
defaultLatencyConstraintProperty>::type;
115+
116+
// Get latency control property values
110117
static constexpr int32_t _anchor_id = _latency_anchor_id_prop::value;
111118
static constexpr int32_t _target_anchor = _latency_constraint_prop::target;
112119
static constexpr oneapi::experimental::latency_control_type _control_type =
113120
_latency_constraint_prop::type;
114121
static constexpr int32_t _relative_cycle = _latency_constraint_prop::cycle;
115122

116-
int32_t _control_type_code = 0; // latency_control_type::none
123+
int32_t _control_type_code = 0; // latency_control_type::none is default
117124
if constexpr (_control_type ==
118125
oneapi::experimental::latency_control_type::exact) {
119126
_control_type_code = 1;
@@ -128,6 +135,7 @@ template <class... _mem_access_params> class lsu final {
128135
*__latency_control_mem_wrapper((_T *)Ptr, _anchor_id, _target_anchor,
129136
_control_type_code, _relative_cycle) = Val;
130137
#else
138+
(void)Properties;
131139
*Ptr = Val;
132140
#endif
133141
}

sycl/include/sycl/ext/intel/experimental/fpga_utils.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ struct _GetValue {
9999
_T...>::value;
100100
};
101101

102+
// Get the specified property from the given compile-time property list. If
103+
// the property is not provided in the property list, get the default version of
104+
// this property.
102105
template <typename PropListT, typename PropKeyT, typename DefaultPropValT,
103106
typename = void>
104107
struct GetOrDefaultValT {
@@ -111,8 +114,12 @@ struct GetOrDefaultValT<
111114
using type = decltype(PropListT::template get_property<PropKeyT>());
112115
};
113116

117+
// Default latency_anchor_id property for latency control, indicating the
118+
// applied operation is not an anchor.
114119
using defaultLatencyAnchorIdProperty =
115120
oneapi::experimental::latency_anchor_id_key::value_t<-1>;
121+
// Default latency_constraint property for latency control, indicating the
122+
// applied operation is not a non-anchor.
116123
using defaultLatencyConstraintProperty =
117124
oneapi::experimental::latency_constraint_key::value_t<
118125
0, oneapi::experimental::latency_control_type::none, 0>;

0 commit comments

Comments
 (0)