Accéder au contenu.
Menu Sympa

starpu-devel - Re: [Starpu-devel] StarPU SVN and OpenCL on CPU

Objet : Developers list for StarPU

Archives de la liste

Re: [Starpu-devel] StarPU SVN and OpenCL on CPU


Chronologique Discussions 
  • From: Sylvain HENRY <sylvain.henry@inria.fr>
  • To: starpu-devel@lists.gforge.inria.fr
  • Subject: Re: [Starpu-devel] StarPU SVN and OpenCL on CPU
  • Date: Wed, 23 Feb 2011 20:32:15 +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 George,

I succeeded in using StarPU with the AMD Stream SDK on CPU but it requires a hack.

The problem is that StarPU uses asynchronous data transfers and uses polling (clGetEventInfo(CL_EVENT_COMMAND_EXECUTION_STATUS...)) to know when a transfer is terminated. But it seems that the asynchronous data transfer (i.e. memcpy) is never performed by AMD Stream. A blocking call is required for the transfer to be performed...

A first simple solution would be to detect when the worker is an OpenCL CPU device and to somehow force the call to be blocking.

The solution I used is different. Because I wanted to avoid the superfluous memcpy, I used an OpenCL buffer created with the flag CL_MEM_USE_HOST_PTR. Each time StarPU wants to transfer data from host memory to the OpenCL CPU device, it calls a function with the source address and the target buffer. This is where I free the buffer and replace it with a new one "mapping" the data.

This hack worked for me because I only had OpenCL devices (no CPU worker from a StarPU point of view, only OpenCL ones). With CPU workers, data may get corrupted as we are faking a copy.

The long term solution would be for StarPU to consider OpenCL CPU devices as CPU workers, that is, workers performing their computations in host memory (and using CPU cores... but this is another story).

Cheers
Sylvain

Le 23/02/2011 16:46, George Russell a écrit :
4D652BBE.4080908@codeplay.com"> Hi,

I have tried to get StarPU trunk from SVN to work for OpenCL on the CPU, but have met with no success. Is this not expected to be a usable approach?

I have made one change to StarPU code itself, to allow CPU OpenCL devices

to provide
cl_device_type device_type = CL_DEVICE_TYPE_CPU|CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR;

in the init function of the OpenCL driver.

I built StarPU as follows:

./configure --with-opencl-include-dir=/home/george/Desktop/ati-stream-sdk-v2.3-lnx32/include/ --with-opencl-lib-dir=/home/george/Desktop/ati-stream-sdk-v2.3-lnx32/lib/x86 --prefix=/home/george --disable-cpu --enable-debug --enable-verbose

Here is a log of the attempt to run one of the examples; It hangs, and I aborted it with Ctrl-C.

george@george-VirtualBox:~/Desktop/starpu/trunk$ examples/basic_examples/vector_scal
BEFORE : First element was 1.000000
[starpu][_starpu_opencl_init] Initialising OpenCL
[starpu][_starpu_opencl_init] Platforms detected: 1
[starpu][_starpu_opencl_init] Platform: ATI Stream - Advanced Micro Devices, Inc.
[starpu][_starpu_opencl_init]   1 devices detected
[starpu][load_sched_policy] Use eager scheduler (greedy policy)
[starpu][_starpu_launch_drivers] initialising worker 0
[starpu][_starpu_opencl_init_context] Initialising context for dev 0
[starpu][_starpu_opencl_get_device_name] Device 0 : [Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz]
[starpu][_starpu_opencl_worker] OpenCL (Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz) dev id 0 thread is ready to run on CPU 0 !
[starpu][_starpu_opencl_locate_file] Trying to locate <examples/basic_examples/vector_scal_opencl_kernel.cl>
[starpu][starpu_opencl_load_opencl_from_file] Source file name : <examples/basic_examples/vector_scal_opencl_kernel.cl>
[starpu][_starpu_opencl_load_program_source] OpenCL kernel </* StarPU --- Runtime system for heterogeneous multicore architectures.
 *
 * Copyright (C) 2010  Centre National de la Recherche Scientifique
 *
 * StarPU is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * StarPU is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
 */

__kernel void vector_mult_opencl(__global float* val, int nx, float factor)
{
        const int i = get_global_id(0);
        if (i < nx) {
                val[i] *= 11.0f+factor;
        }
}
>

Cheers,
George
^C
Compilation terminated.


_______________________________________________
Starpu-devel mailing list
Starpu-devel@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/starpu-devel




Archives gérées par MHonArc 2.6.19+.

Haut de le page