Skip to content

Commit 3722df2

Browse files
authored
Add target helper macro documentation (#208)
--- Signed-off-by: Kartik Nema <kartnema@qti.qualcomm.com>
1 parent 33c3c5f commit 3722df2

3 files changed

Lines changed: 42 additions & 8 deletions

File tree

docs/README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
- [6. Customizations & Extensions](#6-customizations--extensions)
5454
- [6.1. Extensions Interface](#61-extensions-interface)
5555
- [6.1.1. Registering Resource Callbacks](#611-registering-resource-callbacks)
56-
- [6.1.2. Registering Custom Configs](#612-registering-custom-configs)
56+
- [6.1.2. Fetching Target Information](#612-fetching-target-information)
57+
- [6.1.3. Registering Custom Configs](#613-registering-custom-configs)
5758
- [6.2. Custom Configs](#62-custom-configs)
5859
- [6.2.1. Initialization Configs](#621-initialization-configs)
5960
- [6.2.2. Resource Configs](#622-resource-configs)
@@ -1105,8 +1106,41 @@ void resetCustomCpuFreqCustom(void* res) {
11051106
URM_REGISTER_RES_TEAR_CB(0x00010001, resetCustomCpuFreqCustom);
11061107
```
11071108

1109+
### 6.1.2. Fetching Target Information
11081110

1109-
### 6.1.2. Registering Custom Configs
1111+
Plugins can fetch target information using the "GET_TARGET_INFO" helper utility provided by URM. The following information can be retrieved:
1112+
- CPU Masks
1113+
- Logical to Physical Mappings
1114+
- Number of cores / clusters on the target
1115+
1116+
```cpp
1117+
// Utility to fetch target-specific information
1118+
uint64_t GET_TARGET_INFO(int32_t option,
1119+
int32_t numArgs,
1120+
int32_t* args);
1121+
```
1122+
1123+
Usage:
1124+
1125+
For example, to get a cpu mask (which can be used, for example, for IRQ affinity use cases):
1126+
```cpp
1127+
int32_t args[2] = {0, 0};
1128+
uint64_t mask = GET_TARGET_INFO(GET_MASK, 2, args); // all cores in silver cluster
1129+
```
1130+
1131+
- The first parameter in the args array, in this case is the logical cluster ID.
1132+
Here, we use the logical identifier for the silver cluster, using logical identifiers in the code makes it target-architecture independent, hence portable.
1133+
The clusters logical id's are ordered according to the cluster capacities. Hence: 0 represents silver / little, 1 represents gold / big and 2 represents prime.
1134+
1135+
- The second parameter in the args array, in this case is the number of cores in the cluster to be considered for mask creation. 0 represents all cores within the cluster, a non-zero positive value represents the exact number of cores to be considered.
1136+
1137+
To simply get a mask corresponding to the highest capacity cluster on the target, for all cores, the GET_MAX_CLUSTER query can be used, as follows:
1138+
```cpp
1139+
int32_t args[2] = {GET_MAX_CLUSTER, 0};
1140+
uint64_t mask = GET_TARGET_INFO(GET_MASK, 2, args); // all cores in the highest capacity cluster
1141+
```
1142+
1143+
### 6.1.3. Registering Custom Configs
11101144

11111145
Custom config files either can be placed in /etc/urm/custom or Registers a custom configuration (URM_REGISTER_CONFIG) YAML file. This enables target chipset to provide their own config files, i.e. allowing them to provide their own custom resources for example.
11121146

resource-tuner/core/Include/TargetRegistry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ class CacheInfoBuilder {
227227
};
228228

229229
// Utility to fetch target-specific information
230-
uint64_t getTargetInfo(int32_t option,
231-
int32_t numArgs,
232-
int32_t* args);
230+
uint64_t GET_TARGET_INFO(int32_t option,
231+
int32_t numArgs,
232+
int32_t* args);
233233

234234
#endif

resource-tuner/core/TargetRegistry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ CacheInfo* CacheInfoBuilder::build() {
818818
return this->mCacheInfo;
819819
}
820820

821-
uint64_t getTargetInfo(int32_t option,
822-
int32_t numArgs,
823-
int32_t* args) {
821+
uint64_t GET_TARGET_INFO(int32_t option,
822+
int32_t numArgs,
823+
int32_t* args) {
824824
std::shared_ptr<TargetRegistry> targetRegistry = TargetRegistry::getInstance();
825825

826826
switch(option) {

0 commit comments

Comments
 (0)