GetCacheInfo
- Obtain the L2 cache size:
HmppResult HMPP_GetL2CacheSize (int32_t *size);
- Obtain the larger value between the L2 cache and L3 cache:
HmppResult HMPP_GetMaxCacheSizeB (int32_t *size);
- Obtain cache parameters of each level, such as the cache type, level, and size:
HmppResult HMPP_GetCacheParams (HmppCache **cacheInfo);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
size |
Pointer to the buffer size |
The parameter cannot be NULL. |
Output |
cacheInfo |
Pointer to the pointer to the HmppCache array |
The value cannot be NULL. |
Output |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of size or cacheInfo is NULL. |
HMPP_STS_NOT_SUPPORT |
Failed to obtain cache information. |
Example
void GetCacheInfo_Example()
{
int32_t l2CacheSize = 0;
HmppResult result = HMPP_GetL2CacheSize(&l2CacheSize);
printf("%s\n", HMPP_GetStatusString(result));
printf("l2CacheSize = %d Byte\n\n", l2CacheSize);
int32_t maxCacheSize = 0;
result = HMPP_GetMaxCacheSizeB(&maxCacheSize);
printf("%s\n", HMPP_GetStatusString(result));
printf("maxCacheSize = %d Byte\n\n", maxCacheSize);
HmppCache *pCacheSize;
result = HMPP_GetCacheParams(&pCacheSize);
printf("%s\n", HMPP_GetStatusString(result));
int32_t i = 0;
while (pCacheSize[i].type) {
printf("type = %d\n", pCacheSize[i].type);
printf("type = %d\n", pCacheSize[i].level);
printf("type = %d Byte\n\n", pCacheSize[i].size);
++i;
}
}
Output:
No Error l2CacheSize = 524288 Byte No Error maxCacheSize = 33554432 Byte No Error type = 1 type = 1 type = 65536 Byte type = 2 type = 1 type = 65536 Byte type = 3 type = 2 type = 524288 Byte type = 3 type = 3 type = 33554432 Byte
The actual output may be different. You can call lscpu to compare the outputs.
Parent topic: Basic Functions