소스 검색

port r11388 from 1.1: Allocate RAM memory immediately, without using requests

Samuel Thibault 11 년 전
부모
커밋
245bdafca2
4개의 변경된 파일24개의 추가작업 그리고 6개의 파일을 삭제
  1. 19 1
      src/datawizard/coherency.c
  2. 1 1
      src/datawizard/filters.c
  3. 2 2
      src/datawizard/interfaces/data_interface.c
  4. 2 2
      src/datawizard/memalloc.c

+ 19 - 1
src/datawizard/coherency.c

@@ -428,12 +428,30 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
 	/* find someone who already has the data */
 	unsigned src_node = 0;
 
-	/* if the data is in write only mode, there is no need for a source */
 	if (mode & STARPU_R)
 	{
 		src_node = _starpu_select_src_node(handle, requesting_node);
 		STARPU_ASSERT(src_node != requesting_node);
 	}
+	else
+	{
+		/* if the data is in write only mode, there is no need for a source */
+		if (requesting_node == 0) {
+			/* And this is the main RAM, really no need for a
+			 * request, just allocate */
+			if (_starpu_allocate_memory_on_node(handle, dst_replicate, is_prefetch) == 0)
+			{
+				_starpu_update_data_state(handle, dst_replicate, mode);
+
+				_starpu_spin_unlock(&handle->header_lock);
+
+				if (callback_func)
+					callback_func(callback_arg);
+				_STARPU_LOG_OUT_TAG("data immediately allocated");
+				return NULL;
+			}
+		}
+	}
 
 	/* We can safely assume that there won't be more than 2 hops in the
 	 * current implementation */

+ 1 - 1
src/datawizard/filters.c

@@ -258,7 +258,7 @@ void starpu_data_partition(starpu_data_handle_t initial_handle, struct starpu_da
 		child->footprint = _starpu_compute_data_footprint(child);
 
 		void *ptr;
-		ptr = starpu_data_handle_to_pointer(child, 0);
+		ptr = starpu_data_handle_to_pointer(child, STARPU_MAIN_RAM);
 		if (ptr != NULL)
 			_starpu_data_register_ram_pointer(child, ptr);
 	}

+ 2 - 2
src/datawizard/interfaces/data_interface.c

@@ -283,7 +283,7 @@ static void _starpu_register_new_data(starpu_data_handle_t handle,
 	/* now the data is available ! */
 	_starpu_spin_unlock(&handle->header_lock);
 
-	ptr = starpu_data_handle_to_pointer(handle, 0);
+	ptr = starpu_data_handle_to_pointer(handle, STARPU_MAIN_RAM);
 	if (ptr != NULL)
 	{
 		_starpu_data_register_ram_pointer(handle, ptr);
@@ -476,7 +476,7 @@ void _starpu_data_free_interfaces(starpu_data_handle_t handle)
 	unsigned worker;
 	unsigned nworkers = starpu_worker_get_count();
 
-	ram_ptr = starpu_data_handle_to_pointer(handle, 0);
+	ram_ptr = starpu_data_handle_to_pointer(handle, STARPU_MAIN_RAM);
 
 	for (node = 0; node < STARPU_MAXNODES; node++)
 		free(handle->per_node[node].data_interface);

+ 2 - 2
src/datawizard/memalloc.c

@@ -941,9 +941,9 @@ int _starpu_allocate_memory_on_node(starpu_data_handle_t handle, struct _starpu_
 	replicate->allocated = 1;
 	replicate->automatically_allocated = 1;
 
-	if (dst_node == 0)
+	if (dst_node == STARPU_MAIN_RAM)
 	{
-		void *ptr = starpu_data_handle_to_pointer(handle, 0);
+		void *ptr = starpu_data_handle_to_pointer(handle, STARPU_MAIN_RAM);
 		if (ptr != NULL)
 		{
 			_starpu_data_register_ram_pointer(handle, ptr);