Explorar o código

port r11348 from trunk Add bitmap implementation

Samuel Thibault %!s(int64=11) %!d(string=hai) anos
pai
achega
684d1b5788
Modificáronse 5 ficheiros con 76 adicións e 58 borrados
  1. 3 2
      AUTHORS
  2. 1 0
      Makefile.am
  3. 47 0
      include/starpu_bitmap.h
  4. 1 30
      include/starpu_sched_node.h
  5. 24 26
      src/sched_policies/bitmap.c

+ 3 - 2
AUTHORS

@@ -1,3 +1,4 @@
+Simon Archipoff <simon.archipoff@etu.u-bordeaux1.fr>
 Cédric Augonnet <cedric.augonnet@inria.fr>
 William Braik <wbraik@gmail.com>
 Jérôme Clet-Ortega <jerome.clet-ortega@labri.fr>
@@ -8,9 +9,11 @@ Jean-Marie Couteyen <jm.couteyen@gmail.com>
 Nathalie Furmento <nathalie.furmento@labri.fr>
 David Gómez <david_gomez1380@yahoo.com.mx>
 Sylvain Henry <sylvain.henry@inria.fr>
+Andra Hugo <andra.hugo@inria.fr>
 Mehdi Juhoor <mjuhoor@gmail.com>
 Antoine Lucas <antoine.lucas.33@gmail.com>
 Brice Mortier <brice.mortier@etu.u-bordeaux1.fr>
+Joris Pablo <joris.pablo@orange.fr>
 Damien Pasqualinotto <dam.pasqualinotto@wanadoo.fr>
 Nguyen Quôc-Dinh <nguyen.quocdinh@gmail.com>
 Cyril Roelandt <cyril.roelandt@inria.fr>
@@ -20,5 +23,3 @@ Ludovic Stordeur <ludovic.stordeur@inria.fr>
 François Tessier <francois.tessier@inria.fr>
 Samuel Thibault <samuel.thibault@labri.fr>
 Pierre-André Wacrenier <wacrenier@labri.fr>
-Andra Hugo <andra.hugo@inria.fr>
-Simon Archipoff <simon.archipoff@etu.u-bordeaux1.fr>

+ 1 - 0
Makefile.am

@@ -54,6 +54,7 @@ pkgconfig_DATA = libstarpu.pc starpu-1.0.pc starpu-1.1.pc
 versincludedir = $(includedir)/starpu/$(STARPU_EFFECTIVE_VERSION)
 versinclude_HEADERS = 				\
 	include/starpu.h			\
+	include/starpu_bitmap.h			\
 	include/starpu_data_filters.h		\
 	include/starpu_data_interfaces.h	\
 	include/starpu_worker.h			\

+ 47 - 0
include/starpu_bitmap.h

@@ -0,0 +1,47 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2013  Simon Archipoff
+ *
+ * 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_BITMAP_H__
+#define __STARPU_BITMAP_H__
+struct starpu_bitmap * starpu_bitmap_create(void);
+void starpu_bitmap_destroy(struct starpu_bitmap *);
+
+void starpu_bitmap_set(struct starpu_bitmap *, int);
+void starpu_bitmap_unset(struct starpu_bitmap *, int);
+void starpu_bitmap_unset_all(struct starpu_bitmap *);
+
+int starpu_bitmap_get(struct starpu_bitmap *, int);
+
+/* basicaly compute starpu_bitmap_unset_all(a) ; a = b & c; */
+void starpu_bitmap_unset_and(struct starpu_bitmap * a, struct starpu_bitmap * b, struct starpu_bitmap * c);
+
+/* this is basically compute a |= b;*/
+void starpu_bitmap_or(struct starpu_bitmap * a,
+		       struct starpu_bitmap * b);
+
+//return 1 iff e set in b1 AND e set in b2
+int starpu_bitmap_and_get(struct starpu_bitmap * b1,
+			   struct starpu_bitmap * b2,
+			   int e);
+
+int starpu_bitmap_cardinal(struct starpu_bitmap *);
+
+//return the index of first bit, -1 if none
+int starpu_bitmap_first(struct starpu_bitmap *);
+int starpu_bitmap_last(struct starpu_bitmap *);
+//return the index of bit right after e, -1 if none
+int starpu_bitmap_next(struct starpu_bitmap *, int e);
+#endif

+ 1 - 30
include/starpu_sched_node.h

@@ -18,6 +18,7 @@
 #define __STARPU_SCHED_NODE_H__
 #include <starpu.h>
 #include <common/starpu_spinlock.h>
+#include <starpu_bitmap.h>
 
 #ifdef STARPU_HAVE_HWLOC
 #include <hwloc.h>
@@ -218,36 +219,6 @@ void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task);
 
 
 
-struct starpu_bitmap * starpu_bitmap_create(void);
-void starpu_bitmap_destroy(struct starpu_bitmap *);
-
-void starpu_bitmap_set(struct starpu_bitmap *, int);
-void starpu_bitmap_unset(struct starpu_bitmap *, int);
-void starpu_bitmap_unset_all(struct starpu_bitmap *);
-
-int starpu_bitmap_get(struct starpu_bitmap *, int);
-
-/* basicaly compute starpu_bitmap_unset_all(a) ; a = b & c; */
-void starpu_bitmap_unset_and(struct starpu_bitmap * a, struct starpu_bitmap * b, struct starpu_bitmap * c);
-
-/* this is basically compute a |= b;*/
-void starpu_bitmap_or(struct starpu_bitmap * a,
-		       struct starpu_bitmap * b);
-
-//return 1 iff e set in b1 AND e set in b2
-int starpu_bitmap_and_get(struct starpu_bitmap * b1,
-			   struct starpu_bitmap * b2,
-			   int e);
-
-int starpu_bitmap_cardinal(struct starpu_bitmap *);
-
-//return the index of first bit, -1 if none
-int starpu_bitmap_first(struct starpu_bitmap *);
-int starpu_bitmap_last(struct starpu_bitmap *);
-//return the index of bit right after e, -1 if none
-int starpu_bitmap_next(struct starpu_bitmap *, int e);
-
-
 struct starpu_sched_node_composed_recipe;
 
 /* create empty recipe */

+ 24 - 26
src/sched_policies/bitmap.c

@@ -15,7 +15,7 @@
  */
 
 #include <starpu.h>
-#include <starpu_sched_node.h>
+#include <starpu_bitmap.h>
 
 #include <limits.h>
 #include <string.h>
@@ -25,8 +25,6 @@
 #define LONG_BIT (sizeof(unsigned long) * 8)
 #endif
 
-
-
 struct starpu_bitmap
 {
 	unsigned long * bits;
@@ -34,8 +32,29 @@ struct starpu_bitmap
 	int cardinal;
 };
 
-#ifndef STARPU_NO_ASSERT
-static int check_bitmap(struct starpu_bitmap *b);
+//#define DEBUG_BITMAP
+
+#ifdef DEBUG_BITMAP
+static int check_bitmap(struct starpu_bitmap *b)
+{
+	int card = b->cardinal;
+	int i = starpu_bitmap_first(b);
+	int j;
+	for(j = 0; j < card; j++)
+	{
+		if(i == -1)
+			return 0;
+		int tmp = starpu_bitmap_next(b,i);
+		if(tmp == i)
+			return 0;
+		i = tmp;
+	}
+	if(i != -1)
+		return 0;
+	return 1;
+}
+#else
+#define check_bitmap(b) 1
 #endif
 
 static int _count_bit(unsigned long e)
@@ -243,24 +262,3 @@ int starpu_bitmap_next(struct starpu_bitmap *b, int e)
 			return nb_long * LONG_BIT + get_first_bit_rank(b->bits[nb_long]);
 	return -1;
 }
-
-#ifndef STARPU_NO_ASSERT
-static int check_bitmap(struct starpu_bitmap *b)
-{
-	int card = b->cardinal;
-	int i = starpu_bitmap_first(b);
-	int j;
-	for(j = 0; j < card; j++)
-	{
-		if(i == -1)
-			return 0;
-		int tmp = starpu_bitmap_next(b,i);
-		if(tmp == i)
-			return 0;
-		i = tmp;
-	}
-	if(i != -1)
-		return 0;
-	return 1;
-}
-#endif