2021-07-02 14:41:38 -07:00
|
|
|
/* Copyright (c) 2014 - 2021 Advanced Micro Devices, Inc.
|
2020-02-04 09:26:14 -08:00
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
THE SOFTWARE. */
|
2014-07-04 16:17:05 -04:00
|
|
|
|
|
|
|
|
#include "top.hpp"
|
|
|
|
|
#include "os/os.hpp"
|
|
|
|
|
#include "utils/flags.hpp"
|
|
|
|
|
#include "appprofile.hpp"
|
2014-09-23 12:44:50 -04:00
|
|
|
#include <cstdlib>
|
2017-04-13 12:17:47 -04:00
|
|
|
#include <cstring>
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-26 16:10:30 -04:00
|
|
|
typedef void* ADLApplicationProfile;
|
|
|
|
|
int SearchProfileOfAnApplication(const wchar_t* fileName, ADLApplicationProfile** lppProfile)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2016-06-02 13:36:39 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
#define GETPROCADDRESS(_adltype_, _adlfunc_) (_adltype_) amd::Os::getSymbol(adlHandle_, #_adlfunc_);
|
2014-07-04 16:17:05 -04:00
|
|
|
|
|
|
|
|
namespace amd {
|
|
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
AppProfile::AppProfile() : gpuvmHighAddr_(false), profileOverridesAllSettings_(false) {
|
2018-04-02 17:15:51 -04:00
|
|
|
amd::Os::getAppPathAndFileName(appFileName_, appPathAndFileName_);
|
2017-04-13 13:56:38 -04:00
|
|
|
propertyDataMap_.insert(
|
|
|
|
|
DataMap::value_type("BuildOptsAppend", PropertyData(DataType_String, &buildOptsAppend_)));
|
2014-07-04 16:17:05 -04:00
|
|
|
}
|
|
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
AppProfile::~AppProfile() {}
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
bool AppProfile::init() {
|
|
|
|
|
if (appFileName_.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
// Convert appName to wide char for X2_Search ADL interface
|
|
|
|
|
size_t strLength = appFileName_.length() + 1;
|
2018-04-02 17:15:51 -04:00
|
|
|
size_t strPathLength = appPathAndFileName_.length() + 1;
|
|
|
|
|
wchar_t* appName = new wchar_t[strPathLength];
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
size_t success = mbstowcs(appName, appFileName_.c_str(), strLength);
|
|
|
|
|
if (success > 0) {
|
|
|
|
|
// mbstowcs was able to convert to wide character successfully.
|
|
|
|
|
appName[strLength - 1] = L'\0';
|
|
|
|
|
}
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
wsAppFileName_ = appName;
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2018-04-02 17:15:51 -04:00
|
|
|
success = mbstowcs(appName, appPathAndFileName_.c_str(), strPathLength);
|
|
|
|
|
if (success > 0) {
|
|
|
|
|
// mbstowcs was able to convert to wide character successfully.
|
|
|
|
|
appName[strPathLength - 1] = L'\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wsAppPathAndFileName_ = appName;
|
|
|
|
|
|
2017-05-15 19:42:30 -04:00
|
|
|
delete[] appName;
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
ParseApplicationProfile();
|
2014-07-04 16:17:05 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
return true;
|
2014-07-04 16:17:05 -04:00
|
|
|
}
|
|
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
bool AppProfile::ParseApplicationProfile() {
|
|
|
|
|
ADLApplicationProfile* pProfile = NULL;
|
2016-06-02 13:36:39 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
if (!SearchProfileOfAnApplication(wsAppFileName_.c_str(), &pProfile)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-06-02 13:36:39 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
if (pProfile == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2014-09-23 12:44:50 -04:00
|
|
|
}
|
2014-07-04 16:17:05 -04:00
|
|
|
}
|