Corentin Salingue 12 år sedan
förälder
incheckning
4ee76c347d

+ 3 - 1
doc/chapters/sc_hypervisor.texi

@@ -106,7 +106,9 @@ parallel kernels and the number of instruction to be executed by each task.
 The number of flops to be executed by a context are passed as parameter when they are registered to the hypervisor,
  (@code{sc_hypervisor_register_ctx(sched_ctx_id, flops)}) and the one to be executed by each task are passed when the task is submitted.
 The corresponding field in the @code{starpu_task} data structure is @code{flops} and
-the corresponding macro in @code{starpu_insert_task} function is @code{STARPU_FLOPS}. When the task is executed
+the corresponding macro in @code{starpu_insert_task} function is
+@code{STARPU_FLOPS} (but take care of passing a double, not an integer, otherwise
+parameter passing will be bogus). When the task is executed
 the resizing process is triggered.
 @cartouche
 @smallexample

+ 4 - 6
examples/basic_examples/vector_scal.c

@@ -111,14 +111,12 @@ int main(int argc, char **argv)
 	/* Initialize StarPU with default configuration */
 	int ret = starpu_init(NULL);
 
-	unsigned dd = starpu_disk_register(&write_on_file, (void *) "/home/corentin/");
+	unsigned dd = starpu_disk_register(&write_on_file, (void *) "/tmp/", 1024*1024*15);;
 
-	unsigned dc = starpu_disk_register(&write_on_file, (void *) "/home/corentin/");
+	uintptr_t pstt = starpu_malloc_on_node(dd, (1024*1024*15)-1);
+	starpu_free_on_node(dd, pstt, (1024*1024*15)-1);
 
-
-	starpu_disk_free(dc);
-
-	starpu_disk_free(dd);
+	starpu_disk_unregister(dd);
 
 	if (ret == -ENODEV) goto enodev;
 

+ 0 - 1
src/datawizard/malloc.c

@@ -347,7 +347,6 @@ starpu_malloc_on_node(unsigned dst_node, size_t size)
 #ifdef STARPU_USE_CUDA
 	cudaError_t status;
 #endif
-
 	if (_starpu_memory_manager_can_allocate_size(size, dst_node) == 0)
 		return 0;
 

+ 22 - 32
src/datawizard/memalloc.c

@@ -73,44 +73,34 @@ void _starpu_deinit_mem_chunk_lists(void)
 
 static void lock_all_subtree(starpu_data_handle_t handle)
 {
-	if (handle->nchildren == 0)
-	{
-		/* this is a leaf */
-		while (_starpu_spin_trylock(&handle->header_lock))
-			_starpu_datawizard_progress(_starpu_memory_node_get_local_key(), 0);
-	}
-	else
+	unsigned child;
+
+	/* lock parent */
+	while (_starpu_spin_trylock(&handle->header_lock))
+		_starpu_datawizard_progress(_starpu_memory_node_get_local_key(), 0);
+
+	/* lock all sub-subtrees children */
+	for (child = 0; child < handle->nchildren; child++)
 	{
-		/* lock all sub-subtrees children */
-		unsigned child;
-		for (child = 0; child < handle->nchildren; child++)
-		{
-			starpu_data_handle_t child_handle = starpu_data_get_child(handle, child);
-			lock_all_subtree(child_handle);
-		}
+		starpu_data_handle_t child_handle = starpu_data_get_child(handle, child);
+		lock_all_subtree(child_handle);
 	}
 }
 
 static void unlock_all_subtree(starpu_data_handle_t handle)
 {
-	if (handle->nchildren == 0)
-	{
-		/* this is a leaf */
-		_starpu_spin_unlock(&handle->header_lock);
-	}
-	else
+	/* lock all sub-subtrees children
+	 * Note that this is done in the reverse order of the
+	 * lock_all_subtree so that we avoid deadlock */
+	unsigned i;
+	for (i =0; i < handle->nchildren; i++)
 	{
-		/* lock all sub-subtrees children
-		 * Note that this is done in the reverse order of the
-		 * lock_all_subtree so that we avoid deadlock */
-		unsigned i;
-		for (i =0; i < handle->nchildren; i++)
-		{
-			unsigned child = handle->nchildren - 1 - i;
-			starpu_data_handle_t child_handle = starpu_data_get_child(handle, child);
-			unlock_all_subtree(child_handle);
-		}
+		unsigned child = handle->nchildren - 1 - i;
+		starpu_data_handle_t child_handle = starpu_data_get_child(handle, child);
+		unlock_all_subtree(child_handle);
 	}
+
+	_starpu_spin_unlock(&handle->header_lock);
 }
 
 static unsigned may_free_subtree(starpu_data_handle_t handle, unsigned node)
@@ -336,7 +326,7 @@ static size_t try_to_free_mem_chunk(struct _starpu_mem_chunk *mc, unsigned node)
 	}
 	else
 	{
-		/* try to lock all the leafs of the subtree */
+		/* try to lock all the subtree */
 		lock_all_subtree(handle);
 
 		/* check if they are all "free" */
@@ -418,7 +408,7 @@ static unsigned try_to_reuse_mem_chunk(struct _starpu_mem_chunk *mc, unsigned no
 
 	STARPU_ASSERT(old_data);
 
-	/* try to lock all the leafs of the subtree */
+	/* try to lock all the subtree */
 	lock_all_subtree(old_data);
 
 	/* check if they are all "free" */

+ 1 - 1
src/datawizard/memory_manager.c

@@ -59,7 +59,7 @@ int _starpu_memory_manager_can_allocate_size(size_t size, unsigned node)
 		used_size[node] += size;
 		ret = 1;
 	}
-	else if (used_size[node] + size < global_size[node])
+	else if (used_size[node] + size <= global_size[node])
 	{
 		used_size[node] += size;
 		ret = 1;