Skip to content

Commit 59cd3bd

Browse files
author
Diptorup Deb
committed
Documentation changes.
1 parent 3d2b6b5 commit 59cd3bd

3 files changed

Lines changed: 116 additions & 36 deletions

File tree

‎dpctl-capi/include/dpctl_sycl_device_interface.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ bool DPCTLDevice_IsHostUnifiedMemory(
225225
* @brief Checks if two DPCTLSyclDeviceRef objects point to the same
226226
* sycl::device.
227227
*
228-
* @param DevRef1 First opaque pointer to the sycl device.
229-
* @param DevRef2 Second opaque pointer to the sycl device.
228+
* @param DevRef1 First opaque pointer to a sycl device.
229+
* @param DevRef2 Second opaque pointer to a sycl device.
230230
* @return True if the underlying sycl::device are same, false otherwise.
231231
*/
232232
DPCTL_API

‎dpctl-capi/include/dpctl_sycl_device_manager.h‎

Lines changed: 113 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
//===----------------------------------------------------------------------===//
2020
///
2121
/// \file
22-
/// Declarations for helper functions to access sycl devices.
22+
/// This file declares a set of helper functions to query about the available
23+
/// SYCL devices and backends on the system.
2324
///
2425
//===----------------------------------------------------------------------===//
2526

@@ -33,9 +34,13 @@
3334

3435
DPCTL_C_EXTERN_C_BEGIN
3536

37+
/**
38+
* @defgroup DeviceManager Device management helper functions
39+
*/
40+
3641
/*!
37-
* @brief
38-
*
42+
* @brief Contains a #DPCTLSyclDeviceRef and #DPCTLSyclContextRef 2-tuple that
43+
* contains a sycl::device and a sycl::context associated with that device.
3944
*/
4045
typedef struct DeviceAndContextPair
4146
{
@@ -44,85 +49,156 @@ typedef struct DeviceAndContextPair
4449
} DPCTL_DeviceAndContextPair;
4550

4651
/*!
47-
* @brief
52+
* @brief Checks if two ::DPCTLSyclDeviceRef objects point to the same
53+
* sycl::device.
4854
*
49-
* @param DRef1 My Param doc
50-
* @param DRef2 My Param doc
51-
* @return {return} My Param doc
52-
* @return {return} My Param doc
55+
* DPC++ 2021.1.2 has some bugs that prevent the equality of sycl::device
56+
* objects to work correctly. The DPCTLDeviceMgr_AreEq implements a workaround
57+
* to check if two sycl::device pointers are equivalent. Since, DPC++ uses
58+
* std::shared_pointer wrappers for sycl::device objects we check if the raw
59+
* pointer (shared_pointer.get()) for each device are the same. One caveat is
60+
* that the trick works only for non-host devices. The function evaluates host
61+
* devices separately and always assumes that all host devices are equivalent,
62+
* while checking for the raw pointer equivalent for all other types of devices.
63+
* The workaround will be removed once DPC++ is fixed to correctly check device
64+
* equivalence.
65+
*
66+
* @param DRef1 First opaque pointer to a sycl device.
67+
* @param DRef2 Second opaque pointer to a sycl device.
68+
* @return True if the underlying sycl::device are same, false otherwise.
69+
* @ingroup DeviceManager
5370
*/
5471
bool DPCTLDeviceMgr_AreEq(__dpctl_keep const DPCTLSyclDeviceRef DRef1,
5572
__dpctl_keep const DPCTLSyclDeviceRef DRef2);
5673

5774
/*!
58-
* @brief
75+
* @brief Returns an opaque pointer to an empty std::vector<DPCTLSyclDeviceRef>
76+
* object.
77+
*
78+
* The function is useful whenever we want to create a std::vector of
79+
* sycl::device objects in the C API and then pass the vector to another
80+
* function. An example is the constructor of sycl::context class that creates a
81+
* sycl context for a std::vector of sycl::device objects. Using an opaque
82+
* pointer to an std::vector<DPCTLSyclDeviceRef> object makes it easy to use the
83+
* container in languages such as Cython that can access C++ types. It allows us
84+
* to pass through the collection of device objects without having to create a
85+
* specialized list or array. The DPCTLDeviceVectorRef needs to be only
86+
* reinterpret_cast into a std::vector and accessed. The
87+
* DPCTLDeviceMgr_DeleteDeviceVector() or DPCTLDeviceMgr_DeleteDeviceVectorAll()
88+
* functions should be used to free the ::DPCTLDeviceVectorRef.
5989
*
60-
* @return {return} My Param doc
90+
* @return An opaque pointer to a std::vector<DPCTLSyclDeviceRef> container.
91+
* The ownership of both the vector and the ::DPCTLSyclDeviceRef elements of the
92+
* vector are passed to the caller.
93+
* @ingroup DeviceManager
6194
*/
6295
DPCTL_API
6396
__dpctl_give DPCTLDeviceVectorRef DPCTLDeviceMgr_CreateDeviceVector();
6497

6598
/*!
66-
* @brief
99+
* @brief Frees a pointer to a std::vector<sycl::backend>.
67100
*
68-
* @param BVRef My Param doc
69-
* @return {return} My Param doc
101+
* @param BVRef The std::vector<sycl::backend>* that is to be freed.
102+
* @ingroup DeviceManager
70103
*/
71104
DPCTL_API
72105
void DPCTLDeviceMgr_DeleteBackendVector(
73106
__dpctl_take DPCTLBackendVectorRef BVRef);
74107

75108
/*!
76-
* @brief
109+
* @brief Frees a pointer to a std::vector<sycl::DPCTLSyclDeviceRef> but does
110+
* not free the elements of the vector.
77111
*
78-
* @param DVRef My Param doc
79-
* @return {return} My Param doc
112+
* @param DVRef Opaque pointer to a
113+
* std::vector<sycl::DPCTLSyclDeviceRef>.
114+
* @ingroup DeviceManager
80115
*/
81116
DPCTL_API
82117
void DPCTLDeviceMgr_DeleteDeviceVector(__dpctl_take DPCTLDeviceVectorRef DVRef);
83118

84119
/*!
85-
* @brief
120+
* @brief Frees a pointer to a std::vector<sycl::DPCTLSyclDeviceRef> and all
121+
* the elements of the vector.
86122
*
87-
* @param DVRef My Param doc
88-
* @return {return} My Param doc
123+
* @param DVRef Opaque pointer to a
124+
* std::vector<sycl::DPCTLSyclDeviceRef>.
125+
* @ingroup DeviceManager
89126
*/
90127
DPCTL_API
91128
void DPCTLDeviceMgr_DeleteDeviceVectorAll(
92129
__dpctl_take DPCTLDeviceVectorRef DVRef);
93130

94131
/*!
95-
* @brief
132+
* @brief Returns an opaque pointer wrapping a std::vector<syc::backend>
133+
* container that has a list of all the unique backends available on the system.
96134
*
97-
* @return {return} My Param doc
135+
* @return A pointer to a std::vector<syc::backend> storing the list of unique
136+
* sycl::backend available on the system. Note that a single backend can contain
137+
* multiple types of devices, *e.g.* the opencl backend.
138+
* @ingroup DeviceManager
98139
*/
99140
DPCTL_API
100141
__dpctl_give DPCTLBackendVectorRef DPCTLDeviceMgr_GetBackends();
101142

102143
/*!
103-
* @brief
144+
* @brief Returns a pointer to a std::vector<sycl::DPCTLSyclDeviceRef>
145+
* containing the set of ::DPCTLSyclDeviceRef pointers matching the passed in
146+
* device_identifier bit flag.
147+
*
148+
* The device_identifier can be a combination of #DPCTLSyclBackendType and
149+
* #DPCTLSyclDeviceType bit flags. The function returns all devices that
150+
* match the specified bit flags. For example,
151+
*
152+
* @code
153+
* // Returns all opencl devices
154+
* DPCTLDeviceMgr_GetDevices(DPCTLSyclBackendType::DPCTL_OPENCL);
155+
*
156+
* // Returns all opencl gpu devices
157+
* DPCTLDeviceMgr_GetDevices(
158+
* DPCTLSyclBackendType::DPCTL_OPENCL|DPCTLSyclDeviceType::DPCTL_GPU);
159+
*
160+
* // Returns all gpu devices
161+
* DPCTLDeviceMgr_GetDevices(DPCTLSyclDeviceType::DPCTL_GPU);
162+
* @endcode
104163
*
105-
* @param device_identifier My Param doc
106-
* @return {return} My Param doc
164+
* @param device_identifier A bitflag that can be any combination of
165+
* #DPCTLSyclBackendType and #DPCTLSyclDeviceType
166+
* enum values.
167+
* @return A #DPCTLDeviceVectorRef containing #DPCTLSyclDeviceRef objects
168+
* that match the device identifier bit flags.
169+
* @ingroup DeviceManager
107170
*/
108171
DPCTL_API
109172
__dpctl_give DPCTLDeviceVectorRef
110173
DPCTLDeviceMgr_GetDevices(int device_identifier);
111174

112175
/*!
113-
* @brief
176+
* @brief Returns the default sycl context inside an opaque DPCTLSyclContextRef
177+
* pointer for the DPCTLSyclDeviceRef input argument.
114178
*
115-
* @param DRef My Param doc
116-
* @return {return} My Param doc
179+
* @param DRef A pointer to a sycl::device that will be used to
180+
* search an internal map containing a cached "default"
181+
* sycl::context for the device.
182+
* @return A #DPCTL_DeviceAndContextPair struct containing the cached
183+
* #DPCTLSyclContextRef associated with the #DPCTLSyclDeviceRef argument passed
184+
* to the function. The DPCTL_DeviceAndContextPair also contains a
185+
* #DPCTLSyclDeviceRef pointer pointing to the same device as the input
186+
* #DPCTLSyclDeviceRef. The returned #DPCTLSyclDeviceRef was cached along with
187+
* the #DPCTLSyclContextRef. This is a workaround till device equality is
188+
* properly fixed in DPC++. If the #DPCTLSyclDeviceRef is not found in the cache
189+
* then DPCTL_DeviceAndContextPair contains a pair of nullptr.
190+
* @ingroup DeviceManager
117191
*/
118192
DPCTL_API
119193
DPCTL_DeviceAndContextPair DPCTLDeviceMgr_GetDeviceAndContextPair(
120194
__dpctl_keep const DPCTLSyclDeviceRef DRef);
121195

122196
/*!
123-
* @brief
197+
* @brief Returns the number of unique sycl::backend available on the system
124198
*
125-
* @return {return} My Param doc
199+
* @return The number of unique sycl::backend on the system. Note
200+
* that a single backend can have multiple type of devices (e.g. OpenCL).
201+
* @ingroup DeviceManager
126202
*/
127203
DPCTL_API
128204
size_t DPCTLDeviceMgr_GetNumBackends();
@@ -132,18 +208,22 @@ size_t DPCTLDeviceMgr_GetNumBackends();
132208
* combination.
133209
*
134210
* @param device_identifier Identifies a device using a combination of
135-
* DPCTLSyclBackendType and DPCTLSyclDeviceType
211+
* #DPCTLSyclBackendType and #DPCTLSyclDeviceType
136212
* enum values. The argument can be either one of
137213
* the enum values or a bitwise OR-ed combination.
138-
* @return The number of available queues.
214+
* @return The number of available devices satisfying the condition specified
215+
* by the device_identifier bit flag.
216+
* @ingroup DeviceManager
139217
*/
140218
DPCTL_API
141219
size_t DPCTLDeviceMgr_GetNumDevices(int device_identifier);
142220

143221
/*!
144-
* @brief Prints out some of the info::deivice attributes for the device.
222+
* @brief Prints out the info::deivice attributes for the device that are
223+
* currently supported by dpCtl.
145224
*
146-
* @param DRef A DPCTLSyclDeviceRef pointer.
225+
* @param DRef A #DPCTLSyclDeviceRef opaque pointer.
226+
* @ingroup DeviceManager
147227
*/
148228
DPCTL_API
149229
void DPCTLDeviceMgr_PrintDeviceInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef);

‎dpctl-capi/include/dpctl_sycl_device_selector_interface.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
DPCTL_C_EXTERN_C_BEGIN
3535

3636
/**
37-
* \defgroup DeviceSelectors C API for SYCL Device Selectors
37+
* @defgroup DeviceSelectors C API for sycl::device_selector classess.
3838
*/
3939

4040
/*!

0 commit comments

Comments
 (0)