Просмотр исходного кода

Slightly simplify the vector_scal example in the doc

Cédric Augonnet лет назад: 15
Родитель
Сommit
5c6266d584
4 измененных файлов с 5 добавлено и 31 удалено
  1. 1 11
      doc/vector_scal_c.texi
  2. 0 5
      doc/vector_scal_cpu.texi
  3. 2 8
      doc/vector_scal_cuda.texi
  4. 2 7
      doc/vector_scal_opencl.texi

+ 1 - 11
doc/vector_scal_c.texi

@@ -5,9 +5,6 @@
  *  2- how to describe which data are accessed by a task (task->buffers[0])
  *  3- how a kernel can manipulate the data (buffers[0].vector.ptr)
  */
-
-#include <stdio.h>
-#include <stdint.h>
 #include <starpu.h>
 #include <starpu_opencl.h>
 
@@ -18,14 +15,7 @@ extern void scal_cuda_func(void *buffers[], void *_args);
 extern void scal_opencl_func(void *buffers[], void *_args);
 
 static starpu_codelet cl = @{
-    .where = STARPU_CPU
-#ifdef STARPU_USE_CUDA
-        | STARPU_CUDA
-#endif
-#ifdef STARPU_USE_OPENCL
-        | STARPU_OPENCL
-#endif
-        ,
+    .where = STARPU_CPU | STARPU_CUDA | STARPU_USE_OPENCL,
     /* CPU implementation of the codelet */
     .cpu_func = scal_cpu_func,
 #ifdef STARPU_USE_CUDA

+ 0 - 5
doc/vector_scal_cpu.texi

@@ -1,7 +1,3 @@
-/*
- * This example complements vector_scale.c: here we implement a CPU version.
- */
-
 #include <starpu.h>
 
 /* This kernel takes a buffer and scales it by a constant factor */
@@ -20,7 +16,6 @@ void scal_cpu_func(void *buffers[], void *cl_arg)
      * in the array, ptr gives the location of the array (that was possibly
      * migrated/replicated), and elemsize gives the size of each elements.
      */
-
     starpu_vector_interface_t *vector = buffers[0];
 
     /* length of the vector */

+ 2 - 8
doc/vector_scal_cuda.texi

@@ -1,7 +1,3 @@
-/*
- * This example complements vector_scale.c: here we implement a CUDA version.
- */
-
 #include <starpu.h>
 
 static __global__ void vector_mult_cuda(float *val, unsigned n,
@@ -15,14 +11,12 @@ static __global__ void vector_mult_cuda(float *val, unsigned n,
 extern "C" void scal_cuda_func(void *buffers[], void *_args)
 @{
         float *factor = (float *)_args;
-        struct starpu_vector_interface_s *vector = (struct starpu_vector_interface_s *) buffers[0];
 
         /* length of the vector */
-        unsigned n = STARPU_GET_VECTOR_NX(vector);
+        unsigned n = STARPU_GET_VECTOR_NX(buffers[0]);
         /* local copy of the vector pointer */
-        float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
+        float *val = (float *)STARPU_GET_VECTOR_PTR(buffers[0]);
 
-        /* TODO: use more blocks and threads in blocks */
         vector_mult_cuda<<<1,1>>>(val, n, *factor);
 
     cudaThreadSynchronize();

+ 2 - 7
doc/vector_scal_opencl.texi

@@ -1,7 +1,3 @@
-/*
- * This example complements vector_scale.c: here we implement a OpenCL version.
- */
-
 #include <starpu.h>
 #include <starpu_opencl.h>
 
@@ -10,15 +6,14 @@ extern struct starpu_opencl_codelet codelet;
 void scal_opencl_func(void *buffers[], void *_args)
 @{
     float *factor = (float *)_args;
-    struct starpu_vector_interface_s *vector = (struct starpu_vector_interface_s *) buffers[0];
     int id, devid, err;
     cl_kernel kernel;
     cl_command_queue queue;
 
     /* length of the vector */
-    unsigned n = STARPU_GET_VECTOR_NX(vector);
+    unsigned n = STARPU_GET_VECTOR_NX(buffers[0]);
     /* local copy of the vector pointer */
-    float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
+    float *val = (float *)STARPU_GET_VECTOR_PTR(buffers[0]);
 
     id = starpu_worker_get_id();
     devid = starpu_worker_get_devid(id);