From 21f45e3ef49fece453feeefa1c65286c36bfc14b Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 27 Jan 2021 19:09:28 +0800 Subject: [PATCH] Thneed::clinit() : use cl_get_device_id helper(#19934) --- selfdrive/modeld/thneed/thneed.cc | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/selfdrive/modeld/thneed/thneed.cc b/selfdrive/modeld/thneed/thneed.cc index 4442cf6821..521b6a8ec5 100644 --- a/selfdrive/modeld/thneed/thneed.cc +++ b/selfdrive/modeld/thneed/thneed.cc @@ -5,6 +5,7 @@ #include #include #include +#include "common/clutil.h" #include "thneed.h" //#define RUN_DISASSEMBLER @@ -343,26 +344,11 @@ void Thneed::execute(float **finputs, float *foutput, bool slow) { } void Thneed::clinit() { - cl_int err; - - cl_platform_id platform_id[2]; - cl_uint num_devices; - cl_uint num_platforms; - - err = clGetPlatformIDs(sizeof(platform_id)/sizeof(cl_platform_id), platform_id, &num_platforms); - assert(err == 0); - - err = clGetDeviceIDs(platform_id[0], CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &num_devices); - assert(err == 0); - - context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err); - assert(err == 0); - + device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); + context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); //cl_command_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; cl_command_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - command_queue = clCreateCommandQueueWithProperties(context, device_id, props, &err); - assert(err == 0); - + command_queue = CL_CHECK_ERR(clCreateCommandQueueWithProperties(context, device_id, props, &err)); printf("Thneed::clinit done\n"); } @@ -612,4 +598,3 @@ void CLQueuedKernel::debug_print(bool verbose) { } } } -