aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2015-06-04 01:52:30 +0000
committerGil Pitney <gil.pitney@linaro.org>2015-06-04 01:52:30 +0000
commitee27714b3919d58ee0c096bee743feaf5cb7341c (patch)
tree123778f2e77ce50376a31847f3506a56fde4e96f
parente6367bae140986ea1ce0c4d9493ff36343e7bc30 (diff)
downloadshamrock-ee27714b3919d58ee0c096bee743feaf5cb7341c.tar.gz
Implement CL_DEVICE_PARTITION_TYPE case of clGetDeviceInfo()
Used by clients to determine how a (sub)device was partitioned by clCreateSubDevices() Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/core/cpu/device.cpp34
-rw-r--r--src/core/cpu/device.h6
-rw-r--r--src/core/dsp/device.cpp6
3 files changed, 42 insertions, 4 deletions
diff --git a/src/core/cpu/device.cpp b/src/core/cpu/device.cpp
index 254bcbd..5f02f4f 100644
--- a/src/core/cpu/device.cpp
+++ b/src/core/cpu/device.cpp
@@ -65,9 +65,6 @@ using namespace Coal;
#define ONE_GIGABYTE (1024 * ONE_MEGABYTE)
#define HALF_GIGABYTE (512 * ONE_MEGABYTE)
-//TODO: #define MAX_PARTITION_PROPS (2)
-#define MAX_PARTITION_PROPS (1)
-
CPUDevice::CPUDevice(DeviceInterface *parent_device, unsigned int cores)
: DeviceInterface(), p_num_events(0), p_workers(0), p_stop(false),
p_initialized(false)
@@ -80,6 +77,7 @@ CPUDevice::CPUDevice(DeviceInterface *parent_device, unsigned int cores)
else {
// Otherwise, it was computed by createSubDevices and passed in:
p_cores = cores;
+ p_partition_properties[0] = 0;
}
// Determine frequency:
@@ -376,6 +374,7 @@ cl_int CPUDevice::createSubDevices(
for (int i = 0; i < num_new_devices; i++) {
new_device = new CPUDevice(this, partition_size);
out_devices[i] = (cl_device_id)new_device;
+ new_device->setProperties(properties);
}
}
if (num_devices_ret) *num_devices_ret = num_new_devices;
@@ -744,7 +743,14 @@ cl_int CPUDevice::info(cl_device_info param_name,
SIMPLE_ASSIGN(cl_device_id, p_parent_device);
break;
case CL_DEVICE_PARTITION_MAX_SUB_DEVICES:
- SIMPLE_ASSIGN(cl_uint, numCPUs());
+ if (numCPUs() == 1) {
+ // cannot subdivide further:
+ SIMPLE_ASSIGN(cl_uint, 0);
+ }
+ else {
+ // Can have each sub-device have one compute unit:
+ SIMPLE_ASSIGN(cl_uint, numCPUs());
+ }
break;
case CL_DEVICE_PARTITION_PROPERTIES:
value_length = MAX_PARTITION_PROPS * sizeof(cl_device_partition_property);
@@ -755,6 +761,15 @@ cl_int CPUDevice::info(cl_device_info param_name,
case CL_DEVICE_PARTITION_AFFINITY_DOMAIN:
SIMPLE_ASSIGN(cl_device_affinity_domain, 0);
break;
+ case CL_DEVICE_PARTITION_TYPE:
+ if (!p_parent_device) {
+ value_length = 0; // this is a root device.
+ }
+ else { // otherwise, return properties argument of clCreateSubDevices():
+ value = (void *)&p_partition_properties[0];
+ value_length = sizeof(cl_device_partition_property) * MAX_PARTITION_PROPS;
+ }
+ break;
case CL_DEVICE_REFERENCE_COUNT:
SIMPLE_ASSIGN(cl_uint, references());
break;
@@ -775,6 +790,17 @@ cl_int CPUDevice::info(cl_device_info param_name,
return CL_SUCCESS;
}
+void CPUDevice::setProperties(const cl_device_partition_property *properties)
+{
+ // store for retrieval by clGetDeviceInfo(...,CL_DEVICE_PARTITION_TYPE,..)
+
+ assert(properties != NULL);
+ for (int i = 0; i < MAX_PARTITION_PROPS; i++) {
+ p_partition_properties[i] = properties[i];
+ }
+}
+
+
#if !defined(DSPC868X)
#if 0 // /dev/mem is no longer available
unsigned arm_speed()
diff --git a/src/core/cpu/device.h b/src/core/cpu/device.h
index a730d08..52aa2d9 100644
--- a/src/core/cpu/device.h
+++ b/src/core/cpu/device.h
@@ -39,6 +39,9 @@
#include <list>
#include <string>
+//TODO: #define MAX_PARTITION_PROPS (2)
+#define MAX_PARTITION_PROPS (1)
+
namespace Coal
{
@@ -97,6 +100,8 @@ class CPUDevice : public DeviceInterface
cl_device_id * out_devices,
cl_uint * num_devices_ret);
+ void setProperties(const cl_device_partition_property *properties);
+
unsigned int numCPUs() const; /*!< \brief Number of cores in this (sub)device */
float cpuMhz() const; /*!< \brief Speed of the CPU in Mhz */
@@ -114,6 +119,7 @@ class CPUDevice : public DeviceInterface
bool p_stop, p_initialized;
DeviceInterface *p_parent_device;
+ cl_device_partition_property p_partition_properties[MAX_PARTITION_PROPS];
};
}
diff --git a/src/core/dsp/device.cpp b/src/core/dsp/device.cpp
index 32cd9b0..98a2bd8 100644
--- a/src/core/dsp/device.cpp
+++ b/src/core/dsp/device.cpp
@@ -990,6 +990,12 @@ cl_int DSPDevice::info(cl_device_info param_name,
return CL_SUCCESS;
}
+void DSPDevice::setProperties(const cl_device_partition_property *properties)
+{
+ // TODO
+}
+
+
/******************************************************************************
* Call back functions from the target loader
******************************************************************************/