Browse Source

src: minor fixes w.r.tg warnings detected by gcc compiler

Nathalie Furmento 13 years ago
parent
commit
0433b3cc32

+ 1 - 0
src/common/starpu_spinlock.c

@@ -17,6 +17,7 @@
 
 
 #include <common/starpu_spinlock.h>
 #include <common/starpu_spinlock.h>
 #include <common/config.h>
 #include <common/config.h>
+#include <common/utils.h>
 #include <starpu_util.h>
 #include <starpu_util.h>
 
 
 int _starpu_spin_init(struct _starpu_spinlock *lock)
 int _starpu_spin_init(struct _starpu_spinlock *lock)

+ 1 - 1
src/common/utils.c

@@ -77,7 +77,7 @@ int _starpu_check_mutex_deadlock(pthread_mutex_t *mutex)
 	ret = pthread_mutex_trylock(mutex);
 	ret = pthread_mutex_trylock(mutex);
 	if (!ret)
 	if (!ret)
 	{
 	{
-		pthread_mutex_unlock(mutex);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
 		return 0;
 		return 0;
 	}
 	}
 
 

+ 4 - 0
src/common/utils.h

@@ -77,4 +77,8 @@ void _starpu_drop_comments(FILE *f);
 #define _STARPU_PTHREAD_BARRIER_DESTROY(barrier) { int p_ret = pthread_barrier_destroy((barrier)); if (STARPU_UNLIKELY(p_ret)) { fprintf(stderr, "pthread_barrier_destroy : %s\n", strerror(p_ret)); STARPU_ABORT();}}
 #define _STARPU_PTHREAD_BARRIER_DESTROY(barrier) { int p_ret = pthread_barrier_destroy((barrier)); if (STARPU_UNLIKELY(p_ret)) { fprintf(stderr, "pthread_barrier_destroy : %s\n", strerror(p_ret)); STARPU_ABORT();}}
 #define _STARPU_PTHREAD_BARRIER_WAIT(barrier) { int p_ret = pthread_barrier_wait(barrier); if (STARPU_UNLIKELY(!((p_ret == 0) || (p_ret == PTHREAD_BARRIER_SERIAL_THREAD)))) { fprintf(stderr, "pthread_barrier_wait : %s\n", strerror(p_ret)); STARPU_ABORT();}}
 #define _STARPU_PTHREAD_BARRIER_WAIT(barrier) { int p_ret = pthread_barrier_wait(barrier); if (STARPU_UNLIKELY(!((p_ret == 0) || (p_ret == PTHREAD_BARRIER_SERIAL_THREAD)))) { fprintf(stderr, "pthread_barrier_wait : %s\n", strerror(p_ret)); STARPU_ABORT();}}
 
 
+#define _STARPU_PTHREAD_SPIN_DESTROY(lock) { int p_ret = pthread_spin_destroy(lock); if (STARPU_UNLIKELY(p_ret)) { fprintf(stderr, "pthread_spin_destroy : %s\n", strerror(p_ret)); STARPU_ABORT();}}
+#define _STARPU_PTHREAD_SPIN_LOCK(lock) { int p_ret = pthread_spin_lock(lock);  if (STARPU_UNLIKELY(p_ret)) { fprintf(stderr, "pthread_spin_lock : %s\n", strerror(p_ret)); STARPU_ABORT();}}
+#define _STARPU_PTHREAD_SPIN_UNLOCK(lock) { int p_ret = pthread_spin_unlock(lock);  if (STARPU_UNLIKELY(p_ret)) { fprintf(stderr, "pthread_spin_unlock : %s\n", strerror(p_ret)); STARPU_ABORT();}}
+
 #endif // __COMMON_UTILS_H__
 #endif // __COMMON_UTILS_H__

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

@@ -207,7 +207,7 @@ static void parse_per_arch_model_file(FILE *f, struct starpu_per_arch_perfmodel
 	}
 	}
 }
 }
 
 
-static void parse_arch(FILE *f, struct starpu_perfmodel *model, unsigned scan_history, unsigned archmin, unsigned archmax, int skiparch)
+static void parse_arch(FILE *f, struct starpu_perfmodel *model, unsigned scan_history, unsigned archmin, unsigned archmax, unsigned skiparch)
 {
 {
 	struct starpu_per_arch_perfmodel dummy;
 	struct starpu_per_arch_perfmodel dummy;
 	int nimpls, implmax, skipimpl, impl;
 	int nimpls, implmax, skipimpl, impl;

+ 1 - 3
src/core/task.c

@@ -398,8 +398,6 @@ int _starpu_task_submit_nodeps(struct starpu_task *task)
 int _starpu_task_submit_conversion_task(struct starpu_task *task,
 int _starpu_task_submit_conversion_task(struct starpu_task *task,
 					unsigned int workerid)
 					unsigned int workerid)
 {
 {
-	int ret;
-
 	STARPU_ASSERT(task->cl);
 	STARPU_ASSERT(task->cl);
 	STARPU_ASSERT(task->execute_on_a_specific_worker);
 	STARPU_ASSERT(task->execute_on_a_specific_worker);
 
 
@@ -574,7 +572,7 @@ void _starpu_set_current_task(struct starpu_task *task)
 int
 int
 _starpu_task_uses_multiformat_handles(struct starpu_task *task)
 _starpu_task_uses_multiformat_handles(struct starpu_task *task)
 {
 {
-	int i;
+	unsigned i;
 	for (i = 0; i < task->cl->nbuffers; i++)
 	for (i = 0; i < task->cl->nbuffers; i++)
 	{
 	{
 		unsigned int id;
 		unsigned int id;

+ 3 - 0
src/core/task.h

@@ -53,6 +53,9 @@ int _starpu_handle_needs_conversion_task(starpu_data_handle_t handle,
 
 
 int _starpu_task_uses_multiformat_handles(struct starpu_task *task);
 int _starpu_task_uses_multiformat_handles(struct starpu_task *task);
 
 
+int _starpu_task_submit_conversion_task(struct starpu_task *task,
+					unsigned int workerid);
+
 void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl);
 void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl);
 starpu_cpu_func_t _starpu_task_get_cpu_nth_implementation(struct starpu_codelet *cl, unsigned nimpl);
 starpu_cpu_func_t _starpu_task_get_cpu_nth_implementation(struct starpu_codelet *cl, unsigned nimpl);
 starpu_cuda_func_t _starpu_task_get_cuda_nth_implementation(struct starpu_codelet *cl, unsigned nimpl);
 starpu_cuda_func_t _starpu_task_get_cuda_nth_implementation(struct starpu_codelet *cl, unsigned nimpl);

+ 4 - 4
src/datawizard/coherency.c

@@ -562,7 +562,7 @@ void _starpu_release_data_on_node(starpu_data_handle_t handle, uint32_t default_
 static void _starpu_set_data_requested_flag_if_needed(struct _starpu_data_replicate *replicate)
 static void _starpu_set_data_requested_flag_if_needed(struct _starpu_data_replicate *replicate)
 {
 {
 // XXX : this is just a hint, so we don't take the lock ...
 // XXX : this is just a hint, so we don't take the lock ...
-//	pthread_spin_lock(&handle->header_lock);
+//	_STARPU_PTHREAD_SPIN_LOCK(&handle->header_lock);
 
 
 	if (replicate->state == STARPU_INVALID)
 	if (replicate->state == STARPU_INVALID)
 	{
 	{
@@ -570,7 +570,7 @@ static void _starpu_set_data_requested_flag_if_needed(struct _starpu_data_replic
 		replicate->requested[dst_node] = 1;
 		replicate->requested[dst_node] = 1;
 	}
 	}
 
 
-//	pthread_spin_unlock(&handle->header_lock);
+//	_STARPU_PTHREAD_SPIN_UNLOCK(&handle->header_lock);
 }
 }
 
 
 int starpu_prefetch_task_input_on_node(struct starpu_task *task, uint32_t node)
 int starpu_prefetch_task_input_on_node(struct starpu_task *task, uint32_t node)
@@ -737,7 +737,7 @@ unsigned _starpu_is_data_present_or_requested(starpu_data_handle_t handle, uint3
 	unsigned ret = 0;
 	unsigned ret = 0;
 
 
 // XXX : this is just a hint, so we don't take the lock ...
 // XXX : this is just a hint, so we don't take the lock ...
-//	pthread_spin_lock(&handle->header_lock);
+//	_STARPU_PTHREAD_SPIN_LOCK(&handle->header_lock);
 
 
 	if (handle->per_node[node].state != STARPU_INVALID)
 	if (handle->per_node[node].state != STARPU_INVALID)
 	{
 	{
@@ -756,7 +756,7 @@ unsigned _starpu_is_data_present_or_requested(starpu_data_handle_t handle, uint3
 
 
 	}
 	}
 
 
-//	pthread_spin_unlock(&handle->header_lock);
+//	_STARPU_PTHREAD_SPIN_UNLOCK(&handle->header_lock);
 
 
 	return ret;
 	return ret;
 }
 }

+ 1 - 1
src/datawizard/datastats.c

@@ -113,7 +113,7 @@ void _starpu_display_alloc_cache_stats(void)
 static size_t comm_amount[STARPU_MAXNODES][STARPU_MAXNODES];
 static size_t comm_amount[STARPU_MAXNODES][STARPU_MAXNODES];
 #endif /* STARPU_DATA_STATS */
 #endif /* STARPU_DATA_STATS */
 
 
-void _starpu_comm_amounts_inc(unsigned src, unsigned dst, size_t size)
+void _starpu_comm_amounts_inc(unsigned src  __attribute__ ((unused)), unsigned dst  __attribute__ ((unused)), size_t size  __attribute__ ((unused)))
 {
 {
 #ifdef STARPU_DATA_STATS
 #ifdef STARPU_DATA_STATS
 	comm_amount[src][dst] += size;
 	comm_amount[src][dst] += size;

+ 8 - 5
src/datawizard/interfaces/multiformat_interface.c

@@ -22,6 +22,7 @@
 #include <starpu_cuda.h>
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <starpu_opencl.h>
 #include <drivers/opencl/driver_opencl.h>
 #include <drivers/opencl/driver_opencl.h>
+#include <core/task.h>
 
 
 static int copy_ram_to_ram(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node);
 static int copy_ram_to_ram(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node);
 #ifdef STARPU_USE_CUDA
 #ifdef STARPU_USE_CUDA
@@ -374,8 +375,8 @@ static ssize_t allocate_multiformat_buffer_on_node(void *data_interface_, uint32
 /*
 /*
  * Copy methods
  * Copy methods
  */
  */
-static int copy_ram_to_ram(void *src_interface, unsigned src_node,
-			   void *dst_interface, unsigned dst_node)
+static int copy_ram_to_ram(void *src_interface, unsigned src_node __attribute__ ((unused)),
+			   void *dst_interface, unsigned dst_node __attribute__ ((unused)))
 {
 {
 	struct starpu_multiformat_interface *src_multiformat;
 	struct starpu_multiformat_interface *src_multiformat;
 	struct starpu_multiformat_interface *dst_multiformat;
 	struct starpu_multiformat_interface *dst_multiformat;
@@ -394,8 +395,8 @@ static int copy_ram_to_ram(void *src_interface, unsigned src_node,
 }
 }
 
 
 #ifdef STARPU_USE_CUDA
 #ifdef STARPU_USE_CUDA
-static int copy_cuda_common(void *src_interface, unsigned src_node,
-			    void *dst_interface, unsigned dst_node,
+static int copy_cuda_common(void *src_interface, unsigned src_node __attribute__ ((unused)),
+			    void *dst_interface, unsigned dst_node __attribute__ ((unused)),
 			    enum cudaMemcpyKind kind)
 			    enum cudaMemcpyKind kind)
 {
 {
 	struct starpu_multiformat_interface *src_multiformat;
 	struct starpu_multiformat_interface *src_multiformat;
@@ -460,7 +461,9 @@ static int copy_cuda_to_ram(void *src_interface, unsigned src_node STARPU_ATTRIB
 	return copy_cuda_common(src_interface, src_node, dst_interface, dst_node, cudaMemcpyDeviceToHost);
 	return copy_cuda_common(src_interface, src_node, dst_interface, dst_node, cudaMemcpyDeviceToHost);
 }
 }
 
 
-static int copy_cuda_common_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cudaStream_t stream, enum cudaMemcpyKind kind)
+static int copy_cuda_common_async(void *src_interface, unsigned src_node __attribute__ ((unused)),
+				  void *dst_interface, unsigned dst_node __attribute__ ((unused)),
+				  cudaStream_t stream, enum cudaMemcpyKind kind)
 {
 {
 	struct starpu_multiformat_interface *src_multiformat;
 	struct starpu_multiformat_interface *src_multiformat;
 	struct starpu_multiformat_interface *dst_multiformat;
 	struct starpu_multiformat_interface *dst_multiformat;

+ 7 - 5
src/top/starpu_top.c

@@ -26,6 +26,7 @@
 #include <math.h>
 #include <math.h>
 #include <pthread.h>
 #include <pthread.h>
 #include <common/timing.h>
 #include <common/timing.h>
+#include <common/utils.h>
 
 
 extern struct _starpu_top_message_queue*  _starpu_top_mt;
 extern struct _starpu_top_message_queue*  _starpu_top_mt;
 int starpu_top = 0;
 int starpu_top = 0;
@@ -131,7 +132,7 @@ void starpu_top_init_and_wait(const char* server_name)
 	starpu_top=1;
 	starpu_top=1;
 	sem_init(&starpu_top_wait_for_go,0,0);
 	sem_init(&starpu_top_wait_for_go,0,0);
 
 
-	pthread_mutex_init(&starpu_top_wait_for_continue_mutex, NULL);
+	_STARPU_PTHREAD_MUTEX_INIT(&starpu_top_wait_for_continue_mutex, NULL);
 
 
 	//profiling activation
 	//profiling activation
 	starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 	starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
@@ -609,9 +610,10 @@ void starpu_top_debug_lock(const char* debug_message)
 		_starpu_top_message_add(_starpu_top_mt,message);
 		_starpu_top_message_add(_starpu_top_mt,message);
 
 
 		//This threads keeps locked while we don't receive an STEP message
 		//This threads keeps locked while we don't receive an STEP message
-		pthread_mutex_lock(&starpu_top_wait_for_continue_mutex);
-		pthread_cond_wait(&starpu_top_wait_for_continue_cond,&starpu_top_wait_for_continue_mutex);
-		pthread_mutex_unlock(&starpu_top_wait_for_continue_mutex);
+		_STARPU_PTHREAD_MUTEX_LOCK(&starpu_top_wait_for_continue_mutex);
+		_STARPU_PTHREAD_COND_WAIT(&starpu_top_wait_for_continue_cond,
+					  &starpu_top_wait_for_continue_mutex);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&starpu_top_wait_for_continue_mutex);
 	}
 	}
 }
 }
 
 
@@ -728,7 +730,7 @@ void starpu_top_change_debug_mode(const char*message)
 */
 */
 void starpu_top_debug_next_step()
 void starpu_top_debug_next_step()
 {
 {
-	pthread_cond_signal(&starpu_top_wait_for_continue_cond);
+	_STARPU_PTHREAD_COND_SIGNAL(&starpu_top_wait_for_continue_cond);
 }
 }
 
 
 
 

+ 13 - 12
src/top/starpu_top_message_queue.c

@@ -15,10 +15,11 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
  */
 
 
-#include  "starpu_top_message_queue.h"
-#include  <string.h>
-#include  <stdio.h>
-#include  <stdlib.h>
+#include "starpu_top_message_queue.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <common/utils.h>
 
 
 //this global queue is used both by API and by network threads
 //this global queue is used both by API and by network threads
 struct _starpu_top_message_queue*  _starpu_top_mt = NULL;
 struct _starpu_top_message_queue*  _starpu_top_mt = NULL;
@@ -29,11 +30,11 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 							char* msg)
 							char* msg)
 {
 {
 	struct _starpu_top_message_queue_item* p = (struct _starpu_top_message_queue_item *) malloc( 1 * sizeof(*p) );
 	struct _starpu_top_message_queue_item* p = (struct _starpu_top_message_queue_item *) malloc( 1 * sizeof(*p) );
-	pthread_mutex_lock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
 	if( NULL == p )
 	if( NULL == p )
 	{
 	{
 		fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
 		fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
-		pthread_mutex_unlock(&(s->mutex));
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 		return s;
 	}
 	}
 
 
@@ -43,7 +44,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 	if( NULL == s )
 	if( NULL == s )
 	{
 	{
 		printf("Queue not initialized\n");
 		printf("Queue not initialized\n");
-		pthread_mutex_unlock(&(s->mutex));
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 		return s;
 	}
 	}
 	else if( NULL == s->head && NULL == s->tail )
 	else if( NULL == s->head && NULL == s->tail )
@@ -51,7 +52,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 		/* printf("Empty list, adding p->num: %d\n\n", p->num);  */
 		/* printf("Empty list, adding p->num: %d\n\n", p->num);  */
 		sem_post(&(s->semaphore));
 		sem_post(&(s->semaphore));
 		s->head = s->tail = p;
 		s->head = s->tail = p;
-		pthread_mutex_unlock(&(s->mutex));
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 		return s;
 	}
 	}
 	else
 	else
@@ -61,7 +62,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 		s->tail->next = p;
 		s->tail->next = p;
 		s->tail = p;
 		s->tail = p;
 	}
 	}
-	pthread_mutex_unlock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 	return s;
 	return s;
 }
 }
 
 
@@ -77,7 +78,7 @@ char* _starpu_top_message_remove(struct _starpu_top_message_queue* s)
 		printf("List is null\n");
 		printf("List is null\n");
 		return NULL;
 		return NULL;
 	}
 	}
-	pthread_mutex_lock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
 	h = s->head;
 	h = s->head;
 	p = h->next;
 	p = h->next;
 	char* value = h->message;
 	char* value = h->message;
@@ -88,7 +89,7 @@ char* _starpu_top_message_remove(struct _starpu_top_message_queue* s)
 	if( NULL == s->head )
 	if( NULL == s->head )
 		//the element tail was pointing to is free(), so we need an update
 		//the element tail was pointing to is free(), so we need an update
 		s->tail = s->head;
 		s->tail = s->head;
-	pthread_mutex_unlock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 	return value;
 	return value;
 }
 }
 
 
@@ -104,6 +105,6 @@ struct _starpu_top_message_queue* _starpu_top_message_queue_new(void)
 
 
 	p->head = p->tail = NULL;
 	p->head = p->tail = NULL;
 	sem_init(&(p->semaphore),0,0);
 	sem_init(&(p->semaphore),0,0);
-	pthread_mutex_init(&(p->mutex), NULL);
+	_STARPU_PTHREAD_MUTEX_INIT(&(p->mutex), NULL);
 	return p;
 	return p;
 }
 }

+ 1 - 1
src/util/starpu_task_list.c

@@ -123,7 +123,7 @@ struct starpu_task *starpu_task_list_begin(struct starpu_task_list *list)
 	return list->head;
 	return list->head;
 }
 }
 
 
-struct starpu_task *starpu_task_list_end(struct starpu_task_list *list)
+struct starpu_task *starpu_task_list_end(struct starpu_task_list *list __attribute__ ((unused)))
 {
 {
 	return NULL;
 	return NULL;
 }
 }