Accéder au contenu.
Menu Sympa

starpu-devel - [Starpu-devel] Use OpenCL on CPU devices.

Objet : Developers list for StarPU

Archives de la liste

[Starpu-devel] Use OpenCL on CPU devices.


Chronologique Discussions 
  • From: Cyril Roelandt <cyril.roelandt@inria.fr>
  • To: starpu-devel@lists.gforge.inria.fr
  • Cc: ludovic.stordeur@inria.fr
  • Subject: [Starpu-devel] Use OpenCL on CPU devices.
  • Date: Mon, 05 Mar 2012 19:17:34 +0100
  • List-archive: <http://lists.gforge.inria.fr/pipermail/starpu-devel>
  • List-id: "Developers list. For discussion of new features, code changes, etc." <starpu-devel.lists.gforge.inria.fr>

Hi,

The attached patch allows CPUs to be used as OpenCL devices. This is
*not optimized* and you should definitely not use this feature :) But it
might be useful when debugging complex OpenCL kernels.

On my laptop, I get the following :

$ STARPU_OPENCL_ON_CPUS=1 ./tools/starpu_machine_display
...
StarPU has found :
0 CPU cores
0 CUDA devices
1 OpenCL devices
OpenCL 0 (Intel(R) Core(TM) i7 CPU M 620
...


It is said that one may run gdb on an OpenCL kernel that runs on a CPU :

http://developer.amd.com/zones/OpenCLZone/programming/pages/debuggingopenclapps.aspx

I have not tried this, and I do not know how this can be done with the Intel SDK, or the Nvidia SDK.

Valgrind is easier to run.

If the patch looks fine to you, I'll commit it ASAP. I think Ludovic (CCed) will probably want to play a bit with this feature :)

WBR,
Cyril Roelandt.
Index: src/core/perfmodel/perfmodel_bus.c
===================================================================
--- src/core/perfmodel/perfmodel_bus.c (revision 5999)
+++ src/core/perfmodel/perfmodel_bus.c (working copy)
@@ -541,6 +541,12 @@
nopencl = _starpu_opencl_get_device_count();
for (i = 0; i < nopencl; i++)
{
+ if (_starpu_opencl_get_device_type(i) == CL_DEVICE_TYPE_CPU)
+ {
+ _STARPU_DEBUG("Skipping OpenCL #%d : it is a CPU.\n",
i);
+ continue;
+ }
+
fprintf(stderr," OpenCL %d...", i);
/* measure bandwith between Host and Device i */
measure_bandwidth_between_host_and_dev(i,
opencldev_timing_htod, opencldev_timing_dtoh, opencldev_timing_per_cpu, 'O');
Index: src/drivers/opencl/driver_opencl.h
===================================================================
--- src/drivers/opencl/driver_opencl.h (revision 5999)
+++ src/drivers/opencl/driver_opencl.h (working copy)
@@ -39,6 +39,8 @@
extern
unsigned _starpu_opencl_get_device_count(void);

+extern
+cl_device_type _starpu_opencl_get_device_type(int devid);

#if 0
extern
Index: src/drivers/opencl/driver_opencl.c
===================================================================
--- src/drivers/opencl/driver_opencl.c (revision 5999)
+++ src/drivers/opencl/driver_opencl.c (working copy)
@@ -347,6 +347,9 @@
cl_platform_id platform_id[_STARPU_OPENCL_PLATFORM_MAX];
cl_uint nb_platforms;
cl_device_type device_type =
CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR;
+ if (starpu_get_env_number("STARPU_OPENCL_ON_CPUS") > 0)
+ device_type |= CL_DEVICE_TYPE_CPU;
+
cl_int err;
unsigned int i;

@@ -571,6 +574,21 @@
return nb_devices;
}

+cl_device_type _starpu_opencl_get_device_type(int devid)
+{
+ int err;
+ cl_device_type type;
+
+ if (!init_done)
+ _starpu_opencl_init();
+
+ err = clGetDeviceInfo(devices[devid], CL_DEVICE_TYPE,
sizeof(cl_device_type), &type, NULL);
+ if (err != CL_SUCCESS)
+ STARPU_OPENCL_REPORT_ERROR(err);
+
+ return type;
+}
+
static int _starpu_opencl_execute_job(struct _starpu_job *j, struct
_starpu_worker *args)
{
int ret;


  • [Starpu-devel] Use OpenCL on CPU devices., Cyril Roelandt, 05/03/2012

Archives gérées par MHonArc 2.6.19+.

Haut de le page