浏览代码

Allocate dynamically an array used only while reducing data

Samuel Thibault 11 年之前
父节点
当前提交
bbbf1610c4
共有 4 个文件被更改,包括 8 次插入2 次删除
  1. 1 1
      src/datawizard/coherency.h
  2. 1 0
      src/datawizard/filters.c
  3. 1 0
      src/datawizard/interfaces/data_interface.c
  4. 5 1
      src/datawizard/reduction.c

+ 1 - 1
src/datawizard/coherency.h

@@ -206,7 +206,7 @@ struct _starpu_data_state
 	 * the end of the reduction. */
 	 * the end of the reduction. */
 	struct _starpu_data_requester_list *reduction_req_list;
 	struct _starpu_data_requester_list *reduction_req_list;
 
 
-	starpu_data_handle_t reduction_tmp_handles[STARPU_NMAXWORKERS];
+	starpu_data_handle_t *reduction_tmp_handles;
 
 
 	unsigned lazy_unregister;
 	unsigned lazy_unregister;
 
 

+ 1 - 0
src/datawizard/filters.c

@@ -176,6 +176,7 @@ void starpu_data_partition(starpu_data_handle_t initial_handle, struct starpu_da
 		/* initialize the chunk lock */
 		/* initialize the chunk lock */
 		child->req_list = _starpu_data_requester_list_new();
 		child->req_list = _starpu_data_requester_list_new();
 		child->reduction_req_list = _starpu_data_requester_list_new();
 		child->reduction_req_list = _starpu_data_requester_list_new();
+		child->reduction_tmp_handles = NULL;
 		child->refcnt = 0;
 		child->refcnt = 0;
 		child->busy_count = 0;
 		child->busy_count = 0;
 		child->busy_waiting = 0;
 		child->busy_waiting = 0;

+ 1 - 0
src/datawizard/interfaces/data_interface.c

@@ -213,6 +213,7 @@ static void _starpu_register_new_data(starpu_data_handle_t handle,
 
 
 	handle->reduction_refcnt = 0;
 	handle->reduction_refcnt = 0;
 	handle->reduction_req_list = _starpu_data_requester_list_new();
 	handle->reduction_req_list = _starpu_data_requester_list_new();
+	handle->reduction_tmp_handles = NULL;
 
 
 #ifdef STARPU_USE_FXT
 #ifdef STARPU_USE_FXT
 	handle->last_submitted_ghost_sync_id_is_valid = 0;
 	handle->last_submitted_ghost_sync_id_is_valid = 0;

+ 5 - 1
src/datawizard/reduction.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010-2013  Université de Bordeaux 1
+ * Copyright (C) 2010-2014  Université de Bordeaux 1
  * Copyright (C) 2011, 2012, 2013  Centre National de la Recherche Scientifique
  * Copyright (C) 2011, 2012, 2013  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -156,6 +156,8 @@ void _starpu_data_end_reduction_mode(starpu_data_handle_t handle)
 
 
 	/* Register all valid per-worker replicates */
 	/* Register all valid per-worker replicates */
 	unsigned nworkers = starpu_worker_get_count();
 	unsigned nworkers = starpu_worker_get_count();
+	STARPU_ASSERT(!handle->reduction_tmp_handles);
+	handle->reduction_tmp_handles = malloc(nworkers * sizeof(handle->reduction_tmp_handles[0]));
 	for (worker = 0; worker < nworkers; worker++)
 	for (worker = 0; worker < nworkers; worker++)
 	{
 	{
 		if (handle->per_worker[worker].initialized)
 		if (handle->per_worker[worker].initialized)
@@ -390,4 +392,6 @@ void _starpu_data_end_reduction_mode_terminate(starpu_data_handle_t handle)
 			/* TODO put in cache */
 			/* TODO put in cache */
 		}
 		}
 	}
 	}
+	free(handle->reduction_tmp_handles);
+	handle->reduction_tmp_handles = NULL;
 }
 }