Skip to content

Commit

Permalink
Thneed::clinit() : use cl_get_device_id helper(#19934)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored Jan 27, 2021
1 parent 064bcbe commit 21f45e3
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions selfdrive/modeld/thneed/thneed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <string.h>
#include <errno.h>
#include "common/clutil.h"
#include "thneed.h"

//#define RUN_DISASSEMBLER
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -612,4 +598,3 @@ void CLQueuedKernel::debug_print(bool verbose) {
}
}
}

0 comments on commit 21f45e3

Please sign in to comment.