1111
1212
1313class Group :
14- """Analogue to the ``sycl::group`` type."""
14+ # pylint: disable=line-too-long
15+ """Analogue to the :sycl_group:`sycl::group <>` class.
16+
17+ Represents a particular work-group within a parallel execution and
18+ provides API to extract various properties of the work-group. An instance
19+ of the class is not user-constructible. Users should use
20+ :func:`numba_dpex.kernel_api.NdItem.get_group` to access the Group to which
21+ a work-item belongs.
22+ """
1523
1624 def __init__ (
1725 self ,
@@ -27,12 +35,20 @@ def __init__(
2735 self ._leader = False
2836
2937 def get_group_id (self , dim ):
30- """Returns the index of the work-group within the global nd-range for
31- specified dimension.
38+ """Returns a specific coordinate of the multi-dimensional index of a group.
3239
3340 Since the work-items in a work-group have a defined position within the
3441 global nd-range, the returned group id can be used along with the local
3542 id to uniquely identify the work-item in the global nd-range.
43+
44+ Args:
45+ dim (int): An integral value between (1..3) for which the group
46+ index is returned.
47+ Returns:
48+ int: The coordinate for the ``dim`` dimension for the group's
49+ multi-dimensional index within an nd-range.
50+ Raises:
51+ ValueError: If the ``dim`` argument is not in the (1..3) interval.
3652 """
3753 if dim > len (self ._index ) - 1 :
3854 raise ValueError (
@@ -41,7 +57,12 @@ def get_group_id(self, dim):
4157 return self ._index [dim ]
4258
4359 def get_group_linear_id (self ):
44- """Returns a linearized version of the work-group index."""
60+ """Returns a linearized version of the work-group index.
61+
62+ Returns:
63+ int: The linearized index for the group's position within an
64+ nd-range.
65+ """
4566 if self .dimensions == 1 :
4667 return self .get_group_id (0 )
4768 if self .dimensions == 2 :
@@ -59,28 +80,48 @@ def get_group_linear_id(self):
5980 )
6081
6182 def get_group_range (self , dim ):
62- """Returns a the extent of the range representing the number of groups
63- in the nd-range for a specified dimension.
83+ """Returns the extent of the range of groups in an nd-range for given dimension.
84+
85+ Args:
86+ dim (int): An integral value between (1..3) for which the group
87+ index is returned.
88+ Returns:
89+ int: The extent of group range for the specified dimension.
6490 """
6591 return self ._group_range [dim ]
6692
6793 def get_group_linear_range (self ):
68- """Return the total number of work-groups in the nd_range."""
94+ """Returns the total number of work-groups in the nd_range.
95+
96+ Returns:
97+ int: Returns the number of groups in a parallel execution of an
98+ nd-range kernel.
99+ """
69100 num_wg = 1
70101 for i in range (self .dimensions ):
71102 num_wg *= self .get_group_range (i )
72103
73104 return num_wg
74105
75106 def get_local_range (self , dim ):
76- """Returns the extent of the SYCL range representing all dimensions
77- of the local range for a specified dimension. This local range may
78- have been provided by the programmer, or chosen by the SYCL runtime.
107+ """Returns the extent of the range of work-items in a work-group for given dimension.
108+
109+ Args:
110+ dim (int): An integral value between (1..3) for which the group
111+ index is returned.
112+ Returns:
113+ int: The extent of the local work-item range for the specified
114+ dimension.
79115 """
80116 return self ._local_range [dim ]
81117
82118 def get_local_linear_range (self ):
83- """Return the total number of work-items in the work-group."""
119+ """Return the total number of work-items in the work-group.
120+
121+ Returns:
122+ int: Returns the linearized size of the local range inside an
123+ nd-range.
124+ """
84125 num_wi = 1
85126 for i in range (self .dimensions ):
86127 num_wi *= self .get_local_range (i )
@@ -89,24 +130,22 @@ def get_local_linear_range(self):
89130
90131 @property
91132 def leader (self ):
92- """Return true for exactly one work-item in the work-group, if the
93- calling work-item is the leader of the work-group, and false for all
94- other work-items in the work-group.
133+ """Return true if the caller work-item is the leader of the work-group.
95134
96135 The leader of the work-group is determined during construction of the
97136 work-group, and is invariant for the lifetime of the work-group. The
98137 leader of the work-group is guaranteed to be the work-item with a
99138 local id of 0.
100139
101-
102140 Returns:
103141 bool: If the work item is the designated leader of the
104142 """
105143 return self ._leader
106144
107145 @property
108146 def dimensions (self ) -> int :
109- """Returns the rank of a Group object.
147+ """Returns the dimensionality of the range to which the work-group belongs.
148+
110149 Returns:
111150 int: Number of dimensions in the Group object
112151 """
@@ -119,22 +158,21 @@ def leader(self, work_item_id):
119158
120159
121160class Item :
122- """Analogue to the `` sycl::item` ` class.
161+ """Analogue to the :sycl_item:` sycl::item <> ` class.
123162
124- Identifies an instance of the function object executing at each point in an
125- :class:`.Range`.
163+ Identifies the work-item in a parallel execution of a kernel launched with
164+ the :class:`.Range` index-space class .
126165 """
127166
128167 def __init__ (self , extent : Range , index : list ):
129168 self ._extent = extent
130169 self ._index = index
131170
132171 def get_linear_id (self ):
133- """Get the linear id associated with this item for all dimensions.
134- Original implementation could be found at ``sycl::item_base`` class.
172+ """Returns the linear id associated with this item for all dimensions.
135173
136174 Returns:
137- int: The linear id.
175+ int: The linear id of the work item in the global range .
138176 """
139177 if self .dimensions == 1 :
140178 return self .get_id (0 )
@@ -181,7 +219,7 @@ def dimensions(self) -> int:
181219
182220
183221class NdItem :
184- """Analogue to the `` sycl::nd_item` ` class.
222+ """Analogue to the :sycl_nditem:` sycl::nd_item <> ` class.
185223
186224 Identifies an instance of the function object executing at each point in an
187225 :class:`.NdRange`.
0 commit comments