ソースを参照

Remove stencil example

Nathalie Furmento 15 年 前
コミット
50395df8ee
共有4 個のファイルを変更した0 個の追加273 個の削除を含む
  1. 0 17
      examples/Makefile.am
  2. 0 147
      examples/stencil/stencil.c
  3. 0 43
      examples/stencil/stencil.h
  4. 0 66
      examples/stencil/stencil_opencl.c

+ 0 - 17
examples/Makefile.am

@@ -445,23 +445,6 @@ endif
 nobase_STARPU_OPENCL_DATA_DATA = \
 	incrementer/incrementer_kernels_opencl_codelet.cl
 
-###################
-# Stencil example #
-###################
-
-#if STARPU_USE_OPENCL
-#check_PROGRAMS +=		\
-#	stencil/stencil
-#examplebin_PROGRAMS +=		\
-#	stencil/stencil
-#stencil_stencil_SOURCES =	\
-#	stencil/stencil.c       \
-#	stencil/stencil_opencl.c
-#nobase_STARPU_OPENCL_DATA_DATA += \
-#	stencil/stencil_opencl_codelet.cl \
-#	stencil/stencil.h
-#endif
-
 ####################
 # Variable example #
 ####################

+ 0 - 147
examples/stencil/stencil.c

@@ -1,147 +0,0 @@
-/*
- * StarPU
- * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
- *
- * This program 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.
- *
- * This program 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.
- */
-
-#include <starpu.h>
-#include "stencil.h"
-
-extern void opencl_codelet(void *descr[], __attribute__ ((unused)) void *_args);
-
-static int verbose = 0;
-
-static
-void display_non_zero_values(TYPE *ptr, char *msg)
-{
-        if(verbose) {
-                int x, y, z;
-
-                for(z = 0; z < DIM; z++)
-                        for(y = 0; y < DIM; y++)
-                                for(x = 0; x < DIM; x++) {
-                                        TYPE r = ptr[(z + 1) * SURFACE + (y + 1) * REALDIM + x + 1 + FIRST_PAD];
-                                        if(r != 0.0)
-                                                printf("%s[%d, %d, %d] == %f\n", msg, z, y, x, r);
-                                }
-        }
-}
-
-int main(int argc, char **argv)
-{
-        TYPE *data;                         // original data set given to device
-        TYPE *results;                      // results returned from device
-        TYPE C0 = 0.25;
-        TYPE C1 = 0.75;
-        starpu_data_handle data_handle;
-        starpu_data_handle results_handle;
-        starpu_data_handle C0_handle;
-        starpu_data_handle C1_handle;
-
-	starpu_init(NULL);
-
-        // Filter args
-        argv++;
-        while (argc > 1) {
-                if(!strcmp(*argv, "--verbose")) {
-                        verbose = 1;
-                } else
-                        break;
-                argc--; argv++;
-        }
-
-        // Fill our data set with random float values
-        {
-                long i, x, y, z;
-
-                data = (TYPE *)malloc(SIZE * sizeof(TYPE));
-                results = (TYPE *)malloc(SIZE * sizeof(TYPE));
-                if (!data || !results) {
-                        fprintf(stderr, "Malloc failed!\n");
-                        return;
-                }
-
-                for(i = 0; i < SIZE; i++) {
-                        data[i] = 0.0;
-                        results[i] = 0.0;
-                }
-
-                z = ZBLOCK-1;
-                y = YBLOCK-1;
-                x = XBLOCK-1;
-
-                data[(z + 1) * SURFACE + (y + 1) * REALDIM + x + 1 + FIRST_PAD] = 2.0;
-        }
-
-        display_non_zero_values(data, "data");
-
-        starpu_register_vector_data(&data_handle, 0 /* home node */,
-                                    (uintptr_t)data, SIZE, sizeof(TYPE));
-        starpu_register_vector_data(&results_handle, 0 /* home node */,
-                                    (uintptr_t)results, SIZE, sizeof(TYPE));
-        starpu_register_vector_data(&C0_handle, 0 /* home node */,
-                                    (uintptr_t)&C0, 1, sizeof(TYPE));
-        starpu_register_vector_data(&C1_handle, 0 /* home node */,
-                                    (uintptr_t)&C1, 1, sizeof(TYPE));
-
-        _starpu_opencl_compile_source_to_opencl("examples/stencil/stencil_opencl_codelet.cl");
-
-	starpu_codelet cl =
-	{
-		.where = STARPU_OPENCL,
-		.opencl_func = opencl_codelet,
-		.nbuffers = 4
-	};
-
-	{
-		struct starpu_task *task = starpu_task_create();
-
-                task->cl = &cl;
-                task->callback_func = NULL;
-
-		task->buffers[0].handle = data_handle;
-		task->buffers[0].mode = STARPU_R;
-		task->buffers[1].handle = results_handle;
-		task->buffers[1].mode = STARPU_W;
-		task->buffers[2].handle = C0_handle;
-		task->buffers[2].mode = STARPU_R;
-		task->buffers[3].handle = C1_handle;
-		task->buffers[3].mode = STARPU_R;
-
-		int ret = starpu_submit_task(task);
-		if (STARPU_UNLIKELY(ret == -ENODEV))
-		{
-			fprintf(stderr, "No worker may execute this task\n");
-			exit(0);
-		}
-	}
-
-	starpu_wait_all_tasks();
-
-	/* update the array in RAM */
-	starpu_sync_data_with_mem(data_handle, STARPU_R);
-	starpu_sync_data_with_mem(results_handle, STARPU_R);
-	starpu_sync_data_with_mem(C0_handle, STARPU_R);
-	starpu_sync_data_with_mem(C1_handle, STARPU_R);
-
-	display_non_zero_values(results, "results");
-
-	starpu_release_data_from_mem(data_handle);
-	starpu_release_data_from_mem(results_handle);
-	starpu_release_data_from_mem(C0_handle);
-	starpu_release_data_from_mem(C1_handle);
-
-	starpu_shutdown();
-
-	return 0;
-}

+ 0 - 43
examples/stencil/stencil.h

@@ -1,43 +0,0 @@
-/*
- * StarPU
- * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
- *
- * This program 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.
- *
- * This program 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.
- */
-
-#ifndef __STENCIL_H__
-#define __STENCIL_H__
-
-#define TYPE    float
-
-#define DIM     (128)
-#define BORDER  (1)
-
-#define PADDING (64 / sizeof(TYPE) - 2*BORDER)
-#define FIRST_PAD (PADDING+1)
-
-#define REALDIM (DIM + 2 * BORDER + PADDING)
-
-#define SURFACE   ((DIM + 2 * BORDER) * REALDIM)
-
-#define SIZE    ((DIM + 2 * BORDER) * SURFACE + 1)
-
-#define XBLOCK  (16)
-#define YBLOCK  (16)
-#define ZBLOCK  (64)
-
-#define X_PER_THREAD (1)
-#define Y_PER_THREAD (4)
-#define Z_PER_THREAD (ZBLOCK)
-
-#endif
-

+ 0 - 66
examples/stencil/stencil_opencl.c

@@ -1,66 +0,0 @@
-/*
- * StarPU
- * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
- *
- * This program 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.
- *
- * This program 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.
- */
-
-#include <starpu.h>
-#include <starpu_opencl.h>
-#include <starpu_util.h>
-#include "stencil.h"
-
-void opencl_codelet(void *descr[], void *_args)
-{
-	float *data = (float *)STARPU_GET_VECTOR_PTR(descr[0]);
-	float *results = (float *)STARPU_GET_VECTOR_PTR(descr[1]);
-	float *C0 = (float *)STARPU_GET_VECTOR_PTR(descr[2]);
-	float *C1 = (float *)STARPU_GET_VECTOR_PTR(descr[3]);
-
-	cl_kernel kernel;
-	cl_command_queue queue;
-	int id, devid, err;
-
-        id = starpu_get_worker_id();
-        devid = starpu_get_worker_devid(id);
-
-        err = starpu_opencl_load_kernel(&kernel, &queue, "examples/stencil/stencil_opencl_codelet.cl", "stencil", devid);
-	if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
-
-	err = 0;
-	err  = clSetKernelArg(kernel, 0, sizeof(cl_mem), &data);
-	err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &results);
-	err |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &C0);
-	err |= clSetKernelArg(kernel, 3, sizeof(cl_mem), &C1);
-	if (err) STARPU_OPENCL_REPORT_ERROR(err);
-
-	{
-		size_t global[3];
-		size_t local[3];
-
-                // Execute the kernel over the entire range of our 3d input data set
-                local[0] = XBLOCK / X_PER_THREAD;   // threads along the X axis
-                local[1] = YBLOCK / Y_PER_THREAD;   // threads along the Y axis
-                local[2] = ZBLOCK / Z_PER_THREAD;   // threads along the Z axis
-
-                global[0] = DIM / X_PER_THREAD;  // virtual size of global X axis
-                global[1] = DIM / Y_PER_THREAD;  // virtual size of global Y axis
-                global[2] = DIM / Z_PER_THREAD;  // virtual size of global Z axis
-
-                err = clEnqueueNDRangeKernel(queue, kernel, 3, NULL, global, local, 0, NULL, NULL);
-		if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
-	}
-
-	clFinish(queue);
-
-	starpu_opencl_release(kernel);
-}