Accéder au contenu.
Menu Sympa

starpu-devel - Re: [Starpu-devel] starpu opencl app

Objet : Developers list for StarPU

Archives de la liste

Re: [Starpu-devel] starpu opencl app


Chronologique Discussions 
  • From: Cyril Roelandt <cyril.roelandt@inria.fr>
  • To: Samuel Thibault <samuel.thibault@ens-lyon.org>, Bogdan Manciu <bogdan.manciu@movidius.com>, starpu-devel@lists.gforge.inria.fr, Alin Dobre <alin.dobre@movidius.com>, David Nicholls <david.nicholls@movidius.com>, Brendan Barry <brendan.barry@movidius.com>
  • Subject: Re: [Starpu-devel] starpu opencl app
  • Date: Fri, 19 Oct 2012 21:35:36 +0200
  • 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>

On 10/19/2012 05:12 PM, Cyril Roelandt wrote:
On 10/19/2012 04:58 PM, Samuel Thibault wrote:

This is

err = clEnqueueWriteImage(queue, d_tex, CL_TRUE, origin, region,
width*sizeof(float), 0, (void *) d_src, 0, NULL, NULL);
if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);

I don't see anything obviously wrong here, but I don't know
clEnqueueWriteImage very much.


I have just taken a quick look at the code, and I think that in
refocusing_opencl_codelet(), the calls to STARPU_MATRIX_GET_PTR() should
be replaced by calls to STARPU_MATRIX_GET_DEV_HANDLE().

I think that currently, clEnqueueWriteImage() is given an invalid "ptr"
argument, which explains this issue.


I attached a simple patch to this email. It makes your code work on my machine, but I'm not sure it does the right thing, since I'm not an OpenCL expert. Could you tell me if it fixes your issues ?

It uses STARPU_MATRIX_GET_DEV_HANDLE instead of STARPU_MATRIX_GET_PTR, which does not work in OpenCL codelets, creates the 2D image without using a host pointer, and then copies d_src to d_tex.

About the task profiling info: StarPU automatically destroys tasks once they have been completed, which means you cannot use task->profiling_info. You have to set task->destroy to 0 before submitting the task, then get all the info you need, and finally call starpu_task_destroy(task).

Regards,
Cyril Roelandt.
--- refocusing_starpu.c.orig 2012-10-19 18:59:45.825406000 +0200
+++ refocusing_starpu.c 2012-10-19 19:41:57.565173000 +0200
@@ -17,6 +17,7 @@
#include <assert.h>

#ifdef __OPENCL__
+#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#ifdef __Apple__
#include <OpenCL/OpenCL.h>
#else
@@ -28,6 +29,7 @@
#include <starpu.h>
#include <starpu_profiling.h>
#ifdef __OPENCL__
+#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#include <starpu_opencl.h>
#endif
#ifdef __CUDA__
@@ -110,8 +112,8 @@
int ld = STARPU_MATRIX_GET_LD(buffers[0]);
int size = width * height * STARPU_MATRIX_GET_ELEMSIZE(buffers[0]);

- cl_mem *d_dst = (cl_mem *)STARPU_MATRIX_GET_PTR(buffers[0]);
- cl_mem *d_src = (cl_mem *)STARPU_MATRIX_GET_PTR(buffers[1]);
+ cl_mem d_dst = (cl_mem )STARPU_MATRIX_GET_DEV_HANDLE(buffers[0]);
+ cl_mem d_src = (cl_mem )STARPU_MATRIX_GET_DEV_HANDLE(buffers[1]);

refocusing_arg * arg=cl_arg;

@@ -136,13 +138,13 @@
// Allocate device resources for input lightfield image
cl_image_format format = { CL_R, CL_UNSIGNED_INT32};
cl_mem d_tex = clCreateImage2D(context, CL_MEM_READ_ONLY,
- &format, width, height, 0 ,(void *)
d_src, &err);
+ &format, width, height, 0, NULL, &err);
if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
assert(err == CL_SUCCESS);

size_t origin[3] = {0,0,0};
size_t region[3] = {width,height,1};
- err = clEnqueueWriteImage(queue, d_tex, CL_TRUE, origin, region,
width*sizeof(float), 0, (void *) d_src, 0, NULL, NULL);
+ err = clEnqueueCopyBufferToImage(queue, d_src, d_tex, 0, origin,
region, 0, NULL, NULL);
if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
assert(err == CL_SUCCESS);

@@ -268,6 +270,10 @@
task->synchronous = 1;
task->callback_func = NULL;

+ /* We do not want this task to be automatically destroyed by StarPU,
+ * since we need to read its profiling info. */
+ task->destroy = 0;
+
/* submit the task to StarPU */
int err = starpu_task_submit(task);

@@ -287,6 +293,8 @@
FPRINTF(stderr, "Avg. delay : %2.5lf us\n", (delay_sum));
FPRINTF(stderr, "Avg. length : %2.5lf us\n", (length_sum));

+ /* We really do not need the task any more, let's get rid of it. */
+ starpu_task_destroy(task);

/* Display the occupancy of all workers during the test */
for (worker = 0; worker < starpu_worker_get_count(); worker++)



Archives gérées par MHonArc 2.6.19+.

Haut de le page