diff --git a/src/gallium/frontends/clover/core/device.cpp b/src/gallium/frontends/clover/core/device.cpp index 3b41caf06ae..66159e9f297 100644 --- a/src/gallium/frontends/clover/core/device.cpp +++ b/src/gallium/frontends/clover/core/device.cpp @@ -134,6 +134,27 @@ namespace { return version; } + + static cl_device_type + parse_env_device_type() { + const char* val = getenv("CLOVER_DEVICE_TYPE"); + if (!val) { + return 0; + } + if (strcmp(val, "cpu") == 0) { + return CL_DEVICE_TYPE_CPU; + } + if (strcmp(val, "gpu") == 0) { + return CL_DEVICE_TYPE_GPU; + } + if (strcmp(val, "accelerator") == 0) { + return CL_DEVICE_TYPE_ACCELERATOR; + } + /* CL_DEVICE_TYPE_CUSTOM isn't implemented + because CL_DEVICE_TYPE_CUSTOM is OpenCL 1.2 + and Clover is OpenCL 1.1. */ + return 0; + } } device::device(clover::platform &platform, pipe_loader_device *ldev) : @@ -189,6 +210,11 @@ device::operator==(const device &dev) const { cl_device_type device::type() const { + cl_device_type type = parse_env_device_type(); + if (type != 0) { + return type; + } + switch (ldev->type) { case PIPE_LOADER_DEVICE_SOFTWARE: return CL_DEVICE_TYPE_CPU;