@@ -881,14 +881,17 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::Context *ctx, NEO::Device *devic
881
881
svmProps.readOnly = constant;
882
882
svmProps.hostPtrReadOnly = constant;
883
883
auto ptr = ctx->getSVMAllocsManager ()->createSVMAlloc (size, svmProps);
884
- UNRECOVERABLE_IF (device == nullptr );
884
+ UNRECOVERABLE_IF (ptr == nullptr );
885
885
auto gpuAlloc = ctx->getSVMAllocsManager ()->getSVMAlloc (ptr)->gpuAllocation ;
886
+ UNRECOVERABLE_IF (gpuAlloc == nullptr );
887
+ UNRECOVERABLE_IF (device == nullptr );
886
888
device->getMemoryManager ()->copyMemoryToAllocation (gpuAlloc, initData, static_cast <uint32_t >(size));
887
889
return ctx->getSVMAllocsManager ()->getSVMAlloc (ptr)->gpuAllocation ;
888
890
} else {
889
891
UNRECOVERABLE_IF (device == nullptr );
890
892
auto allocationType = constant ? GraphicsAllocation::AllocationType::CONSTANT_SURFACE : GraphicsAllocation::AllocationType::GLOBAL_SURFACE;
891
893
auto gpuAlloc = device->getMemoryManager ()->allocateGraphicsMemoryWithProperties ({size, allocationType});
894
+ UNRECOVERABLE_IF (gpuAlloc == nullptr );
892
895
memcpy_s (gpuAlloc->getUnderlyingBuffer (), gpuAlloc->getUnderlyingBufferSize (), initData, size);
893
896
return gpuAlloc;
894
897
}
@@ -952,26 +955,24 @@ cl_int Program::parseProgramScopePatchList() {
952
955
};
953
956
break ;
954
957
955
- case PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO:
956
- if (globalSurface != nullptr ) {
957
- auto patch = *(SPatchGlobalPointerProgramBinaryInfo *)pPatch;
958
- if ((patch.GlobalBufferIndex == 0 ) && (patch.BufferIndex == 0 ) && (patch.BufferType == PROGRAM_SCOPE_GLOBAL_BUFFER)) {
959
- globalVariablesSelfPatches.push_back (readMisalignedUint64 (&patch.GlobalPointerOffset ));
960
- } else {
961
- printDebugString (DebugManager.flags .PrintDebugMessages .get (), stderr, " Program::parseProgramScopePatchList. Unhandled Data parameter: %d\n " , pPatch->Token );
962
- }
963
- DBG_LOG (LogPatchTokens,
964
- " \n .GLOBAL_POINTER_PROGRAM_BINARY_INFO" , pPatch->Token ,
965
- " \n .Size" , pPatch->Size ,
966
- " \n .GlobalBufferIndex" , patch.GlobalBufferIndex ,
967
- " \n .GlobalPointerOffset" , patch.GlobalPointerOffset ,
968
- " \n .BufferType" , patch.BufferType ,
969
- " \n .BufferIndex" , patch.BufferIndex );
958
+ case PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO: {
959
+ auto patch = *(SPatchGlobalPointerProgramBinaryInfo *)pPatch;
960
+ if ((patch.GlobalBufferIndex == 0 ) && (patch.BufferIndex == 0 ) && (patch.BufferType == PROGRAM_SCOPE_GLOBAL_BUFFER)) {
961
+ globalVariablesSelfPatches.push_back (readMisalignedUint64 (&patch.GlobalPointerOffset ));
962
+ } else {
963
+ printDebugString (DebugManager.flags .PrintDebugMessages .get (), stderr, " Program::parseProgramScopePatchList. Unhandled Data parameter: %d\n " , pPatch->Token );
964
+ }
965
+ DBG_LOG (LogPatchTokens,
966
+ " \n .GLOBAL_POINTER_PROGRAM_BINARY_INFO" , pPatch->Token ,
967
+ " \n .Size" , pPatch->Size ,
968
+ " \n .GlobalBufferIndex" , patch.GlobalBufferIndex ,
969
+ " \n .GlobalPointerOffset" , patch.GlobalPointerOffset ,
970
+ " \n .BufferType" , patch.BufferType ,
971
+ " \n .BufferIndex" , patch.BufferIndex );
970
972
}
971
973
break ;
972
974
973
- case PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO:
974
- if (constantSurface != nullptr ) {
975
+ case PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO: {
975
976
auto patch = *(SPatchConstantPointerProgramBinaryInfo *)pPatch;
976
977
if ((patch.ConstantBufferIndex == 0 ) && (patch.BufferIndex == 0 ) && (patch.BufferType == PROGRAM_SCOPE_CONSTANT_BUFFER)) {
977
978
globalConstantsSelfPatches.push_back (readMisalignedUint64 (&patch.ConstantPointerOffset ));
@@ -1021,22 +1022,28 @@ cl_int Program::parseProgramScopePatchList() {
1021
1022
}
1022
1023
1023
1024
for (auto offset : globalVariablesSelfPatches) {
1024
- UNRECOVERABLE_IF (globalSurface == nullptr );
1025
- void *pPtr = ptrOffset (globalSurface->getUnderlyingBuffer (), static_cast <size_t >(offset));
1026
- if (globalSurface->is32BitAllocation ()) {
1027
- *reinterpret_cast <uint32_t *>(pPtr) += static_cast <uint32_t >(globalSurface->getGpuAddressToPatch ());
1025
+ if (globalSurface == nullptr ) {
1026
+ retVal = CL_INVALID_BINARY;
1028
1027
} else {
1029
- *reinterpret_cast <uintptr_t *>(pPtr) += static_cast <uintptr_t >(globalSurface->getGpuAddressToPatch ());
1028
+ void *pPtr = ptrOffset (globalSurface->getUnderlyingBuffer (), static_cast <size_t >(offset));
1029
+ if (globalSurface->is32BitAllocation ()) {
1030
+ *reinterpret_cast <uint32_t *>(pPtr) += static_cast <uint32_t >(globalSurface->getGpuAddressToPatch ());
1031
+ } else {
1032
+ *reinterpret_cast <uintptr_t *>(pPtr) += static_cast <uintptr_t >(globalSurface->getGpuAddressToPatch ());
1033
+ }
1030
1034
}
1031
1035
}
1032
1036
1033
1037
for (auto offset : globalConstantsSelfPatches) {
1034
- UNRECOVERABLE_IF (constantSurface == nullptr );
1035
- void *pPtr = ptrOffset (constantSurface->getUnderlyingBuffer (), static_cast <size_t >(offset));
1036
- if (constantSurface->is32BitAllocation ()) {
1037
- *reinterpret_cast <uint32_t *>(pPtr) += static_cast <uint32_t >(constantSurface->getGpuAddressToPatch ());
1038
+ if (constantSurface == nullptr ) {
1039
+ retVal = CL_INVALID_BINARY;
1038
1040
} else {
1039
- *reinterpret_cast <uintptr_t *>(pPtr) += static_cast <uintptr_t >(constantSurface->getGpuAddressToPatch ());
1041
+ void *pPtr = ptrOffset (constantSurface->getUnderlyingBuffer (), static_cast <size_t >(offset));
1042
+ if (constantSurface->is32BitAllocation ()) {
1043
+ *reinterpret_cast <uint32_t *>(pPtr) += static_cast <uint32_t >(constantSurface->getGpuAddressToPatch ());
1044
+ } else {
1045
+ *reinterpret_cast <uintptr_t *>(pPtr) += static_cast <uintptr_t >(constantSurface->getGpuAddressToPatch ());
1046
+ }
1040
1047
}
1041
1048
}
1042
1049
0 commit comments