Skip to content

Commit 9786c2d

Browse files
committed
Fix version query; misc style fixes
1 parent cb6bca2 commit 9786c2d

File tree

6 files changed

+31
-54
lines changed

6 files changed

+31
-54
lines changed

offload/new-api/API/APIDefs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class AddPointerChecksToReturns<list<Param> Params, list<Return> Returns> {
133133
}
134134

135135
defvar DefaultReturns = [Return<PREFIX#"_RESULT_SUCCESS">,
136-
Return<PREFIX#"_RESULT_ERROR_UNINITIALIZED">,
137-
Return<PREFIX#"_RESULT_ERROR_DEVICE_LOST">];
136+
Return<PREFIX#"_ERRC_UNINITIALIZED">,
137+
Return<PREFIX#"_ERRC_DEVICE_LOST">];
138138

139139
class APIObject {
140140
string name;

offload/new-api/API/Device.td

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def : Function {
4949
let desc = "Retrieves devices within a platform";
5050
let details = [
5151
"Multiple calls to this function will return identical device handles, in the same order.",
52-
"The application may call this function from simultaneous threads, the implementation must be thread-safe"
5352
];
5453
let params = [
5554
Param<"offload_platform_handle_t", "Platform", "handle of the platform instance", PARAM_IN>,
@@ -68,10 +67,7 @@ def : Function {
6867
def : Function {
6968
let name = "offloadDeviceGetInfo";
7069
let desc = "Queries the given property of the device";
71-
let details = [
72-
"The application may call this function from simultaneous threads.",
73-
"The implementation of this function should be lock-free."
74-
];
70+
let details = [];
7571
let params = [
7672
Param<"offload_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
7773
Param<"offload_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
@@ -95,10 +91,7 @@ def : Function {
9591
def : Function {
9692
let name = "offloadDeviceGetInfoSize";
9793
let desc = "Returns the storage size of the given device query";
98-
let details = [
99-
"The application may call this function from simultaneous threads.",
100-
"The implementation of this function should be lock-free."
101-
];
94+
let details = [];
10295
let params = [
10396
Param<"offload_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
10497
Param<"offload_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,

offload/new-api/API/Platform.td

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ def : Function {
7272
let details = [
7373
"`offloadPlatformGetInfoSize` can be used to query the storage size "
7474
"required for the given query."
75-
"The application may call this function from simultaneous threads.",
76-
"The implementation of this function should be lock-free."
7775
];
7876
let params = [
7977
Param<"offload_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
@@ -99,10 +97,7 @@ def : Function {
9997
def : Function {
10098
let name = "offloadPlatformGetInfoSize";
10199
let desc = "Returns the storage size of the given platform query";
102-
let details = [
103-
"The application may call this function from simultaneous threads.",
104-
"The implementation of this function should be lock-free."
105-
];
100+
let details = [];
106101
let params = [
107102
Param<"offload_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
108103
Param<"offload_platform_info_t", "PropName", "type of the info to query", PARAM_IN>,

offload/new-api/API/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ When a new entry point is added (e.g. `offloadDeviceFoo`), the actual entry
147147
point is automatically generated, which contains validation and tracing code.
148148
It expects an implementation function (`offloadDeviceFoo_impl`) to be defined,
149149
which it will call into. The definition of this implementation function should
150-
be added to `src/offload_impl.cpp`
150+
be added to `src/offload_impl.cpp`

offload/new-api/include/offload_api.h

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ typedef struct offload_code_location_t {
165165
///
166166
/// @returns
167167
/// - ::OFFLOAD_RESULT_SUCCESS
168-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
169-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
168+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
169+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
170170
/// - ::OFFLOAD_ERRC_INVALID_NULL_HANDLE
171171
/// - ::OFFLOAD_ERRC_INVALID_NULL_POINTER
172172
OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadInit();
@@ -181,8 +181,8 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadInit();
181181
///
182182
/// @returns
183183
/// - ::OFFLOAD_RESULT_SUCCESS
184-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
185-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
184+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
185+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
186186
/// - ::OFFLOAD_ERRC_INVALID_NULL_HANDLE
187187
/// - ::OFFLOAD_ERRC_INVALID_NULL_POINTER
188188
OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadShutDown();
@@ -196,8 +196,8 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadShutDown();
196196
///
197197
/// @returns
198198
/// - ::OFFLOAD_RESULT_SUCCESS
199-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
200-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
199+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
200+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
201201
/// - ::OFFLOAD_ERRC_INVALID_SIZE
202202
/// + `NumEntries == 0`
203203
/// - ::OFFLOAD_ERRC_INVALID_NULL_HANDLE
@@ -219,8 +219,8 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadPlatformGet(
219219
///
220220
/// @returns
221221
/// - ::OFFLOAD_RESULT_SUCCESS
222-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
223-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
222+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
223+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
224224
/// - ::OFFLOAD_ERRC_INVALID_NULL_HANDLE
225225
/// - ::OFFLOAD_ERRC_INVALID_NULL_POINTER
226226
/// + `NULL == NumPlatforms`
@@ -268,14 +268,12 @@ typedef enum offload_platform_backend_t {
268268
///
269269
/// @details
270270
/// - `offloadPlatformGetInfoSize` can be used to query the storage size
271-
/// required for the given query.The application may call this function from
272-
/// simultaneous threads.
273-
/// - The implementation of this function should be lock-free.
271+
/// required for the given query.
274272
///
275273
/// @returns
276274
/// - ::OFFLOAD_RESULT_SUCCESS
277-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
278-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
275+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
276+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
279277
/// - ::OFFLOAD_ERRC_UNSUPPORTED_ENUMERATION
280278
/// + If `PropName` is not supported by the platform.
281279
/// - ::OFFLOAD_ERRC_INVALID_SIZE
@@ -304,13 +302,11 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadPlatformGetInfo(
304302
/// @brief Returns the storage size of the given platform query
305303
///
306304
/// @details
307-
/// - The application may call this function from simultaneous threads.
308-
/// - The implementation of this function should be lock-free.
309305
///
310306
/// @returns
311307
/// - ::OFFLOAD_RESULT_SUCCESS
312-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
313-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
308+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
309+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
314310
/// - ::OFFLOAD_ERRC_UNSUPPORTED_ENUMERATION
315311
/// + If `PropName` is not supported by the platform.
316312
/// - ::OFFLOAD_ERRC_INVALID_PLATFORM
@@ -369,8 +365,8 @@ typedef enum offload_device_info_t {
369365
///
370366
/// @returns
371367
/// - ::OFFLOAD_RESULT_SUCCESS
372-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
373-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
368+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
369+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
374370
/// - ::OFFLOAD_ERRC_INVALID_NULL_HANDLE
375371
/// + `NULL == Platform`
376372
/// - ::OFFLOAD_ERRC_INVALID_NULL_POINTER
@@ -387,13 +383,11 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadDeviceGetCount(
387383
/// @details
388384
/// - Multiple calls to this function will return identical device handles,
389385
/// in the same order.
390-
/// - The application may call this function from simultaneous threads, the
391-
/// implementation must be thread-safe
392386
///
393387
/// @returns
394388
/// - ::OFFLOAD_RESULT_SUCCESS
395-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
396-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
389+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
390+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
397391
/// - ::OFFLOAD_ERRC_INVALID_SIZE
398392
/// + `NumEntries == 0`
399393
/// - ::OFFLOAD_ERRC_INVALID_NULL_HANDLE
@@ -415,13 +409,11 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadDeviceGet(
415409
/// @brief Queries the given property of the device
416410
///
417411
/// @details
418-
/// - The application may call this function from simultaneous threads.
419-
/// - The implementation of this function should be lock-free.
420412
///
421413
/// @returns
422414
/// - ::OFFLOAD_RESULT_SUCCESS
423-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
424-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
415+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
416+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
425417
/// - ::OFFLOAD_ERRC_UNSUPPORTED_ENUMERATION
426418
/// + If `PropName` is not supported by the device.
427419
/// - ::OFFLOAD_ERRC_INVALID_SIZE
@@ -449,13 +441,11 @@ OFFLOAD_APIEXPORT offload_result_t OFFLOAD_APICALL offloadDeviceGetInfo(
449441
/// @brief Returns the storage size of the given device query
450442
///
451443
/// @details
452-
/// - The application may call this function from simultaneous threads.
453-
/// - The implementation of this function should be lock-free.
454444
///
455445
/// @returns
456446
/// - ::OFFLOAD_RESULT_SUCCESS
457-
/// - ::OFFLOAD_RESULT_ERROR_UNINITIALIZED
458-
/// - ::OFFLOAD_RESULT_ERROR_DEVICE_LOST
447+
/// - ::OFFLOAD_ERRC_UNINITIALIZED
448+
/// - ::OFFLOAD_ERRC_DEVICE_LOST
459449
/// - ::OFFLOAD_ERRC_UNSUPPORTED_ENUMERATION
460450
/// + If `PropName` is not supported by the device.
461451
/// - ::OFFLOAD_ERRC_INVALID_DEVICE

offload/new-api/src/offload_impl.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ offload_impl_result_t offloadInit_impl() {
8080
offload_impl_result_t offloadShutDown_impl() { return OFFLOAD_RESULT_SUCCESS; }
8181

8282
offload_impl_result_t offloadPlatformGetCount_impl(uint32_t *NumPlatforms) {
83-
// It is expected that offloadPlatformGet is the first function to be called.
84-
// In future it may make sense to have a specific entry point for Offload
85-
// initialization, or expose explicit initialization of plugins.
8683
*NumPlatforms = Platforms().size();
8784
return OFFLOAD_RESULT_SUCCESS;
8885
}
@@ -116,8 +113,10 @@ offload_impl_result_t offloadPlatformGetInfoImplDetail(
116113
// TODO: Implement this
117114
return ReturnValue("Unknown platform vendor");
118115
case OFFLOAD_PLATFORM_INFO_VERSION: {
119-
// TODO: Implement this
120-
return ReturnValue("v0.0.0");
116+
return ReturnValue(formatv("v{0}.{1}.{2}", OFFLOAD_VERSION_MAJOR,
117+
OFFLOAD_VERSION_MINOR, OFFLOAD_VERSION_PATCH)
118+
.str()
119+
.c_str());
121120
}
122121
case OFFLOAD_PLATFORM_INFO_BACKEND: {
123122
auto PluginName = Platform->Plugin->getName();

0 commit comments

Comments
 (0)