[llvm] [Offload] Add `const` to getInfo and calculateOptimalOccupancy (PR #157488)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 08:13:30 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Ross Brunton (RossBrunton)
<details>
<summary>Changes</summary>
These functions should not perform any mutation of the device state.
---
Full diff: https://github.com/llvm/llvm-project/pull/157488.diff
7 Files Affected:
- (modified) offload/liboffload/API/Device.td (+2-2)
- (modified) offload/liboffload/API/Event.td (+2-2)
- (modified) offload/liboffload/API/Kernel.td (+1-1)
- (modified) offload/liboffload/API/Platform.td (+2-2)
- (modified) offload/liboffload/API/Queue.td (+2-2)
- (modified) offload/liboffload/API/Symbol.td (+2-2)
- (modified) offload/liboffload/src/OffloadImpl.cpp (+25-21)
``````````diff
diff --git a/offload/liboffload/API/Device.td b/offload/liboffload/API/Device.td
index 5b54c79d83f9d..e3140659955d4 100644
--- a/offload/liboffload/API/Device.td
+++ b/offload/liboffload/API/Device.td
@@ -95,7 +95,7 @@ def olGetDeviceInfo : Function {
let desc = "Queries the given property of the device.";
let details = [];
let params = [
- Param<"ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
+ Param<"const ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
Param<"ol_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
Param<"size_t", "PropSize", "the number of bytes pointed to by PropValue.", PARAM_IN>,
TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. If PropSize is not equal to or greater than the real "
@@ -118,7 +118,7 @@ def olGetDeviceInfoSize : Function {
let desc = "Returns the storage size of the given device query.";
let details = [];
let params = [
- Param<"ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
+ Param<"const ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
Param<"ol_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
];
diff --git a/offload/liboffload/API/Event.td b/offload/liboffload/API/Event.td
index 075bf5bafaa64..16cd8545de4f6 100644
--- a/offload/liboffload/API/Event.td
+++ b/offload/liboffload/API/Event.td
@@ -56,7 +56,7 @@ def olGetEventInfo : Function {
"required for the given query."
];
let params = [
- Param<"ol_event_handle_t", "Event", "handle of the event", PARAM_IN>,
+ Param<"const ol_event_handle_t", "Event", "handle of the event", PARAM_IN>,
Param<"ol_event_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
Param<"size_t", "PropSize", "the number of bytes pointed to by PropValue.", PARAM_IN>,
TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. "
@@ -77,7 +77,7 @@ def olGetEventInfoSize : Function {
let desc = "Returns the storage size of the given event query.";
let details = [];
let params = [
- Param<"ol_event_handle_t", "Event", "handle of the event", PARAM_IN>,
+ Param<"const ol_event_handle_t", "Event", "handle of the event", PARAM_IN>,
Param<"ol_event_info_t", "PropName", "type of the info to query", PARAM_IN>,
Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
];
diff --git a/offload/liboffload/API/Kernel.td b/offload/liboffload/API/Kernel.td
index 2f5692a19d712..c2279820d9954 100644
--- a/offload/liboffload/API/Kernel.td
+++ b/offload/liboffload/API/Kernel.td
@@ -47,7 +47,7 @@ def olCalculateOptimalOccupancy : Function {
"For most devices, this will be the largest workgroup size that will result in all work items fitting on the device at once.",
];
let params = [
- Param<"ol_device_handle_t", "Device", "device intended to run the kernel", PARAM_IN>,
+ Param<"const ol_device_handle_t", "Device", "device intended to run the kernel", PARAM_IN>,
Param<"ol_symbol_handle_t", "Kernel", "handle of the kernel", PARAM_IN>,
Param<"size_t", "SharedMemory", "dynamic shared memory required per work item in bytes", PARAM_IN>,
Param<"size_t*", "GroupSize", "optimal block size", PARAM_OUT>
diff --git a/offload/liboffload/API/Platform.td b/offload/liboffload/API/Platform.td
index 906f899076a80..8394e5c34c24a 100644
--- a/offload/liboffload/API/Platform.td
+++ b/offload/liboffload/API/Platform.td
@@ -38,7 +38,7 @@ def olGetPlatformInfo : Function {
"required for the given query."
];
let params = [
- Param<"ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
+ Param<"const ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
Param<"ol_platform_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
Param<"size_t", "PropSize", "the number of bytes pointed to by pPlatformInfo.", PARAM_IN>,
TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. "
@@ -62,7 +62,7 @@ def olGetPlatformInfoSize : Function {
let desc = "Returns the storage size of the given platform query.";
let details = [];
let params = [
- Param<"ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
+ Param<"const ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
Param<"ol_platform_info_t", "PropName", "type of the info to query", PARAM_IN>,
Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
];
diff --git a/offload/liboffload/API/Queue.td b/offload/liboffload/API/Queue.td
index ededa9cc92fef..81e53439d5707 100644
--- a/offload/liboffload/API/Queue.td
+++ b/offload/liboffload/API/Queue.td
@@ -72,7 +72,7 @@ def olGetQueueInfo : Function {
"required for the given query."
];
let params = [
- Param<"ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN>,
+ Param<"const ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN>,
Param<"ol_queue_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
Param<"size_t", "PropSize", "the number of bytes pointed to by PropValue.", PARAM_IN>,
TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. "
@@ -93,7 +93,7 @@ def olGetQueueInfoSize : Function {
let desc = "Returns the storage size of the given queue query.";
let details = [];
let params = [
- Param<"ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN>,
+ Param<"const ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN>,
Param<"ol_queue_info_t", "PropName", "type of the info to query", PARAM_IN>,
Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
];
diff --git a/offload/liboffload/API/Symbol.td b/offload/liboffload/API/Symbol.td
index c57a2e1b83632..115e960e5b4b2 100644
--- a/offload/liboffload/API/Symbol.td
+++ b/offload/liboffload/API/Symbol.td
@@ -49,7 +49,7 @@ def olGetSymbolInfo : Function {
"required for the given query."
];
let params = [
- Param<"ol_symbol_handle_t", "Symbol", "handle of the symbol", PARAM_IN>,
+ Param<"const ol_symbol_handle_t", "Symbol", "handle of the symbol", PARAM_IN>,
Param<"ol_symbol_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
Param<"size_t", "PropSize", "the number of bytes pointed to by PropValue.", PARAM_IN>,
TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. "
@@ -73,7 +73,7 @@ def olGetSymbolInfoSize : Function {
let desc = "Returns the storage size of the given symbol query.";
let details = [];
let params = [
- Param<"ol_symbol_handle_t", "Symbol", "handle of the symbol", PARAM_IN>,
+ Param<"const ol_symbol_handle_t", "Symbol", "handle of the symbol", PARAM_IN>,
Param<"ol_symbol_info_t", "PropName", "type of the info to query", PARAM_IN>,
Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
];
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 7e8e297831f45..e3accdbab2909 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -368,7 +368,7 @@ Error olGetPlatformInfoSize_impl(ol_platform_handle_t Platform,
PropSizeRet);
}
-Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
+Error olGetDeviceInfoImplDetail(const ol_device_handle_t Device,
ol_device_info_t PropName, size_t PropSize,
void *PropValue, size_t *PropSizeRet) {
assert(Device != OffloadContext::get().HostDevice());
@@ -506,7 +506,7 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
}
}
-Error olGetDeviceInfoImplDetailHost(ol_device_handle_t Device,
+Error olGetDeviceInfoImplDetailHost(const ol_device_handle_t Device,
ol_device_info_t PropName, size_t PropSize,
void *PropValue, size_t *PropSizeRet) {
assert(Device == OffloadContext::get().HostDevice());
@@ -575,8 +575,9 @@ Error olGetDeviceInfoImplDetailHost(ol_device_handle_t Device,
return Error::success();
}
-Error olGetDeviceInfo_impl(ol_device_handle_t Device, ol_device_info_t PropName,
- size_t PropSize, void *PropValue) {
+Error olGetDeviceInfo_impl(const ol_device_handle_t Device,
+ ol_device_info_t PropName, size_t PropSize,
+ void *PropValue) {
if (Device == OffloadContext::get().HostDevice())
return olGetDeviceInfoImplDetailHost(Device, PropName, PropSize, PropValue,
nullptr);
@@ -584,7 +585,7 @@ Error olGetDeviceInfo_impl(ol_device_handle_t Device, ol_device_info_t PropName,
nullptr);
}
-Error olGetDeviceInfoSize_impl(ol_device_handle_t Device,
+Error olGetDeviceInfoSize_impl(const ol_device_handle_t Device,
ol_device_info_t PropName, size_t *PropSizeRet) {
if (Device == OffloadContext::get().HostDevice())
return olGetDeviceInfoImplDetailHost(Device, PropName, 0, nullptr,
@@ -733,7 +734,7 @@ Error olWaitEvents_impl(ol_queue_handle_t Queue, ol_event_handle_t *Events,
return Error::success();
}
-Error olGetQueueInfoImplDetail(ol_queue_handle_t Queue,
+Error olGetQueueInfoImplDetail(const ol_queue_handle_t Queue,
ol_queue_info_t PropName, size_t PropSize,
void *PropValue, size_t *PropSizeRet) {
InfoWriter Info(PropSize, PropValue, PropSizeRet);
@@ -755,14 +756,15 @@ Error olGetQueueInfoImplDetail(ol_queue_handle_t Queue,
return Error::success();
}
-Error olGetQueueInfo_impl(ol_queue_handle_t Queue, ol_queue_info_t PropName,
- size_t PropSize, void *PropValue) {
+Error olGetQueueInfo_impl(const ol_queue_handle_t Queue,
+ ol_queue_info_t PropName, size_t PropSize,
+ void *PropValue) {
return olGetQueueInfoImplDetail(Queue, PropName, PropSize, PropValue,
nullptr);
}
-Error olGetQueueInfoSize_impl(ol_queue_handle_t Queue, ol_queue_info_t PropName,
- size_t *PropSizeRet) {
+Error olGetQueueInfoSize_impl(const ol_queue_handle_t Queue,
+ ol_queue_info_t PropName, size_t *PropSizeRet) {
return olGetQueueInfoImplDetail(Queue, PropName, 0, nullptr, PropSizeRet);
}
@@ -785,7 +787,7 @@ Error olDestroyEvent_impl(ol_event_handle_t Event) {
return olDestroy(Event);
}
-Error olGetEventInfoImplDetail(ol_event_handle_t Event,
+Error olGetEventInfoImplDetail(const ol_event_handle_t Event,
ol_event_info_t PropName, size_t PropSize,
void *PropValue, size_t *PropSizeRet) {
InfoWriter Info(PropSize, PropValue, PropSizeRet);
@@ -813,15 +815,16 @@ Error olGetEventInfoImplDetail(ol_event_handle_t Event,
return Error::success();
}
-Error olGetEventInfo_impl(ol_event_handle_t Event, ol_event_info_t PropName,
- size_t PropSize, void *PropValue) {
+Error olGetEventInfo_impl(const ol_event_handle_t Event,
+ ol_event_info_t PropName, size_t PropSize,
+ void *PropValue) {
return olGetEventInfoImplDetail(Event, PropName, PropSize, PropValue,
nullptr);
}
-Error olGetEventInfoSize_impl(ol_event_handle_t Event, ol_event_info_t PropName,
- size_t *PropSizeRet) {
+Error olGetEventInfoSize_impl(const ol_event_handle_t Event,
+ ol_event_info_t PropName, size_t *PropSizeRet) {
return olGetEventInfoImplDetail(Event, PropName, 0, nullptr, PropSizeRet);
}
@@ -928,8 +931,8 @@ Error olDestroyProgram_impl(ol_program_handle_t Program) {
return olDestroy(Program);
}
-Error olCalculateOptimalOccupancy_impl(ol_device_handle_t Device,
- ol_symbol_handle_t Kernel,
+Error olCalculateOptimalOccupancy_impl(const ol_device_handle_t Device,
+ const ol_symbol_handle_t Kernel,
size_t DynamicMemSize,
size_t *GroupSize) {
if (Kernel->Kind != OL_SYMBOL_KIND_KERNEL)
@@ -1036,7 +1039,7 @@ Error olGetSymbol_impl(ol_program_handle_t Program, const char *Name,
}
}
-Error olGetSymbolInfoImplDetail(ol_symbol_handle_t Symbol,
+Error olGetSymbolInfoImplDetail(const ol_symbol_handle_t Symbol,
ol_symbol_info_t PropName, size_t PropSize,
void *PropValue, size_t *PropSizeRet) {
InfoWriter Info(PropSize, PropValue, PropSizeRet);
@@ -1071,14 +1074,15 @@ Error olGetSymbolInfoImplDetail(ol_symbol_handle_t Symbol,
return Error::success();
}
-Error olGetSymbolInfo_impl(ol_symbol_handle_t Symbol, ol_symbol_info_t PropName,
- size_t PropSize, void *PropValue) {
+Error olGetSymbolInfo_impl(const ol_symbol_handle_t Symbol,
+ ol_symbol_info_t PropName, size_t PropSize,
+ void *PropValue) {
return olGetSymbolInfoImplDetail(Symbol, PropName, PropSize, PropValue,
nullptr);
}
-Error olGetSymbolInfoSize_impl(ol_symbol_handle_t Symbol,
+Error olGetSymbolInfoSize_impl(const ol_symbol_handle_t Symbol,
ol_symbol_info_t PropName, size_t *PropSizeRet) {
return olGetSymbolInfoImplDetail(Symbol, PropName, 0, nullptr, PropSizeRet);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/157488
More information about the llvm-commits
mailing list