P4 to Git Change 1535708 by rili@rili-ocl on 2018/04/02 17:07:56
SWDEV-147340 - Added function UpdateAppPowerProfile() that notices KMD to update applicaiton profile.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.cpp#20 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.hpp#13 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#82 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#45 edit
... //depot/stg/opencl/drivers/opencl/runtime/os/os.hpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/os/os_posix.cpp#43 edit
... //depot/stg/opencl/drivers/opencl/runtime/os/os_win32.cpp#49 edit
[ROCm/clr commit: 8dd0ed0240]
This commit is contained in:
@@ -134,7 +134,7 @@ bool ADL::init() {
|
||||
#endif // BRAHMA
|
||||
|
||||
AppProfile::AppProfile() : gpuvmHighAddr_(false), profileOverridesAllSettings_(false) {
|
||||
appFileName_ = amd::Os::getAppFileName();
|
||||
amd::Os::getAppPathAndFileName(appFileName_, appPathAndFileName_);
|
||||
propertyDataMap_.insert(
|
||||
DataMap::value_type("BuildOptsAppend", PropertyData(DataType_String, &buildOptsAppend_)));
|
||||
}
|
||||
@@ -148,7 +148,8 @@ bool AppProfile::init() {
|
||||
|
||||
// Convert appName to wide char for X2_Search ADL interface
|
||||
size_t strLength = appFileName_.length() + 1;
|
||||
wchar_t* appName = new wchar_t[strLength];
|
||||
size_t strPathLength = appPathAndFileName_.length() + 1;
|
||||
wchar_t* appName = new wchar_t[strPathLength];
|
||||
|
||||
size_t success = mbstowcs(appName, appFileName_.c_str(), strLength);
|
||||
if (success > 0) {
|
||||
@@ -158,6 +159,14 @@ bool AppProfile::init() {
|
||||
|
||||
wsAppFileName_ = appName;
|
||||
|
||||
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;
|
||||
|
||||
delete[] appName;
|
||||
|
||||
ParseApplicationProfile();
|
||||
|
||||
@@ -19,6 +19,7 @@ class AppProfile {
|
||||
const std::string& GetBuildOptsAppend() const { return buildOptsAppend_; }
|
||||
|
||||
const std::string& appFileName() const { return appFileName_; }
|
||||
const std::wstring& wsAppPathAndFileName() const { return wsAppPathAndFileName_; }
|
||||
|
||||
protected:
|
||||
enum DataTypes {
|
||||
@@ -38,6 +39,8 @@ class AppProfile {
|
||||
DataMap propertyDataMap_;
|
||||
std::string appFileName_; // without extension
|
||||
std::wstring wsAppFileName_;
|
||||
std::string appPathAndFileName_; // with path and extension
|
||||
std::wstring wsAppPathAndFileName_;
|
||||
|
||||
virtual bool ParseApplicationProfile();
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "device/pal/paltimestamp.hpp"
|
||||
#include "device/pal/palblit.hpp"
|
||||
#include "device/pal/paldebugger.hpp"
|
||||
#include "device/appprofile.hpp"
|
||||
#include "hsa.h"
|
||||
#include "amd_hsa_kernel_code.h"
|
||||
#include "amd_hsa_queue.h"
|
||||
@@ -90,7 +91,7 @@ VirtualGPU::Queue* VirtualGPU::Queue::Create(Pal::IDevice* palDev, Pal::QueueTyp
|
||||
delete queue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
queue->UpdateAppPowerProfile();
|
||||
address addrCmd = addrQ + qSize;
|
||||
address addrF = addrCmd + MaxCmdBuffers * cmdSize;
|
||||
Pal::CmdBufferBuildInfo cmdBuildInfo = {};
|
||||
@@ -146,6 +147,18 @@ VirtualGPU::Queue::~Queue() {
|
||||
}
|
||||
}
|
||||
|
||||
Pal::Result VirtualGPU::Queue::UpdateAppPowerProfile()
|
||||
{
|
||||
std::wstring wsAppPathAndFileName = Device::appProfile()->wsAppPathAndFileName();
|
||||
|
||||
const wchar_t* wAppPathAndName = wsAppPathAndFileName.c_str();
|
||||
// Find the last occurance of the '\\' character and extract the name of the application as wide char.
|
||||
const wchar_t* wAppNamePtr = wcsrchr(wAppPathAndName, '\\');
|
||||
const wchar_t* wAppName = wAppNamePtr ? wAppNamePtr + 1 : wAppPathAndName;
|
||||
|
||||
return iQueue_->UpdateAppPowerProfile(wAppName, wAppPathAndName);
|
||||
}
|
||||
|
||||
void VirtualGPU::Queue::addCmdMemRef(GpuMemoryReference* mem) {
|
||||
Pal::IGpuMemory* iMem = mem->iMem();
|
||||
auto it = memReferences_.find(mem);
|
||||
|
||||
@@ -96,6 +96,9 @@ class VirtualGPU : public device::VirtualDevice {
|
||||
iDev_->RemoveGpuMemoryReferences(1, &iMem, nullptr);
|
||||
}
|
||||
|
||||
// Notice KMD to update applicaiton profile
|
||||
Pal::Result UpdateAppPowerProfile();
|
||||
|
||||
// ibReuse forces event wait without polling, to make sure event occured
|
||||
template <bool ibReuse>
|
||||
bool waifForFence(uint cbId) const {
|
||||
|
||||
@@ -249,8 +249,8 @@ class Os : AllStatic {
|
||||
// return gloabal memory size to be assigned to device info
|
||||
static size_t getPhysicalMemSize();
|
||||
|
||||
//! get Application file name
|
||||
static std::string getAppFileName();
|
||||
//! get Application file name and path
|
||||
static void getAppPathAndFileName(std::string& appName, std::string& appPathAndName);
|
||||
|
||||
//! Install SIGFPE handler for CPU device
|
||||
static bool installSigfpeHandler();
|
||||
|
||||
@@ -729,15 +729,19 @@ size_t Os::getPhysicalMemSize() {
|
||||
return (size_t)si.totalram * si.mem_unit;
|
||||
}
|
||||
|
||||
std::string Os::getAppFileName() {
|
||||
void Os::getAppPathAndFileName(std::string& appName, std::string& appPathAndName) {
|
||||
std::unique_ptr<char[]> buff(new char[FILE_PATH_MAX_LENGTH]());
|
||||
|
||||
if (readlink("/proc/self/exe", buff.get(), FILE_PATH_MAX_LENGTH) > 0) {
|
||||
// Get filename without path and extension.
|
||||
return std::string(basename(buff.get()));
|
||||
appName = std::string(basename(buff.get()));
|
||||
appPathAndName = std::string(buff.get());
|
||||
}
|
||||
|
||||
return "";
|
||||
else {
|
||||
appName = "";
|
||||
appPathAndName = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
|
||||
@@ -931,19 +931,22 @@ size_t Os::getPhysicalMemSize() {
|
||||
return (size_t)statex.ullTotalPhys;
|
||||
}
|
||||
|
||||
std::string Os::getAppFileName() {
|
||||
std::string strFileName;
|
||||
void Os::getAppPathAndFileName(std::string& appName, std::string& appPathAndName) {
|
||||
char* buff = new char[FILE_PATH_MAX_LENGTH];
|
||||
|
||||
if (GetModuleFileNameA(NULL, buff, FILE_PATH_MAX_LENGTH) != 0) {
|
||||
// Get filename without path and extension.
|
||||
strFileName = strrchr(buff, '\\') ? strrchr(buff, '\\') + 1 : buff;
|
||||
appPathAndName = buff;
|
||||
appName = strrchr(buff, '\\') ? strrchr(buff, '\\') + 1 : buff;
|
||||
}
|
||||
else {
|
||||
appPathAndName = "";
|
||||
appName = "";
|
||||
}
|
||||
|
||||
delete[] buff;
|
||||
return strFileName;
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
|
||||
#endif // _WIN32 || __CYGWIN__
|
||||
|
||||
مرجع در شماره جدید
Block a user