mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Allow sub devices to reuse build status from root device
create DeviceBuildInfo struct for per-device info in program Related-To: NEO-5001 Change-Id: I4048f3dd34240a4f937cc4a05935cba4f40a1872 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
87fd9b0708
commit
e39af42137
@@ -54,14 +54,14 @@ cl_int Program::build(
|
||||
}
|
||||
do {
|
||||
// check to see if a previous build request is in progress
|
||||
if (std::any_of(deviceVector.begin(), deviceVector.end(), [&](auto device) { return CL_BUILD_IN_PROGRESS == buildStatuses[device]; })) {
|
||||
if (std::any_of(deviceVector.begin(), deviceVector.end(), [&](auto device) { return CL_BUILD_IN_PROGRESS == deviceBuildInfos[device].buildStatus; })) {
|
||||
retVal = CL_INVALID_OPERATION;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isCreatedFromBinary == false) {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_IN_PROGRESS;
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_IN_PROGRESS;
|
||||
}
|
||||
|
||||
if (nullptr != buildOptions) {
|
||||
@@ -199,13 +199,11 @@ cl_int Program::build(
|
||||
|
||||
if (retVal != CL_SUCCESS) {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_ERROR;
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_ERROR;
|
||||
}
|
||||
programBinaryType = CL_PROGRAM_BINARY_TYPE_NONE;
|
||||
} else {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_SUCCESS;
|
||||
}
|
||||
setBuildStatusSuccess(deviceVector);
|
||||
programBinaryType = CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ cl_int Program::compile(
|
||||
}
|
||||
}
|
||||
|
||||
if (std::any_of(deviceVector.begin(), deviceVector.end(), [&](auto device) { return CL_BUILD_IN_PROGRESS == buildStatuses[device]; })) {
|
||||
if (std::any_of(deviceVector.begin(), deviceVector.end(), [&](auto device) { return CL_BUILD_IN_PROGRESS == deviceBuildInfos[device].buildStatus; })) {
|
||||
retVal = CL_INVALID_OPERATION;
|
||||
break;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ cl_int Program::compile(
|
||||
}
|
||||
for (const auto &device : deviceVector) {
|
||||
sourceLevelDebuggerNotified[device->getRootDeviceIndex()] = false;
|
||||
buildStatuses[device] = CL_BUILD_IN_PROGRESS;
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_IN_PROGRESS;
|
||||
}
|
||||
|
||||
options = (buildOptions != nullptr) ? buildOptions : "";
|
||||
@@ -165,13 +165,11 @@ cl_int Program::compile(
|
||||
|
||||
if (retVal != CL_SUCCESS) {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_ERROR;
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_ERROR;
|
||||
}
|
||||
programBinaryType = CL_PROGRAM_BINARY_TYPE_NONE;
|
||||
} else {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_SUCCESS;
|
||||
}
|
||||
setBuildStatusSuccess(deviceVector);
|
||||
programBinaryType = CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ T *Program::createBuiltInFromGenBinary(
|
||||
if (program->buildInfos[device->getRootDeviceIndex()].packedDeviceBinarySize == 0) {
|
||||
program->replaceDeviceBinary(makeCopy(binary, size), size, device->getRootDeviceIndex());
|
||||
}
|
||||
program->buildStatuses[device] = CL_BUILD_SUCCESS;
|
||||
program->deviceBuildInfos[device].buildStatus = CL_BUILD_SUCCESS;
|
||||
}
|
||||
program->isCreatedFromBinary = true;
|
||||
program->programBinaryType = CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
|
||||
|
||||
@@ -187,7 +187,7 @@ cl_int Program::getBuildInfo(cl_device_id device, cl_program_build_info paramNam
|
||||
switch (paramName) {
|
||||
case CL_PROGRAM_BUILD_STATUS:
|
||||
srcSize = retSize = sizeof(cl_build_status);
|
||||
pSrc = &buildStatuses.at(pClDev);
|
||||
pSrc = &deviceBuildInfos.at(pClDev).buildStatus;
|
||||
break;
|
||||
|
||||
case CL_PROGRAM_BUILD_OPTIONS:
|
||||
|
||||
@@ -48,7 +48,7 @@ cl_int Program::link(
|
||||
break;
|
||||
}
|
||||
|
||||
if (std::any_of(deviceVector.begin(), deviceVector.end(), [&](auto device) { return CL_BUILD_IN_PROGRESS == buildStatuses[device]; })) {
|
||||
if (std::any_of(deviceVector.begin(), deviceVector.end(), [&](auto device) { return CL_BUILD_IN_PROGRESS == deviceBuildInfos[device].buildStatus; })) {
|
||||
retVal = CL_INVALID_OPERATION;
|
||||
break;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ cl_int Program::link(
|
||||
for (const auto &device : deviceVector) {
|
||||
kernelDebugDataNotified[device->getRootDeviceIndex()] = false;
|
||||
debugOptionsAppended[device->getRootDeviceIndex()] = false;
|
||||
buildStatuses[device] = CL_BUILD_IN_PROGRESS;
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_IN_PROGRESS;
|
||||
}
|
||||
|
||||
options = (buildOptions != nullptr) ? buildOptions : "";
|
||||
@@ -208,13 +208,11 @@ cl_int Program::link(
|
||||
|
||||
if (retVal != CL_SUCCESS) {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_ERROR;
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_ERROR;
|
||||
}
|
||||
programBinaryType = CL_PROGRAM_BINARY_TYPE_NONE;
|
||||
} else {
|
||||
for (const auto &device : deviceVector) {
|
||||
buildStatuses[device] = CL_BUILD_SUCCESS;
|
||||
}
|
||||
setBuildStatusSuccess(deviceVector);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
@@ -55,7 +55,15 @@ Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevic
|
||||
if (device->getRootDeviceIndex() > maxRootDeviceIndex) {
|
||||
maxRootDeviceIndex = device->getRootDeviceIndex();
|
||||
}
|
||||
buildStatuses[device] = CL_BUILD_NONE;
|
||||
deviceBuildInfos[device] = {};
|
||||
if (device->getNumAvailableDevices() > 1) {
|
||||
for (auto i = 0u; i < device->getNumAvailableDevices(); i++) {
|
||||
auto subDevice = device->getDeviceById(i);
|
||||
if (isDeviceAssociated(*subDevice)) {
|
||||
deviceBuildInfos[device].associatedSubDevices.push_back(subDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildInfos.resize(maxRootDeviceIndex + 1);
|
||||
@@ -484,8 +492,16 @@ cl_int Program::packDeviceBinary(uint32_t rootDeviceIndex) {
|
||||
}
|
||||
|
||||
void Program::setBuildStatus(cl_build_status status) {
|
||||
for (auto &buildStatusPair : buildStatuses) {
|
||||
buildStatusPair.second = status;
|
||||
for (auto &deviceBuildInfo : deviceBuildInfos) {
|
||||
deviceBuildInfo.second.buildStatus = status;
|
||||
}
|
||||
}
|
||||
void Program::setBuildStatusSuccess(const ClDeviceVector &deviceVector) {
|
||||
for (const auto &device : deviceVector) {
|
||||
deviceBuildInfos[device].buildStatus = CL_BUILD_SUCCESS;
|
||||
for (const auto &subDevice : deviceBuildInfos[device].associatedSubDevices) {
|
||||
deviceBuildInfos[subDevice].buildStatus = CL_BUILD_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class Program : public BaseObject<_cl_program> {
|
||||
size_t paramValueSize, void *paramValue, size_t *paramValueSizeRet) const;
|
||||
|
||||
bool isBuilt() const {
|
||||
return std::all_of(this->buildStatuses.begin(), this->buildStatuses.end(), [](auto pair) { return pair.second == CL_SUCCESS; });
|
||||
return std::all_of(this->deviceBuildInfos.begin(), this->deviceBuildInfos.end(), [](auto deviceBuildInfo) { return deviceBuildInfo.second.buildStatus == CL_SUCCESS; });
|
||||
}
|
||||
|
||||
Context &getContext() const {
|
||||
@@ -288,6 +288,7 @@ class Program : public BaseObject<_cl_program> {
|
||||
void notifyDebuggerWithSourceCode(ClDevice &clDevice, std::string &filename);
|
||||
|
||||
void setBuildStatus(cl_build_status status);
|
||||
void setBuildStatusSuccess(const ClDeviceVector &deviceVector);
|
||||
|
||||
cl_program_binary_type programBinaryType = CL_PROGRAM_BINARY_TYPE_NONE;
|
||||
bool isSpirV = false;
|
||||
@@ -304,7 +305,12 @@ class Program : public BaseObject<_cl_program> {
|
||||
std::vector<KernelInfo *> parentKernelInfoArray;
|
||||
std::vector<KernelInfo *> subgroupKernelInfoArray;
|
||||
|
||||
std::unordered_map<ClDevice *, int> buildStatuses;
|
||||
struct DeviceBuildInfo {
|
||||
StackVec<ClDevice *, 2> associatedSubDevices;
|
||||
cl_build_status buildStatus = CL_BUILD_NONE;
|
||||
};
|
||||
|
||||
std::unordered_map<ClDevice *, DeviceBuildInfo> deviceBuildInfos;
|
||||
bool isCreatedFromBinary = false;
|
||||
|
||||
std::string sourceCode;
|
||||
|
||||
Reference in New Issue
Block a user