Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions sycl/tools/get_device_count_by_type.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//==-- get_device_count_by_type.cpp - Get device count by type -------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand All @@ -12,7 +11,6 @@

#ifdef USE_PI_CUDA
#include <cuda.h>
// #include <cuda_device_runtime_api.h>
#endif // USE_PI_CUDA

#include <algorithm>
Expand All @@ -36,33 +34,23 @@ std::string lowerString(const std::string &str) {
return result;
}

const char *deviceTypeToString(cl_device_type deviceType) {
const char *str = "unknown";
static const char *deviceTypeToString(cl_device_type deviceType) {
switch (deviceType) {
case CL_DEVICE_TYPE_CPU:
str = "cpu";
break;
return "cpu";
case CL_DEVICE_TYPE_GPU:
str = "gpu";
break;
return "gpu";
case CL_DEVICE_TYPE_ACCELERATOR:
str = "accelerator";
break;
return "accelerator";
case CL_DEVICE_TYPE_CUSTOM:
str = "custom";
break;
return "custom";
case CL_DEVICE_TYPE_DEFAULT:
str = "default";
break;
return "default";
case CL_DEVICE_TYPE_ALL:
str = "all";
break;
default:
// str already set to express unknown device type.
break;
return "all";
}

return str;
return "unknown";
}

static bool queryOpenCL(cl_device_type deviceType, cl_uint &deviceCount,
Expand All @@ -74,13 +62,13 @@ static bool queryOpenCL(cl_device_type deviceType, cl_uint &deviceCount,
iRet = clGetPlatformIDs(0, nullptr, &platformCount);
if (iRet != CL_SUCCESS) {
if (iRet == CL_PLATFORM_NOT_FOUND_KHR) {
msg = "ERROR: OpenCL error runtime not found";
} else {
std::stringstream stream;
stream << "ERROR: OpenCL error calling clGetPlatformIDs " << iRet
<< std::endl;
msg = stream.str();
msg = "OpenCL error runtime not found";
return true;
}
std::stringstream stream;
stream << "ERROR: OpenCL error calling clGetPlatformIDs " << iRet
<< std::endl;
msg = stream.str();
return false;
}

Expand Down