Kaynağa Gözat

move implementation of starpu_task_list functions in public .h file

Nathalie Furmento 11 yıl önce
ebeveyn
işleme
8f69d75bdd

+ 0 - 3
include/starpu.h

@@ -53,9 +53,6 @@ typedef UINT_PTR uintptr_t;
 #include <starpu_worker.h>
 #include <starpu_task.h>
 #include <starpu_task_list.h>
-#ifdef BUILDING_STARPU
-#include <util/starpu_task_list_inline.h>
-#endif
 #include <starpu_task_util.h>
 #include <starpu_sched_ctx.h>
 #include <starpu_expert.h>

+ 128 - 18
include/starpu_task_list.h

@@ -18,6 +18,7 @@
 #define __STARPU_TASK_LIST_H__
 
 #include <starpu_task.h>
+#include <starpu_util.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -30,25 +31,134 @@ struct starpu_task_list
 	struct starpu_task *tail;
 };
 
-/* If we are building starpu and not using gnu inline, we have to avoid
- * declaring the functions extern, as in that case the compiler will compile
- * the inline into all .o files! */
-#if !defined(BUILDING_STARPU) || defined(__GNUC_GNU_INLINE__)
-
-void starpu_task_list_init(struct starpu_task_list *list);
-void starpu_task_list_push_front(struct starpu_task_list *list, struct starpu_task *task);
-void starpu_task_list_push_back(struct starpu_task_list *list, struct starpu_task *task);
-struct starpu_task *starpu_task_list_front(struct starpu_task_list *list);
-struct starpu_task *starpu_task_list_back(struct starpu_task_list *list);
-int starpu_task_list_empty(struct starpu_task_list *list);
-void starpu_task_list_erase(struct starpu_task_list *list, struct starpu_task *task);
-struct starpu_task *starpu_task_list_pop_front(struct starpu_task_list *list);
-struct starpu_task *starpu_task_list_pop_back(struct starpu_task_list *list);
-struct starpu_task *starpu_task_list_begin(struct starpu_task_list *list);
-struct starpu_task *starpu_task_list_end(struct starpu_task_list *list);
-struct starpu_task *starpu_task_list_next(struct starpu_task *task);
+static STARPU_INLINE
+void starpu_task_list_init(struct starpu_task_list *list)
+{
+	list->head = NULL;
+	list->tail = NULL;
+}
 
-#endif
+static STARPU_INLINE
+void starpu_task_list_push_front(struct starpu_task_list *list,
+				struct starpu_task *task)
+{
+	if (list->tail == NULL)
+	{
+		list->tail = task;
+	}
+	else
+	{
+		list->head->prev = task;
+	}
+
+	task->prev = NULL;
+	task->next = list->head;
+	list->head = task;
+}
+
+static STARPU_INLINE
+void starpu_task_list_push_back(struct starpu_task_list *list,
+				struct starpu_task *task)
+{
+	if (list->head == NULL)
+	{
+		list->head = task;
+	}
+	else
+	{
+		list->tail->next = task;
+	}
+
+	task->next = NULL;
+	task->prev = list->tail;
+	list->tail = task;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_front(struct starpu_task_list *list)
+{
+	return list->head;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_back(struct starpu_task_list *list)
+{
+	return list->tail;
+}
+
+static STARPU_INLINE
+int starpu_task_list_empty(struct starpu_task_list *list)
+{
+	return (list->head == NULL);
+}
+
+static STARPU_INLINE
+void starpu_task_list_erase(struct starpu_task_list *list,
+				struct starpu_task *task)
+{
+	struct starpu_task *p = task->prev;
+
+	if (p)
+	{
+		p->next = task->next;
+	}
+	else
+	{
+		list->head = task->next;
+	}
+
+	if (task->next)
+	{
+		task->next->prev = p;
+	}
+	else
+	{
+		list->tail = p;
+	}
+
+	task->prev = NULL;
+	task->next = NULL;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_pop_front(struct starpu_task_list *list)
+{
+	struct starpu_task *task = list->head;
+
+	if (task)
+		starpu_task_list_erase(list, task);
+
+	return task;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_pop_back(struct starpu_task_list *list)
+{
+	struct starpu_task *task = list->tail;
+
+	if (task)
+		starpu_task_list_erase(list, task);
+
+	return task;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_begin(struct starpu_task_list *list)
+{
+	return list->head;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_end(struct starpu_task_list *list STARPU_ATTRIBUTE_UNUSED)
+{
+	return NULL;
+}
+
+static STARPU_INLINE
+struct starpu_task *starpu_task_list_next(struct starpu_task *task)
+{
+	return task->next;
+}
 
 #ifdef __cplusplus
 }

+ 3 - 11
include/starpu_thread_util.h

@@ -21,14 +21,6 @@
 #include <starpu_util.h>
 #include <errno.h>
 
-#ifndef STARPU_INLINE
-#ifdef __GNUC_GNU_INLINE__
-#define STARPU_INLINE extern inline
-#else
-#define STARPU_INLINE inline
-#endif
-#endif
-
 /*
  * Encapsulation of the starpu_pthread_create_* functions.
  */
@@ -89,7 +81,7 @@
 
 #define STARPU_PTHREAD_MUTEX_TRYLOCK(mutex) \
 	_STARPU_PTHREAD_MUTEX_TRYLOCK(mutex, __FILE__, __LINE__)
-STARPU_INLINE
+static STARPU_INLINE
 int _STARPU_PTHREAD_MUTEX_TRYLOCK(starpu_pthread_mutex_t *mutex, char *file, int line)
 {
 	int p_ret = starpu_pthread_mutex_trylock(mutex);
@@ -169,7 +161,7 @@ int _STARPU_PTHREAD_MUTEX_TRYLOCK(starpu_pthread_mutex_t *mutex, char *file, int
 
 #define STARPU_PTHREAD_RWLOCK_TRYRDLOCK(rwlock) \
 	_starpu_pthread_rwlock_tryrdlock(rwlock, __FILE__, __LINE__)
-STARPU_INLINE
+static STARPU_INLINE
 int _starpu_pthread_rwlock_tryrdlock(starpu_pthread_rwlock_t *rwlock, char *file, int line)
 {
 	int p_ret = starpu_pthread_rwlock_tryrdlock(rwlock);
@@ -194,7 +186,7 @@ int _starpu_pthread_rwlock_tryrdlock(starpu_pthread_rwlock_t *rwlock, char *file
 
 #define STARPU_PTHREAD_RWLOCK_TRYWRLOCK(rwlock) \
 	_starpu_pthread_rwlock_trywrlock(rwlock, __FILE__, __LINE__)
-STARPU_INLINE
+static STARPU_INLINE
 int _starpu_pthread_rwlock_trywrlock(starpu_pthread_rwlock_t *rwlock, char *file, int line)
 {
 	int p_ret = starpu_pthread_rwlock_trywrlock(rwlock);

+ 10 - 0
include/starpu_util.h

@@ -57,6 +57,16 @@ extern "C"
 #  define STARPU_ATTRIBUTE_ALIGNED(size)
 #endif
 
+/* Note that if we're compiling C++, then just use the "inline"
+   keyword, since it's part of C++ */
+#if defined(c_plusplus) || defined(__cplusplus)
+#  define STARPU_INLINE inline
+#elif defined(_MSC_VER) || defined(__HP_cc)
+#  define STARPU_INLINE __inline
+#else
+#  define STARPU_INLINE __inline__
+#endif
+
 #if STARPU_GNUC_PREREQ(3, 1) && !defined(BUILDING_STARPU) && !defined(STARPU_USE_DEPRECATED_API) && !defined(STARPU_USE_DEPRECATED_ONE_ZERO_API)
 #define STARPU_DEPRECATED  __attribute__((__deprecated__))
 #else

+ 0 - 2
src/Makefile.am

@@ -129,7 +129,6 @@ noinst_HEADERS = 						\
 	profiling/profiling.h					\
 	util/starpu_task_insert_utils.h				\
 	util/starpu_data_cpy.h					\
-	util/starpu_task_list_inline.h				\
 	starpu_parameters.h					\
 	top/starpu_top_message_queue.h				\
 	top/starpu_top_connection.h				\
@@ -227,7 +226,6 @@ libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
 	util/starpu_data_cpy.c					\
 	util/starpu_task_insert.c				\
 	util/starpu_task_insert_utils.c				\
-	util/starpu_inlines.c					\
 	debug/traces/starpu_fxt.c				\
 	debug/traces/starpu_fxt_mpi.c				\
 	debug/traces/starpu_fxt_dag.c				\

+ 0 - 18
src/util/starpu_inlines.c

@@ -1,18 +0,0 @@
-/* StarPU --- Runtime system for heterogeneous multicore architectures.
- *
- * Copyright (C) 2012  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
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * StarPU is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#define STARPU_INLINE
-#include <starpu.h>

+ 0 - 158
src/util/starpu_task_list_inline.h

@@ -1,158 +0,0 @@
-/* StarPU --- Runtime system for heterogeneous multicore architectures.
- *
- * Copyright (C) 2010-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
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * StarPU is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#ifndef __STARPU_TASK_LIST_INLINE_H
-#define __STARPU_TASK_LIST_INLINE_H
-
-#include <starpu_task.h>
-
-#ifndef STARPU_INLINE
-#ifdef __GNUC_GNU_INLINE__
-#define STARPU_INLINE extern inline
-#else
-#define STARPU_INLINE static inline
-#endif
-#endif
-
-STARPU_INLINE
-void starpu_task_list_init(struct starpu_task_list *list)
-{
-	list->head = NULL;
-	list->tail = NULL;
-}
-
-STARPU_INLINE
-void starpu_task_list_push_front(struct starpu_task_list *list,
-				struct starpu_task *task)
-{
-	if (list->tail == NULL)
-	{
-		list->tail = task;
-	}
-	else
-	{
-		list->head->prev = task;
-	}
-
-	task->prev = NULL;
-	task->next = list->head;
-	list->head = task;
-}
-
-STARPU_INLINE
-void starpu_task_list_push_back(struct starpu_task_list *list,
-				struct starpu_task *task)
-{
-	if (list->head == NULL)
-	{
-		list->head = task;
-	}
-	else
-	{
-		list->tail->next = task;
-	}
-
-	task->next = NULL;
-	task->prev = list->tail;
-	list->tail = task;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_front(struct starpu_task_list *list)
-{
-	return list->head;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_back(struct starpu_task_list *list)
-{
-	return list->tail;
-}
-
-STARPU_INLINE
-int starpu_task_list_empty(struct starpu_task_list *list)
-{
-	return (list->head == NULL);
-}
-
-STARPU_INLINE
-void starpu_task_list_erase(struct starpu_task_list *list,
-				struct starpu_task *task)
-{
-	struct starpu_task *p = task->prev;
-
-	if (p)
-	{
-		p->next = task->next;
-	}
-	else
-	{
-		list->head = task->next;
-	}
-
-	if (task->next)
-	{
-		task->next->prev = p;
-	}
-	else
-	{
-		list->tail = p;
-	}
-
-	task->prev = NULL;
-	task->next = NULL;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_pop_front(struct starpu_task_list *list)
-{
-	struct starpu_task *task = list->head;
-
-	if (task)
-		starpu_task_list_erase(list, task);
-
-	return task;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_pop_back(struct starpu_task_list *list)
-{
-	struct starpu_task *task = list->tail;
-
-	if (task)
-		starpu_task_list_erase(list, task);
-
-	return task;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_begin(struct starpu_task_list *list)
-{
-	return list->head;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_end(struct starpu_task_list *list STARPU_ATTRIBUTE_UNUSED)
-{
-	return NULL;
-}
-
-STARPU_INLINE
-struct starpu_task *starpu_task_list_next(struct starpu_task *task)
-{
-	return task->next;
-}
-#endif /* __STARPU_TASK_LIST_INLINE_H */