瀏覽代碼

Add more debugging information on assertions

Samuel Thibault 12 年之前
父節點
當前提交
2e901e9bd8

+ 7 - 5
src/core/dependencies/tags.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux 1
+ * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -327,6 +327,9 @@ void _starpu_tag_declare(starpu_tag_t id, struct _starpu_job *job)
 
 void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array)
 {
+	if (!ndeps)
+		return;
+
 	unsigned i;
 
 	/* create the associated completion group */
@@ -336,8 +339,6 @@ void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t
 	struct _starpu_cg *cg = create_cg_tag(ndeps, tag_child);
 	_starpu_spin_unlock(&tag_child->lock);
 
-	STARPU_ASSERT(ndeps != 0);
-
 	for (i = 0; i < ndeps; i++)
 	{
 		starpu_tag_t dep_id = array[i];
@@ -364,6 +365,9 @@ void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t
 
 void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...)
 {
+	if (!ndeps)
+		return;
+
 	unsigned i;
 
 	/* create the associated completion group */
@@ -373,8 +377,6 @@ void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...)
 	struct _starpu_cg *cg = create_cg_tag(ndeps, tag_child);
 	_starpu_spin_unlock(&tag_child->lock);
 
-	STARPU_ASSERT(ndeps != 0);
-
 	va_list pa;
 	va_start(pa, ndeps);
 	for (i = 0; i < ndeps; i++)

+ 7 - 7
src/core/perfmodel/perfmodel_bus.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux 1
+ * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -126,8 +126,8 @@ static void measure_bandwidth_between_host_and_dev_on_cpu_with_cuda(int dev, int
 
 	/* Allocate a buffer on the device */
 	unsigned char *d_buffer;
-	cudaMalloc((void **)&d_buffer, size);
-	STARPU_ASSERT(d_buffer);
+	cures = cudaMalloc((void **)&d_buffer, size);
+	STARPU_ASSERT(cures == cudaSuccess);
 
 	/* hack to avoid third party libs to rebind threads */
 	_starpu_bind_thread_on_cpu(config, cpu);
@@ -240,8 +240,8 @@ static void measure_bandwidth_between_dev_and_dev_cuda(int src, int dst)
 
 	/* Allocate a buffer on the device */
 	unsigned char *s_buffer;
-	cudaMalloc((void **)&s_buffer, size);
-	STARPU_ASSERT(s_buffer);
+	cures = cudaMalloc((void **)&s_buffer, size);
+	STARPU_ASSERT(cures == cudaSuccess);
 	cudaMemset(s_buffer, 0, size);
 
 	/* Initialize CUDA context on the destination */
@@ -260,8 +260,8 @@ static void measure_bandwidth_between_dev_and_dev_cuda(int src, int dst)
 
 	/* Allocate a buffer on the device */
 	unsigned char *d_buffer;
-	cudaMalloc((void **)&d_buffer, size);
-	STARPU_ASSERT(d_buffer);
+	cures = cudaMalloc((void **)&d_buffer, size);
+	STARPU_ASSERT(cures == cudaSuccess);
 	cudaMemset(d_buffer, 0, size);
 
 	unsigned iter;

+ 1 - 1
src/core/perfmodel/perfmodel_history.c

@@ -687,7 +687,7 @@ static void save_history_based_model(struct starpu_perfmodel *model)
 	/* overwrite existing file, or create it */
 	FILE *f;
 	f = fopen(path, "w+");
-	STARPU_ASSERT(f);
+	STARPU_ASSERT_MSG(f, "Could not save performance model %s\n", path);
 
 	dump_model_file(f, model);
 

+ 3 - 3
src/core/task.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux 1
+ * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011  INRIA
@@ -363,7 +363,7 @@ int starpu_task_submit(struct starpu_task *task)
 {
 	_STARPU_LOG_IN();
 	STARPU_ASSERT(task);
-	STARPU_ASSERT(task->magic == 42);
+	STARPU_ASSERT_MSG(task->magic == 42, "Tasks must be created with starpu_task_create, or initialized with starpu_task_init.");
 
 	int ret;
 	unsigned is_sync = task->synchronous;
@@ -404,7 +404,7 @@ int starpu_task_submit(struct starpu_task *task)
 		unsigned i;
 
 		/* Check buffers */
-		STARPU_ASSERT(task->cl->nbuffers <= STARPU_NMAXBUFS);
+		STARPU_ASSERT_MSG(task->cl->nbuffers <= STARPU_NMAXBUFS, "Codelet %p has too many buffers (%d vs max %d)", task->cl, task->cl->nbuffers, STARPU_NMAXBUFS);
 		for (i = 0; i < task->cl->nbuffers; i++)
 		{
 			starpu_data_handle_t handle = task->handles[i];

+ 2 - 2
src/core/task_bundle.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011  Université de Bordeaux 1
+ * Copyright (C) 2011, 2013  Université de Bordeaux 1
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2012  Inria
  *
@@ -103,7 +103,7 @@ int starpu_task_bundle_remove(starpu_task_bundle_t bundle, struct starpu_task *t
 		return -ENOENT;
 	}
 
-	STARPU_ASSERT(task->bundle == bundle);
+	STARPU_ASSERT_MSG(task->bundle == bundle, "Task %p was not in bundle %p, but in bundle %p", task, bundle, task->bundle);
 	task->bundle = NULL;
 
 	if (item->task == task)

+ 3 - 3
src/datawizard/coherency.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux 1
+ * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -556,9 +556,9 @@ void _starpu_release_data_on_node(starpu_data_handle_t handle, uint32_t default_
 
 	/* Release refcnt taken by fetch_data_on_node */
 	replicate->refcnt--;
-	STARPU_ASSERT(replicate->refcnt >= 0);
+	STARPU_ASSERT_MSG(replicate->refcnt >= 0, "handle %p released too many times", handle);
 
-	STARPU_ASSERT(handle->busy_count > 0);
+	STARPU_ASSERT_MSG(handle->busy_count > 0, "handle %p released too many times", handle);
 	handle->busy_count--;
 
 	if (!_starpu_notify_data_dependencies(handle))

+ 2 - 2
src/datawizard/filters.c

@@ -75,7 +75,7 @@ int starpu_data_get_nb_children(starpu_data_handle_t handle)
 
 starpu_data_handle_t starpu_data_get_child(starpu_data_handle_t handle, unsigned i)
 {
-	STARPU_ASSERT(i < handle->nchildren);
+	STARPU_ASSERT_MSG(i < handle->nchildren, "Invalid child index %u, maximum %u", i, handle->nchildren);
 	return &handle->children[i];
 }
 
@@ -130,7 +130,7 @@ void starpu_data_partition(starpu_data_handle_t initial_handle, struct starpu_da
 	else
 	  nparts = f->nchildren;
 
-	STARPU_ASSERT(nparts > 0);
+	STARPU_ASSERT_MSG(nparts > 0, "Partitioning in 0 piece does not make sense");
 
 	/* allocate the children */
 	starpu_data_create_children(initial_handle, nparts, f);

+ 7 - 6
src/datawizard/interfaces/block_filters.c

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2013  Université de Bordeaux 1
  *
  * 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
@@ -29,7 +30,7 @@ void starpu_block_filter_func_block(void *father_interface, void *child_interfac
         uint32_t nz = block_father->nz;
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT(nparts <= nx);
+	STARPU_ASSERT_MSG(nparts <= nx, "%u parts for %u elements", nparts, nx);
 
 	uint32_t chunk_size;
 	size_t offset;
@@ -66,7 +67,7 @@ void starpu_block_shadow_filter_func_block(void *father_interface, void *child_i
         uint32_t nz = block_father->nz;
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT(nparts <= nx);
+	STARPU_ASSERT_MSG(nparts <= nx, "%u parts for %u elements", nparts, nx);
 
 	uint32_t child_nx;
 	size_t offset;
@@ -101,7 +102,7 @@ void starpu_vertical_block_filter_func_block(void *father_interface, void *child
         uint32_t nz = block_father->nz;
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT(nparts <= ny);
+	STARPU_ASSERT_MSG(nparts <= ny, "%u parts for %u elements", nparts, ny);
 
 	uint32_t child_ny;
 	size_t offset;
@@ -138,7 +139,7 @@ void starpu_vertical_block_shadow_filter_func_block(void *father_interface, void
         uint32_t nz = block_father->nz;
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT(nparts <= ny);
+	STARPU_ASSERT_MSG(nparts <= ny, "%u parts for %u elements", nparts, ny);
 
 	uint32_t child_ny;
 	size_t offset;
@@ -174,7 +175,7 @@ void starpu_depth_block_filter_func_block(void *father_interface, void *child_in
         uint32_t nz = block_father->nz;
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT(nparts <= nz);
+	STARPU_ASSERT_MSG(nparts <= nz, "%u parts for %u elements", nparts, nz);
 
 	uint32_t child_nz;
 	size_t offset;
@@ -212,7 +213,7 @@ void starpu_depth_block_shadow_filter_func_block(void *father_interface, void *c
         uint32_t nz = block_father->nz - 2 * shadow_size;
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT(nparts <= nz);
+	STARPU_ASSERT_MSG(nparts <= nz, "%u parts for %u elements", nparts, nz);
 
 	uint32_t child_nz;
 	size_t offset;

+ 5 - 5
src/datawizard/interfaces/matrix_filters.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-2013  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
@@ -32,7 +32,7 @@ void starpu_block_filter_func(void *father_interface, void *child_interface, STA
 	uint32_t ny = matrix_father->ny;
 	size_t elemsize = matrix_father->elemsize;
 
-	STARPU_ASSERT(nchunks <= nx);
+	STARPU_ASSERT_MSG(nchunks <= nx, "%u parts for %u elements", nchunks, nx);
 
 	uint32_t child_nx;
 	size_t offset;
@@ -71,7 +71,7 @@ void starpu_block_shadow_filter_func(void *father_interface, void *child_interfa
 	uint32_t ny = matrix_father->ny;
 	size_t elemsize = matrix_father->elemsize;
 
-	STARPU_ASSERT(nchunks <= nx);
+	STARPU_ASSERT_MSG(nchunks <= nx, "%u parts for %u elements", nchunks, nx);
 
 	uint32_t child_nx;
 	size_t offset;
@@ -106,7 +106,7 @@ void starpu_vertical_block_filter_func(void *father_interface, void *child_inter
 	uint32_t ny = matrix_father->ny;
 	size_t elemsize = matrix_father->elemsize;
 
-	STARPU_ASSERT(nchunks <= ny);
+	STARPU_ASSERT_MSG(nchunks <= ny, "%u parts for %u elements", nchunks, ny);
 
 	uint32_t child_ny;
 	size_t offset;
@@ -142,7 +142,7 @@ void starpu_vertical_block_shadow_filter_func(void *father_interface, void *chil
 	uint32_t ny = matrix_father->ny - 2 * shadow_size;
 	size_t elemsize = matrix_father->elemsize;
 
-	STARPU_ASSERT(nchunks <= ny);
+	STARPU_ASSERT_MSG(nchunks <= ny, "%u parts for %u elements", nchunks, ny);
 
 	uint32_t child_ny;
 	size_t offset;

+ 5 - 5
src/datawizard/interfaces/vector_filters.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux 1
+ * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
@@ -28,7 +28,7 @@ void starpu_block_filter_func_vector(void *father_interface, void *child_interfa
 	uint32_t nx = vector_father->nx;
 	size_t elemsize = vector_father->elemsize;
 
-	STARPU_ASSERT(nchunks <= nx);
+	STARPU_ASSERT_MSG(nchunks <= nx, "%u parts for %u elements", nchunks, nx);
 
 	uint32_t child_nx;
 	size_t offset;
@@ -59,7 +59,7 @@ void starpu_block_shadow_filter_func_vector(void *father_interface, void *child_
 	uint32_t nx = vector_father->nx - 2 * shadow_size;
 	size_t elemsize = vector_father->elemsize;
 
-	STARPU_ASSERT(nchunks <= nx);
+	STARPU_ASSERT_MSG(nchunks <= nx, "%u parts for %u elements", nchunks, nx);
 
 	uint32_t child_nx;
 	size_t offset;
@@ -83,7 +83,7 @@ void starpu_block_shadow_filter_func_vector(void *father_interface, void *child_
 void starpu_vector_divide_in_2_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, STARPU_ATTRIBUTE_UNUSED unsigned nchunks)
 {
         /* there cannot be more than 2 chunks */
-        STARPU_ASSERT(id < 2);
+	STARPU_ASSERT_MSG(id < 2, "Only %d parts", id);
 
 	struct starpu_vector_interface *vector_father = (struct starpu_vector_interface *) father_interface;
 	struct starpu_vector_interface *vector_child = (struct starpu_vector_interface *) child_interface;
@@ -93,7 +93,7 @@ void starpu_vector_divide_in_2_filter_func(void *father_interface, void *child_i
 	uint32_t nx = vector_father->nx;
 	size_t elemsize = vector_father->elemsize;
 
-	STARPU_ASSERT(length_first < nx);
+	STARPU_ASSERT_MSG(length_first < nx, "First part is too long: %u vs %u", length_first, nx);
 
 	/* this is the first child */
 	if (id == 0)

+ 2 - 2
src/datawizard/memory_nodes.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux 1
+ * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -196,7 +196,7 @@ unsigned starpu_worker_get_memory_node(unsigned workerid)
 
 	/* We have a combined worker */
 	unsigned ncombinedworkers = config->topology.ncombinedworkers;
-	STARPU_ASSERT(workerid < ncombinedworkers + nworkers);
+	STARPU_ASSERT_MSG(workerid < ncombinedworkers + nworkers, "Bad workerid %u, maximum %u", workerid, ncombinedworkers + nworkers);
 	return config->combined_workers[workerid - nworkers].memory_node;
 
 }