Files
rocm-systems/rocclr/runtime/device/gpu/gpuappprofile.cpp
T

80 rindas
2.1 KiB
C++

2014-07-04 16:17:05 -04:00
//
// Copyright (c) 2014 Advanced Micro Devices, Inc. All rights reserved.
//
#include "top.hpp"
#include "utils/debug.hpp"
#include "device/appprofile.hpp"
#include "device/gpu/gpuappprofile.hpp"
namespace gpu {
AppProfile::AppProfile()
: amd::AppProfile()
, enableHighPerformanceState_(IS_LINUX ? false : true)
, reportAsOCL12Device_(false)
2014-07-04 16:17:05 -04:00
{
propertyDataMap_.insert(DataMap::value_type("HighPerfState",
PropertyData(DataType_Boolean, &enableHighPerformanceState_)));
propertyDataMap_.insert(DataMap::value_type("OCL12Device",
PropertyData(DataType_Boolean, &reportAsOCL12Device_)));
2014-07-04 16:17:05 -04:00
}
bool AppProfile::ParseApplicationProfile()
{
amd::ADL* adl = new amd::ADL;
2014-07-04 16:17:05 -04:00
if ((adl == NULL) || !adl->init()) {
2014-07-04 16:17:05 -04:00
delete adl;
return false;
}
ADLApplicationProfile* pProfile = NULL;
2014-07-04 16:17:05 -04:00
// Apply blb configurations
int result = adl->adl2ApplicationProfilesProfileOfApplicationx2Search(
adl->adlContext(), wsAppFileName_.c_str(), NULL, NULL,
L"OCL", &pProfile);
2014-07-04 16:17:05 -04:00
delete adl;
if (pProfile == NULL) {
return false;
}
PropertyRecord* firstProperty = pProfile->record;
2014-07-04 16:17:05 -04:00
uint32_t valueOffset = 0;
2014-07-04 16:17:05 -04:00
for (int index = 0; index < pProfile->iCount; index++) {
PropertyRecord* profileProperty = reinterpret_cast<PropertyRecord*>
((reinterpret_cast<char*>(firstProperty)) + valueOffset);
2014-07-04 16:17:05 -04:00
// Get property name
char* propertyName = profileProperty->strName;
auto entry = propertyDataMap_.find(std::string(propertyName));
if (entry == propertyDataMap_.end()) {
// unexpected name
2014-07-04 16:17:05 -04:00
valueOffset += (sizeof(PropertyRecord) + profileProperty->iDataSize - 4);
continue;
2014-07-04 16:17:05 -04:00
}
// Get the property value
switch (entry->second.type_) {
2014-07-04 16:17:05 -04:00
case DataType_Boolean:
*(reinterpret_cast<bool*>(entry->second.data_)) =
profileProperty->uData[0] ? true : false;
2014-07-04 16:17:05 -04:00
break;
default:
break;
}
valueOffset += (sizeof(PropertyRecord) + profileProperty->iDataSize - 4);
}
free(pProfile);
return true;
}
}