Skip to content

Commit b7c0fb3

Browse files
committed
separate USM and SVM pointers for clSetKernelExecInfo
1 parent a43a3e5 commit b7c0fb3

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

layers/99_svmplusplus/emulate.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,25 +1172,42 @@ cl_int CL_API_CALL clSetKernelExecInfo_override(
11721172
param_value_size,
11731173
param_value);
11741174
ret = (check == CL_SUCCESS) ? CL_SUCCESS : ret;
1175-
return check;
1175+
return ret;
11761176
}
11771177
case CL_KERNEL_EXEC_INFO_SVM_PTRS:
11781178
{
11791179
const void* const* svmPtrs = (const void* const*)param_value;
11801180
const size_t numPtrs = param_value_size / sizeof(void*);
11811181

1182-
std::vector<const void*> nonNullPtrs;
1182+
cl_context context = getContext(kernel);
1183+
1184+
std::vector<const void*> nonNullUSMPtrs;
1185+
std::vector<const void*> nonNullSVMPtrs;
11831186
for (size_t i = 0; i < numPtrs; ++i) {
11841187
if (svmPtrs[i] != nullptr) {
1185-
nonNullPtrs.push_back(svmPtrs[i]);
1188+
if (isUSMPtr(context, svmPtrs[i])) {
1189+
nonNullUSMPtrs.push_back(svmPtrs[i]);
1190+
} else {
1191+
nonNullSVMPtrs.push_back(svmPtrs[i]);
1192+
}
11861193
}
11871194
}
11881195

1189-
return g_pNextDispatch->clSetKernelExecInfo(
1196+
cl_int ret = CL_INVALID_OPERATION;
1197+
cl_int check = CL_INVALID_OPERATION;
1198+
check = g_pNextDispatch->clSetKernelExecInfo(
1199+
kernel,
1200+
CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL,
1201+
nonNullUSMPtrs.size() * sizeof(void*),
1202+
nonNullUSMPtrs.empty() ? nullptr : nonNullUSMPtrs.data());
1203+
ret = (check == CL_SUCCESS) ? CL_SUCCESS : ret;
1204+
check = g_pNextDispatch->clSetKernelExecInfo(
11901205
kernel,
11911206
CL_KERNEL_EXEC_INFO_SVM_PTRS,
1192-
nonNullPtrs.size() * sizeof(void*),
1193-
nonNullPtrs.empty() ? nullptr : nonNullPtrs.data());
1207+
nonNullSVMPtrs.size() * sizeof(void*),
1208+
nonNullSVMPtrs.empty() ? nullptr : nonNullSVMPtrs.data());
1209+
ret = (check == CL_SUCCESS) ? CL_SUCCESS : ret;
1210+
return ret;
11941211
}
11951212
default: break;
11961213
}

0 commit comments

Comments
 (0)