P4 to Git Change 1275679 by jatang@jatang-ocl-lnx2 on 2016/06/02 11:53:13
SWDEV-92067 - Support app profiles on Brahma.
The Brahma kernel driver does not support parsing the app profile blob files, and does not have ADL. OGL has a library that reads and parses the blob file directly. This CL imports the OGL library into OCL runtime.
Affected files ...
... //depot/stg/opencl/drivers/opencl/appprofiles/brahma/apl.cpp#1 add
... //depot/stg/opencl/drivers/opencl/appprofiles/brahma/apl.hpp#1 add
... //depot/stg/opencl/drivers/opencl/appprofiles/brahma/aplexport.cpp#1 add
... //depot/stg/opencl/drivers/opencl/appprofiles/brahma/structanddefines.hpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/build/Makefile.runtime#63 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.cpp#12 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.hpp#9 edit
[ROCm/clr commit: 428dfba879]
This commit is contained in:
@@ -6,8 +6,13 @@
|
|||||||
#include "os/os.hpp"
|
#include "os/os.hpp"
|
||||||
#include "utils/flags.hpp"
|
#include "utils/flags.hpp"
|
||||||
#include "appprofile.hpp"
|
#include "appprofile.hpp"
|
||||||
|
#include "adl.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#ifdef BRAHMA
|
||||||
|
extern int SearchProfileOfAnApplication(const wchar_t* fileName, ADLApplicationProfile ** lppProfile);
|
||||||
|
#endif //BRAHMA
|
||||||
|
|
||||||
static void* __stdcall adlMallocCallback(int n)
|
static void* __stdcall adlMallocCallback(int n)
|
||||||
{
|
{
|
||||||
return malloc(n);
|
return malloc(n);
|
||||||
@@ -17,6 +22,44 @@ static void* __stdcall adlMallocCallback(int n)
|
|||||||
|
|
||||||
namespace amd {
|
namespace amd {
|
||||||
|
|
||||||
|
#ifndef BRAHMA
|
||||||
|
|
||||||
|
class ADL {
|
||||||
|
public:
|
||||||
|
ADL();
|
||||||
|
~ADL();
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
|
||||||
|
void* adlHandle() const { return adlHandle_; };
|
||||||
|
ADL_CONTEXT_HANDLE adlContext() const { return adlContext_; }
|
||||||
|
|
||||||
|
typedef int (*Adl2MainControlCreate)(ADL_MAIN_MALLOC_CALLBACK callback,
|
||||||
|
int iEnumConnectedAdapters,
|
||||||
|
ADL_CONTEXT_HANDLE* context);
|
||||||
|
typedef int (*Adl2MainControlDestroy)(ADL_CONTEXT_HANDLE context);
|
||||||
|
typedef int (*Adl2ConsoleModeFileDescriptorSet)(ADL_CONTEXT_HANDLE context, int fileDescriptor);
|
||||||
|
typedef int (*Adl2MainControlRefresh)(ADL_CONTEXT_HANDLE context);
|
||||||
|
typedef int (*Adl2ApplicationProfilesSystemReload)(ADL_CONTEXT_HANDLE context);
|
||||||
|
typedef int (*Adl2ApplicationProfilesProfileOfApplicationx2Search)(ADL_CONTEXT_HANDLE context,
|
||||||
|
const wchar_t* fileName,
|
||||||
|
const wchar_t* path,
|
||||||
|
const wchar_t* version,
|
||||||
|
const wchar_t* appProfileArea,
|
||||||
|
ADLApplicationProfile** lppProfile);
|
||||||
|
|
||||||
|
Adl2MainControlCreate adl2MainControlCreate;
|
||||||
|
Adl2MainControlDestroy adl2MainControlDestroy;
|
||||||
|
Adl2ConsoleModeFileDescriptorSet adl2ConsoleModeFileDescriptorSet;
|
||||||
|
Adl2MainControlRefresh adl2MainControlRefresh;
|
||||||
|
Adl2ApplicationProfilesSystemReload adl2ApplicationProfilesSystemReload;
|
||||||
|
Adl2ApplicationProfilesProfileOfApplicationx2Search adl2ApplicationProfilesProfileOfApplicationx2Search;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void* adlHandle_;
|
||||||
|
ADL_CONTEXT_HANDLE adlContext_;
|
||||||
|
};
|
||||||
|
|
||||||
ADL::ADL() : adlHandle_(NULL),
|
ADL::ADL() : adlHandle_(NULL),
|
||||||
adlContext_(NULL)
|
adlContext_(NULL)
|
||||||
{
|
{
|
||||||
@@ -86,6 +129,8 @@ bool ADL::init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //BRAHMA
|
||||||
|
|
||||||
AppProfile::AppProfile(): hsaDeviceHint_(0),
|
AppProfile::AppProfile(): hsaDeviceHint_(0),
|
||||||
gpuvmHighAddr_(false),
|
gpuvmHighAddr_(false),
|
||||||
noHsaInit_(false),
|
noHsaInit_(false),
|
||||||
@@ -151,6 +196,9 @@ cl_device_type AppProfile::ApplyHsaDeviceHintFlag(const cl_device_type& type)
|
|||||||
|
|
||||||
bool AppProfile::ParseApplicationProfile()
|
bool AppProfile::ParseApplicationProfile()
|
||||||
{
|
{
|
||||||
|
ADLApplicationProfile* pProfile = NULL;
|
||||||
|
|
||||||
|
#ifndef BRAHMA
|
||||||
amd::ADL* adl = new amd::ADL;
|
amd::ADL* adl = new amd::ADL;
|
||||||
|
|
||||||
if ((adl == NULL) || !adl->init()) {
|
if ((adl == NULL) || !adl->init()) {
|
||||||
@@ -158,8 +206,6 @@ bool AppProfile::ParseApplicationProfile()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ADLApplicationProfile* pProfile = NULL;
|
|
||||||
|
|
||||||
// Apply blb configurations
|
// Apply blb configurations
|
||||||
int result = adl->adl2ApplicationProfilesProfileOfApplicationx2Search(
|
int result = adl->adl2ApplicationProfilesProfileOfApplicationx2Search(
|
||||||
adl->adlContext(), wsAppFileName_.c_str(), NULL, NULL,
|
adl->adlContext(), wsAppFileName_.c_str(), NULL, NULL,
|
||||||
@@ -167,6 +213,14 @@ bool AppProfile::ParseApplicationProfile()
|
|||||||
|
|
||||||
delete adl;
|
delete adl;
|
||||||
|
|
||||||
|
#else //BRAHMA
|
||||||
|
|
||||||
|
if (!SearchProfileOfAnApplication(wsAppFileName_.c_str(), &pProfile)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //BRAHMA
|
||||||
|
|
||||||
if (pProfile == NULL) {
|
if (pProfile == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -199,8 +253,8 @@ bool AppProfile::ParseApplicationProfile()
|
|||||||
case DataType_String: {
|
case DataType_String: {
|
||||||
assert((size_t)(profileProperty->iDataSize) < sizeof(wbuffer) - 2 &&
|
assert((size_t)(profileProperty->iDataSize) < sizeof(wbuffer) - 2 &&
|
||||||
"app profile string too long");
|
"app profile string too long");
|
||||||
|
memset(wbuffer, 0, sizeof(wbuffer));
|
||||||
memcpy(wbuffer, profileProperty->uData, profileProperty->iDataSize);
|
memcpy(wbuffer, profileProperty->uData, profileProperty->iDataSize);
|
||||||
wbuffer[profileProperty->iDataSize / 2] = L'\0';
|
|
||||||
size_t len = wcstombs(buffer, wbuffer, sizeof(buffer));
|
size_t len = wcstombs(buffer, wbuffer, sizeof(buffer));
|
||||||
assert(len < sizeof(buffer) - 1 && "app profile string too long");
|
assert(len < sizeof(buffer) - 1 && "app profile string too long");
|
||||||
*(reinterpret_cast<std::string*>(entry->second.data_)) = buffer;
|
*(reinterpret_cast<std::string*>(entry->second.data_)) = buffer;
|
||||||
|
|||||||
@@ -4,49 +4,11 @@
|
|||||||
#ifndef APPPROFILE_HPP_
|
#ifndef APPPROFILE_HPP_
|
||||||
#define APPPROFILE_HPP_
|
#define APPPROFILE_HPP_
|
||||||
|
|
||||||
#include "adl.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace amd {
|
namespace amd {
|
||||||
|
|
||||||
class ADL {
|
|
||||||
public:
|
|
||||||
ADL();
|
|
||||||
~ADL();
|
|
||||||
|
|
||||||
bool init();
|
|
||||||
|
|
||||||
void* adlHandle() const { return adlHandle_; };
|
|
||||||
ADL_CONTEXT_HANDLE adlContext() const { return adlContext_; }
|
|
||||||
|
|
||||||
typedef int (*Adl2MainControlCreate)(ADL_MAIN_MALLOC_CALLBACK callback,
|
|
||||||
int iEnumConnectedAdapters,
|
|
||||||
ADL_CONTEXT_HANDLE* context);
|
|
||||||
typedef int (*Adl2MainControlDestroy)(ADL_CONTEXT_HANDLE context);
|
|
||||||
typedef int (*Adl2ConsoleModeFileDescriptorSet)(ADL_CONTEXT_HANDLE context, int fileDescriptor);
|
|
||||||
typedef int (*Adl2MainControlRefresh)(ADL_CONTEXT_HANDLE context);
|
|
||||||
typedef int (*Adl2ApplicationProfilesSystemReload)(ADL_CONTEXT_HANDLE context);
|
|
||||||
typedef int (*Adl2ApplicationProfilesProfileOfApplicationx2Search)(ADL_CONTEXT_HANDLE context,
|
|
||||||
const wchar_t* fileName,
|
|
||||||
const wchar_t* path,
|
|
||||||
const wchar_t* version,
|
|
||||||
const wchar_t* appProfileArea,
|
|
||||||
ADLApplicationProfile** lppProfile);
|
|
||||||
|
|
||||||
Adl2MainControlCreate adl2MainControlCreate;
|
|
||||||
Adl2MainControlDestroy adl2MainControlDestroy;
|
|
||||||
Adl2ConsoleModeFileDescriptorSet adl2ConsoleModeFileDescriptorSet;
|
|
||||||
Adl2MainControlRefresh adl2MainControlRefresh;
|
|
||||||
Adl2ApplicationProfilesSystemReload adl2ApplicationProfilesSystemReload;
|
|
||||||
Adl2ApplicationProfilesProfileOfApplicationx2Search adl2ApplicationProfilesProfileOfApplicationx2Search;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void* adlHandle_;
|
|
||||||
ADL_CONTEXT_HANDLE adlContext_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AppProfile {
|
class AppProfile {
|
||||||
public:
|
public:
|
||||||
AppProfile();
|
AppProfile();
|
||||||
|
|||||||
Reference in New Issue
Block a user