瀏覽代碼

Fix running stencil in simgrid

Samuel Thibault 10 年之前
父節點
當前提交
0630c33945

+ 5 - 1
examples/stencil/stencil-blocks.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2013  Université de Bordeaux
+ * Copyright (C) 2010, 2013-2014  Université de Bordeaux
  *
  * 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
@@ -254,6 +254,7 @@ static void allocate_block_on_node(starpu_data_handle_t *handleptr, TYPE **ptr,
 	size_t block_size = nx*ny*nz*sizeof(TYPE);
 
 	/* Allocate memory */
+#ifndef STARPU_SIMGRID
 #if 1
 	ret = starpu_malloc((void **)ptr, block_size);
 	STARPU_ASSERT(ret == 0);
@@ -266,6 +267,7 @@ static void allocate_block_on_node(starpu_data_handle_t *handleptr, TYPE **ptr,
 
 	/* Fill the blocks with 0 */
 	memset(*ptr, 0, block_size);
+#endif
 
 	/* Register it to StarPU */
 	starpu_block_data_register(handleptr, STARPU_MAIN_RAM, (uintptr_t)*ptr, nx, nx*ny, nx, ny, nz, sizeof(TYPE));
@@ -299,6 +301,7 @@ void allocate_memory_on_node(int rank)
 		{
 			allocate_block_on_node(&block->layers_handle[0], &block->layers[0],
 						(sizex + 2*K), (sizey + 2*K), (size_bz + 2*K));
+#ifndef STARPU_SIMGRID
 #ifdef LIFE
 			unsigned x, y, z;
 			unsigned sum = 0;
@@ -309,6 +312,7 @@ void allocate_memory_on_node(int rank)
 						sum += block->layers[0][(K+x)+(K+y)*(sizex + 2*K)+(K+z)*(sizex+2*K)*(sizey+2*K)] = (int)((x/7.+y/13.+(bz*size_bz + z)/17.) * 10.) % 2;
 /*			printf("block %d starts with %d/%d alive\n", bz, sum, sizex*sizey*size_bz);*/
 #endif
+#endif
 			allocate_block_on_node(&block->layers_handle[1], &block->layers[1],
 						(sizex + 2*K), (sizey + 2*K), (size_bz + 2*K));
 		}

+ 3 - 3
examples/stencil/stencil-kernels.c

@@ -189,7 +189,7 @@ static void update_func_cuda(void *descr[], void *arg)
 		FPRINTF(stderr,"!!! DO update_func_cuda z %d CUDA%d !!!\n", block->bz, workerid);
 	else
 		DEBUG( "!!! DO update_func_cuda z %d CUDA%d !!!\n", block->bz, workerid);
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	int rank = 0;
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	DEBUG( "!!!           RANK %d              !!!\n", rank);
@@ -277,7 +277,7 @@ static void update_func_opencl(void *descr[], void *arg)
 		FPRINTF(stderr,"!!! DO update_func_opencl z %d OPENCL%d !!!\n", block->bz, workerid);
 	else
 		DEBUG( "!!! DO update_func_opencl z %d OPENCL%d !!!\n", block->bz, workerid);
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	int rank = 0;
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	DEBUG( "!!!           RANK %d              !!!\n", rank);
@@ -347,7 +347,7 @@ void update_func_cpu(void *descr[], void *arg)
 		FPRINTF(stderr,"!!! DO update_func_cpu z %d CPU%d !!!\n", block->bz, workerid);
 	else
 		DEBUG( "!!! DO update_func_cpu z %d CPU%d !!!\n", block->bz, workerid);
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	int rank = 0;
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	DEBUG( "!!!           RANK %d            !!!\n", rank);

+ 16 - 1
examples/stencil/stencil-tasks.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2013  Université de Bordeaux
+ * Copyright (C) 2010, 2013-2014  Université de Bordeaux
  * Copyright (C) 2012, 2013  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -213,6 +213,20 @@ void create_task_update(unsigned iter, unsigned z, int local_rank)
 
 /* Dummy empty codelet taking one buffer */
 void null_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg STARPU_ATTRIBUTE_UNUSED) { }
+
+static double null_cost_function(struct starpu_task *task, unsigned nimpl)
+{
+	(void) task;
+	(void) nimpl;
+	return 0.000001;
+}
+
+static struct starpu_perfmodel null_model =
+{
+	.type = STARPU_COMMON,
+	.cost_function = null_cost_function
+};
+
 static struct starpu_codelet null =
 {
 	.modes = { STARPU_W, STARPU_W },
@@ -221,6 +235,7 @@ static struct starpu_codelet null =
 	.cuda_funcs = {null_func},
 	.opencl_funcs = {null_func},
 	.nbuffers = 2,
+	.model = &null_model,
 	.name = "start"
 };
 

+ 7 - 7
examples/stencil/stencil.c

@@ -205,7 +205,7 @@ int main(int argc, char **argv)
 	int world_size;
 	int ret;
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	int thread_support;
 	if (MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &thread_support))
 	{
@@ -233,7 +233,7 @@ int main(int argc, char **argv)
 		return 77;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	starpu_mpi_init(NULL, NULL, 0);
 #endif
 
@@ -246,7 +246,7 @@ int main(int argc, char **argv)
 
 	create_tasks(rank);
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	int barrier_ret = MPI_Barrier(MPI_COMM_WORLD);
 	STARPU_ASSERT(barrier_ret == MPI_SUCCESS);
 #endif
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
 
 	end = starpu_timing_now();
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	barrier_ret = MPI_Barrier(MPI_COMM_WORLD);
 	STARPU_ASSERT(barrier_ret == MPI_SUCCESS);
 #endif
@@ -274,7 +274,7 @@ int main(int argc, char **argv)
 
 	/*display_debug(nbz, niter, rank);*/
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	starpu_mpi_shutdown();
 #endif
 
@@ -285,7 +285,7 @@ int main(int argc, char **argv)
 	double max_timing = timing;
 	double sum_timing = timing;
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	int reduce_ret;
 
 	reduce_ret = MPI_Reduce(&timing, &min_timing, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD);
@@ -366,7 +366,7 @@ int main(int argc, char **argv)
 	free_problem(rank);
 	starpu_shutdown();
 
-#ifdef STARPU_USE_MPI
+#if defined(STARPU_USE_MPI) && !defined(STARPU_SIMGRID)
 	MPI_Finalize();
 #endif