Accéder au contenu.
Menu Sympa

starpu-devel - [Starpu-devel] Matrix Filters

Objet : Developers list for StarPU

Archives de la liste

[Starpu-devel] Matrix Filters


Chronologique Discussions 
  • From: Nathalie Furmento <nathalie.furmento@labri.fr>
  • To: starpu-devel@lists.gforge.inria.fr
  • Cc: Juhoor Mehdi <mehdi.juhoor@etu.u-bordeaux1.fr>
  • Subject: [Starpu-devel] Matrix Filters
  • Date: Mon, 12 Jul 2010 17:25:11 +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>

I have a question about the filters. I have a sample application which defines a matrix, partitions it in 2 blocks, and sets the elements of the i-st block to i.

Here the output i get with the filter *starpu_block_filter_func*:

IN Matrix:
10 11 12 13
14 15 16 17
18 19 20 21
22 23 24 25

OUT Matrix:
0 0 1 1
1 1 1 1
1 1 20 21
22 23 24 25

And with the filter *starpu_vertical_block_filter_func*

IN Matrix:
10 11 12 13
14 15 16 17
18 19 20 21
22 23 24 25

OUT Matrix:
0 0 0 0
0 0 0 0
1 1 1 1
1 1 1 1

So it is working fine with *starpu_vertical_block_filter_func*, but not with *starpu_block_filter_func*.

Any ideas on what's wrong ....

Thanks,

Nathalie
/*
 * StarPU
 * Copyright (C) INRIA 2008-2009 (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>

#define NX    4
#define NY    4
#define PARTS 2

void cpu_func(void *buffers[], void *cl_arg)
{
        unsigned i, j;
        int *factor = cl_arg;

        /* length of the matrix */
        unsigned nx = STARPU_GET_MATRIX_NX(buffers[0]);
        unsigned ny = STARPU_GET_MATRIX_NY(buffers[0]);
        /* local copy of the matrix pointer */
        int *val = (int *)STARPU_GET_MATRIX_PTR(buffers[0]);

        for(j=0; j<ny ; j++) {
                for(i=0; i<nx ; i++)
                        val[(j*nx)+i] = *factor;
        }
}

int main(int argc, char **argv)
{
	unsigned i, j, n=10;
        int matrix[NX*NY];
        starpu_data_handle handle;
        int factor=1;

        starpu_codelet cl = {
                .where = STARPU_CPU,
                .cpu_func = cpu_func,
                .nbuffers = 1
        };

        fprintf(stderr,"IN  Matrix: \n");
        for(j=0 ; j<NY ; j++) {
                for(i=0 ; i<NX ; i++) {
                        matrix[(j*NX)+i] = n++;
                        fprintf(stderr, "%d ", matrix[(j*NX)+i]);
                }
                fprintf(stderr,"\n");
        }
        fprintf(stderr,"\n");

	starpu_init(NULL);

	/* Declare data to StarPU */
	starpu_matrix_data_register(&handle, 0, (uintptr_t)matrix, NX, NX, NY, sizeof(matrix[0]));

        /* Partition the matrix in PARTS sub-matrices */
	struct starpu_data_filter f =
	{
		.filter_func = starpu_vertical_block_filter_func,
		.nchildren = PARTS,
		.get_nchildren = NULL,
		.get_child_ops = NULL
	};
	starpu_data_partition(handle, &f);

        /* Submit a task on each sub-vector */
	for (i=0; i<PARTS; i++)
	{
                starpu_data_handle sub_handle = starpu_data_get_sub_data(handle, 1, i);
                struct starpu_task *task = starpu_task_create();

                factor = i;//10;
		task->buffers[0].handle = sub_handle;
		task->buffers[0].mode = STARPU_RW;
                task->cl = &cl;
                task->synchronous = 1;
                task->cl_arg = &factor;
                task->cl_arg_size = sizeof(factor);

		starpu_task_submit(task);
	}

	starpu_data_unpartition(handle, 0);
        starpu_data_unregister(handle);
	starpu_shutdown();

        fprintf(stderr,"OUT Matrix: \n");
        for(j=0 ; j<NY ; j++) {
                for(i=0 ; i<NX ; i++) {
                        fprintf(stderr, "%2d ", matrix[(j*NX)+i]);
                }
                fprintf(stderr,"\n");
        }
        fprintf(stderr,"\n");

	return 0;
}



Archives gérées par MHonArc 2.6.19+.

Haut de le page