@@ -46,30 +46,39 @@ Program::Program(ExecutionEnvironment &executionEnvironment, Context *context, b
4646 this ->context ->incRefInternal ();
4747 }
4848 blockKernelManager = new BlockKernelManager ();
49- auto clDevice = context != nullptr ? context->getDevice (0 ) : (device != nullptr ) ? device->getSpecializedDevice <ClDevice>() : nullptr ;
50- if (pDevice == nullptr && context != nullptr ) {
51- pDevice = &context->getDevice (0 )->getDevice ();
49+ ClDevice *pClDevice = nullptr ;
50+ if (context != nullptr ) {
51+ pClDevice = context->getDevice (0 );
52+ if (pDevice == nullptr ) {
53+ pDevice = &pClDevice->getDevice ();
54+ }
55+ } else if (pDevice != nullptr ) {
56+ auto pSpecializedDevice = castToObject<ClDevice>(pDevice->getSpecializedDevice <ClDevice>());
57+ if (pSpecializedDevice != nullptr ) {
58+ pClDevice = pSpecializedDevice;
59+ }
5260 }
61+
5362 numDevices = 1 ;
5463 char paramValue[32 ] = {};
5564 bool force32BitAddressess = false ;
5665
57- if (clDevice ) {
58- clDevice ->getDeviceInfo (CL_DEVICE_VERSION, 32 , paramValue, nullptr );
66+ if (pClDevice ) {
67+ pClDevice ->getDeviceInfo (CL_DEVICE_VERSION, 32 , paramValue, nullptr );
5968 if (strstr (paramValue, " 2.1" )) {
6069 internalOptions = " -ocl-version=210 " ;
6170 } else if (strstr (paramValue, " 2.0" )) {
6271 internalOptions = " -ocl-version=200 " ;
6372 } else if (strstr (paramValue, " 1.2" )) {
6473 internalOptions = " -ocl-version=120 " ;
6574 }
66- force32BitAddressess = clDevice ->getDeviceInfo ().force32BitAddressess ;
75+ force32BitAddressess = pClDevice ->getDeviceInfo ().force32BitAddressess ;
6776
6877 if (force32BitAddressess) {
6978 CompilerOptions::concatenateAppend (internalOptions, CompilerOptions::arch32bit);
7079 }
7180
72- if (clDevice ->areSharedSystemAllocationsAllowed () ||
81+ if (pClDevice ->areSharedSystemAllocationsAllowed () ||
7382 DebugManager.flags .DisableStatelessToStatefulOptimization .get ()) {
7483 CompilerOptions::concatenateAppend (internalOptions, CompilerOptions::greaterThan4gbBuffersRequired);
7584 }
@@ -82,9 +91,9 @@ Program::Program(ExecutionEnvironment &executionEnvironment, Context *context, b
8291 CompilerOptions::concatenateAppend (internalOptions, CompilerOptions::bindlessImages);
8392 }
8493
85- kernelDebugEnabled = clDevice ->isDebuggerActive ();
94+ kernelDebugEnabled = pClDevice ->isDebuggerActive ();
8695
87- auto enableStatelessToStatefullWithOffset = clDevice ->getHardwareCapabilities ().isStatelesToStatefullWithOffsetSupported ;
96+ auto enableStatelessToStatefullWithOffset = pClDevice ->getHardwareCapabilities ().isStatelesToStatefullWithOffsetSupported ;
8897 if (DebugManager.flags .EnableStatelessToStatefulBufferOffsetOpt .get () != -1 ) {
8998 enableStatelessToStatefullWithOffset = DebugManager.flags .EnableStatelessToStatefulBufferOffsetOpt .get () != 0 ;
9099 }
@@ -93,8 +102,8 @@ Program::Program(ExecutionEnvironment &executionEnvironment, Context *context, b
93102 CompilerOptions::concatenateAppend (internalOptions, CompilerOptions::hasBufferOffsetArg);
94103 }
95104
96- auto &hwHelper = HwHelper::get (clDevice ->getHardwareInfo ().platform .eRenderCoreFamily );
97- if (hwHelper.isForceEmuInt32DivRemSPWARequired (clDevice ->getHardwareInfo ())) {
105+ auto &hwHelper = HwHelper::get (pClDevice ->getHardwareInfo ().platform .eRenderCoreFamily );
106+ if (hwHelper.isForceEmuInt32DivRemSPWARequired (pClDevice ->getHardwareInfo ())) {
98107 CompilerOptions::concatenateAppend (internalOptions, CompilerOptions::forceEmuInt32DivRemSP);
99108 }
100109 }
0 commit comments