Skip to content

Commit

Permalink
ensure platform SVM capabilities include all device SVM capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbaug committed Dec 11, 2024
1 parent c019c8a commit ef9b407
Showing 1 changed file with 45 additions and 27 deletions.
72 changes: 45 additions & 27 deletions layers/99_svmplusplus/emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,80 +230,98 @@ struct SLayerContext

// USM Types:

cl_svm_capabilities_khr combinedCaps = 0;
for (auto device: devices) {
cl_svm_capabilities_khr caps = getDeviceUSMCaps(device);
if (caps != 0) {
typeCapsPlatform.push_back(CL_SVM_TYPE_MACRO_DEVICE_KHR);
break;
combinedCaps = (combinedCaps == 0) ? caps : (combinedCaps & caps);
}
}
if (combinedCaps != 0) {
typeCapsPlatform.push_back(combinedCaps);
}

combinedCaps = 0;
for (auto device: devices) {
cl_svm_capabilities_khr caps = getHostUSMCaps(device);
if (caps != 0) {
typeCapsPlatform.push_back(CL_SVM_TYPE_MACRO_HOST_KHR);
break;
combinedCaps = (combinedCaps == 0) ? caps : (combinedCaps & caps);
}
}
if (combinedCaps != 0) {
typeCapsPlatform.push_back(combinedCaps);
}

combinedCaps = 0;
for (auto device: devices) {
cl_svm_capabilities_khr caps = getSingleDeviceSharedUSMCaps(device);
if (caps != 0) {
typeCapsPlatform.push_back(CL_SVM_TYPE_MACRO_SINGLE_DEVICE_SHARED_KHR);
break;
combinedCaps = (combinedCaps == 0) ? caps : (combinedCaps & caps);
}
}
if (combinedCaps != 0) {
typeCapsPlatform.push_back(combinedCaps);
}

// SVM Types:

combinedCaps = 0;
for (auto device: devices) {
cl_svm_capabilities_khr caps = getCoarseGrainSVMCaps(device);
if (caps != 0) {
typeCapsPlatform.push_back(CL_SVM_TYPE_MACRO_COARSE_GRAIN_BUFFER_KHR);
break;
combinedCaps = (combinedCaps == 0) ? caps : (combinedCaps & caps);
}
}
if (combinedCaps != 0) {
typeCapsPlatform.push_back(combinedCaps);
}

for (auto device: devices) {
cl_svm_capabilities_khr caps = getFineGrainSVMCaps(device);
if (caps != 0) {
typeCapsPlatform.push_back(CL_SVM_TYPE_MACRO_FINE_GRAIN_BUFFER_KHR);
break;
combinedCaps = (combinedCaps == 0) ? caps : (combinedCaps & caps);
}
}
if (combinedCaps != 0) {
typeCapsPlatform.push_back(combinedCaps);
}

for (auto device: devices) {
cl_svm_capabilities_khr caps = getSystemSVMCaps(device);
if (caps != 0) {
typeCapsPlatform.push_back(CL_SVM_TYPE_MACRO_SYSTEM_KHR);
break;
combinedCaps = (combinedCaps == 0) ? caps : (combinedCaps & caps);
}
}
if (combinedCaps != 0) {
typeCapsPlatform.push_back(combinedCaps);
}

TypeCapsPlatform[platform] = typeCapsPlatform;

for (auto device: devices) {
std::vector<cl_svm_capabilities_khr> typeCapsDevice;

for (auto caps: typeCapsPlatform) {
switch(caps) {
case CL_SVM_TYPE_MACRO_DEVICE_KHR:
if ((caps & CL_SVM_TYPE_MACRO_DEVICE_KHR) == CL_SVM_TYPE_MACRO_DEVICE_KHR) {
typeCapsDevice.push_back(getDeviceUSMCaps(device));
break;
case CL_SVM_TYPE_MACRO_HOST_KHR:
}
else if ((caps & CL_SVM_TYPE_MACRO_HOST_KHR) == CL_SVM_TYPE_MACRO_HOST_KHR) {
typeCapsDevice.push_back(getHostUSMCaps(device));
break;
case CL_SVM_TYPE_MACRO_SINGLE_DEVICE_SHARED_KHR:
}
else if ((caps & CL_SVM_TYPE_MACRO_SINGLE_DEVICE_SHARED_KHR) == CL_SVM_TYPE_MACRO_SINGLE_DEVICE_SHARED_KHR) {
typeCapsDevice.push_back(getSingleDeviceSharedUSMCaps(device));
break;
case CL_SVM_TYPE_MACRO_COARSE_GRAIN_BUFFER_KHR:
}
else if ((caps & CL_SVM_TYPE_MACRO_COARSE_GRAIN_BUFFER_KHR) == CL_SVM_TYPE_MACRO_COARSE_GRAIN_BUFFER_KHR) {
typeCapsDevice.push_back(getCoarseGrainSVMCaps(device));
break;
case CL_SVM_TYPE_MACRO_FINE_GRAIN_BUFFER_KHR:
}
else if ((caps & CL_SVM_TYPE_MACRO_FINE_GRAIN_BUFFER_KHR) == CL_SVM_TYPE_MACRO_FINE_GRAIN_BUFFER_KHR) {
typeCapsDevice.push_back(getFineGrainSVMCaps(device));
break;
case CL_SVM_TYPE_MACRO_SYSTEM_KHR:
}
else if ((caps & CL_SVM_TYPE_MACRO_SYSTEM_KHR) == CL_SVM_TYPE_MACRO_SYSTEM_KHR) {
typeCapsDevice.push_back(getSystemSVMCaps(device));
break;
default:
}
else {
assert(0 && "unknown platform SVM type");
break;
}
}

Expand Down

0 comments on commit ef9b407

Please sign in to comment.