@@ -1013,7 +1013,6 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
1013
1013
size_t source_size[1 ];
1014
1014
int b_error, binary_status, binaryExisted, idx;
1015
1015
cl_uint numDevices;
1016
- cl_device_id *mpArryDevsID;
1017
1016
FILE *fd, *fd1;
1018
1017
const char * filename = " kernel.cl" ;
1019
1018
// fprintf(stderr, "[OD] CompileKernelFile ... \n");
@@ -1036,10 +1035,7 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
1036
1035
sizeof (numDevices), &numDevices, nullptr );
1037
1036
CHECK_OPENCL (clStatus, " clGetContextInfo" );
1038
1037
1039
- mpArryDevsID = (cl_device_id *)malloc (sizeof (cl_device_id ) * numDevices);
1040
- if (mpArryDevsID == nullptr ) {
1041
- return 0 ;
1042
- }
1038
+ std::vector<cl_device_id > mpArryDevsID (numDevices);
1043
1039
// PERF_COUNT_SUB("get numDevices")
1044
1040
b_error = 0 ;
1045
1041
length = 0 ;
@@ -1062,18 +1058,16 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
1062
1058
// grab the handles to all of the devices in the context.
1063
1059
clStatus = clGetContextInfo (gpuInfo->mpContext , CL_CONTEXT_DEVICES,
1064
1060
sizeof (cl_device_id ) * numDevices,
1065
- mpArryDevsID, nullptr );
1061
+ & mpArryDevsID[ 0 ] , nullptr );
1066
1062
CHECK_OPENCL ( clStatus, " clGetContextInfo" );
1067
1063
// PERF_COUNT_SUB("get devices")
1068
1064
// fprintf(stderr, "[OD] Create kernel from binary\n");
1069
1065
const uint8_t *c_binary = &binary[0 ];
1070
1066
gpuInfo->mpArryPrograms [idx] = clCreateProgramWithBinary ( gpuInfo->mpContext ,numDevices,
1071
- mpArryDevsID, &length, &c_binary,
1067
+ & mpArryDevsID[ 0 ] , &length, &c_binary,
1072
1068
&binary_status, &clStatus );
1073
1069
CHECK_OPENCL ( clStatus, " clCreateProgramWithBinary" );
1074
1070
// PERF_COUNT_SUB("clCreateProgramWithBinary")
1075
- free ( mpArryDevsID );
1076
- mpArryDevsID = nullptr ;
1077
1071
// PERF_COUNT_SUB("binaryExisted")
1078
1072
}
1079
1073
else
0 commit comments