Browse Source

src: fix indent

Nathalie Furmento 3 years ago
parent
commit
a58e6f059e

+ 314 - 314
src/common/rbtree.c

@@ -38,15 +38,15 @@
 static inline int starpu_rbtree_index(const struct starpu_rbtree_node *node,
                                const struct starpu_rbtree_node *parent)
 {
-    assert(parent != NULL);
-    assert((node == NULL) || (starpu_rbtree_parent(node) == parent));
+	assert(parent != NULL);
+	assert((node == NULL) || (starpu_rbtree_parent(node) == parent));
 
-    if (parent->children[STARPU_RBTREE_LEFT] == node)
-        return STARPU_RBTREE_LEFT;
+	if (parent->children[STARPU_RBTREE_LEFT] == node)
+		return STARPU_RBTREE_LEFT;
 
-    assert(parent->children[STARPU_RBTREE_RIGHT] == node);
+	assert(parent->children[STARPU_RBTREE_RIGHT] == node);
 
-    return STARPU_RBTREE_RIGHT;
+	return STARPU_RBTREE_RIGHT;
 }
 
 /*
@@ -54,7 +54,7 @@ static inline int starpu_rbtree_index(const struct starpu_rbtree_node *node,
  */
 static inline int starpu_rbtree_color(const struct starpu_rbtree_node *node)
 {
-    return node->parent & STARPU_RBTREE_COLOR_MASK;
+	return node->parent & STARPU_RBTREE_COLOR_MASK;
 }
 
 /*
@@ -62,7 +62,7 @@ static inline int starpu_rbtree_color(const struct starpu_rbtree_node *node)
  */
 static inline int starpu_rbtree_is_red(const struct starpu_rbtree_node *node)
 {
-    return starpu_rbtree_color(node) == STARPU_RBTREE_COLOR_RED;
+	return starpu_rbtree_color(node) == STARPU_RBTREE_COLOR_RED;
 }
 
 /*
@@ -70,7 +70,7 @@ static inline int starpu_rbtree_is_red(const struct starpu_rbtree_node *node)
  */
 static inline int starpu_rbtree_is_black(const struct starpu_rbtree_node *node)
 {
-    return starpu_rbtree_color(node) == STARPU_RBTREE_COLOR_BLACK;
+	return starpu_rbtree_color(node) == STARPU_RBTREE_COLOR_BLACK;
 }
 
 /*
@@ -79,10 +79,10 @@ static inline int starpu_rbtree_is_black(const struct starpu_rbtree_node *node)
 static inline void starpu_rbtree_set_parent(struct starpu_rbtree_node *node,
                                      struct starpu_rbtree_node *parent)
 {
-    assert(starpu_rbtree_check_alignment(node));
-    assert(starpu_rbtree_check_alignment(parent));
+	assert(starpu_rbtree_check_alignment(node));
+	assert(starpu_rbtree_check_alignment(parent));
 
-    node->parent = (uintptr_t)parent | (node->parent & STARPU_RBTREE_COLOR_MASK);
+	node->parent = (uintptr_t)parent | (node->parent & STARPU_RBTREE_COLOR_MASK);
 }
 
 /*
@@ -90,8 +90,8 @@ static inline void starpu_rbtree_set_parent(struct starpu_rbtree_node *node,
  */
 static inline void starpu_rbtree_set_color(struct starpu_rbtree_node *node, int color)
 {
-    assert((color & ~STARPU_RBTREE_COLOR_MASK) == 0);
-    node->parent = (node->parent & STARPU_RBTREE_PARENT_MASK) | color;
+	assert((color & ~STARPU_RBTREE_COLOR_MASK) == 0);
+	node->parent = (node->parent & STARPU_RBTREE_PARENT_MASK) | color;
 }
 
 /*
@@ -99,7 +99,7 @@ static inline void starpu_rbtree_set_color(struct starpu_rbtree_node *node, int
  */
 static inline void starpu_rbtree_set_red(struct starpu_rbtree_node *node)
 {
-    starpu_rbtree_set_color(node, STARPU_RBTREE_COLOR_RED);
+	starpu_rbtree_set_color(node, STARPU_RBTREE_COLOR_RED);
 }
 
 /*
@@ -107,7 +107,7 @@ static inline void starpu_rbtree_set_red(struct starpu_rbtree_node *node)
  */
 static inline void starpu_rbtree_set_black(struct starpu_rbtree_node *node)
 {
-    starpu_rbtree_set_color(node, STARPU_RBTREE_COLOR_BLACK);
+	starpu_rbtree_set_color(node, STARPU_RBTREE_COLOR_BLACK);
 }
 
 /*
@@ -118,323 +118,323 @@ static inline void starpu_rbtree_set_black(struct starpu_rbtree_node *node)
  */
 static void starpu_rbtree_rotate(struct starpu_rbtree *tree, struct starpu_rbtree_node *node, int direction)
 {
-    struct starpu_rbtree_node *parent, *rnode;
-    int left, right;
+	struct starpu_rbtree_node *parent, *rnode;
+	int left, right;
 
-    left = direction;
-    right = 1 - left;
-    parent = starpu_rbtree_parent(node);
-    rnode = node->children[right];
+	left = direction;
+	right = 1 - left;
+	parent = starpu_rbtree_parent(node);
+	rnode = node->children[right];
 
-    node->children[right] = rnode->children[left];
+	node->children[right] = rnode->children[left];
 
-    if (rnode->children[left] != NULL)
-        starpu_rbtree_set_parent(rnode->children[left], node);
+	if (rnode->children[left] != NULL)
+		starpu_rbtree_set_parent(rnode->children[left], node);
 
-    rnode->children[left] = node;
-    starpu_rbtree_set_parent(rnode, parent);
+	rnode->children[left] = node;
+	starpu_rbtree_set_parent(rnode, parent);
 
-    if (unlikely(parent == NULL))
-        tree->root = rnode;
-    else
-        parent->children[starpu_rbtree_index(node, parent)] = rnode;
+	if (unlikely(parent == NULL))
+		tree->root = rnode;
+	else
+		parent->children[starpu_rbtree_index(node, parent)] = rnode;
 
-    starpu_rbtree_set_parent(node, rnode);
+	starpu_rbtree_set_parent(node, rnode);
 }
 
 void starpu_rbtree_insert_rebalance(struct starpu_rbtree *tree, struct starpu_rbtree_node *parent,
-                             int index, struct starpu_rbtree_node *node)
+				    int index, struct starpu_rbtree_node *node)
 {
-    struct starpu_rbtree_node *grand_parent, *tmp;
-
-    assert(starpu_rbtree_check_alignment(parent));
-    assert(starpu_rbtree_check_alignment(node));
-
-    node->parent = (uintptr_t)parent | STARPU_RBTREE_COLOR_RED;
-    node->children[STARPU_RBTREE_LEFT] = NULL;
-    node->children[STARPU_RBTREE_RIGHT] = NULL;
-
-    if (unlikely(parent == NULL))
-        tree->root = node;
-    else
-        parent->children[index] = node;
-
-    for (;;)
-    {
-	struct starpu_rbtree_node *uncle;
-	int left, right;
+	struct starpu_rbtree_node *grand_parent, *tmp;
 
-	if (parent == NULL)
-	{
-            starpu_rbtree_set_black(node);
-            break;
-        }
-
-        if (starpu_rbtree_is_black(parent))
-            break;
+	assert(starpu_rbtree_check_alignment(parent));
+	assert(starpu_rbtree_check_alignment(node));
 
-        grand_parent = starpu_rbtree_parent(parent);
-        assert(grand_parent != NULL);
+	node->parent = (uintptr_t)parent | STARPU_RBTREE_COLOR_RED;
+	node->children[STARPU_RBTREE_LEFT] = NULL;
+	node->children[STARPU_RBTREE_RIGHT] = NULL;
 
-        left = starpu_rbtree_index(parent, grand_parent);
-        right = 1 - left;
+	if (unlikely(parent == NULL))
+		tree->root = node;
+	else
+		parent->children[index] = node;
 
-        uncle = grand_parent->children[right];
-
-        /*
-         * Uncle is red. Flip colors and repeat at grand parent.
-         */
-        if ((uncle != NULL) && starpu_rbtree_is_red(uncle))
-	{
-            starpu_rbtree_set_black(uncle);
-            starpu_rbtree_set_black(parent);
-            starpu_rbtree_set_red(grand_parent);
-            node = grand_parent;
-            parent = starpu_rbtree_parent(node);
-            continue;
-        }
-
-        /*
-         * Node is the right child of its parent. Rotate left at parent.
-         */
-        if (parent->children[right] == node)
+	for (;;)
 	{
-            starpu_rbtree_rotate(tree, parent, left);
-            tmp = node;
-            node = parent;
-            parent = tmp;
-        }
-
-        /*
-         * Node is the left child of its parent. Handle colors, rotate right
-         * at grand parent, and leave.
-         */
-        starpu_rbtree_set_black(parent);
-        starpu_rbtree_set_red(grand_parent);
-        starpu_rbtree_rotate(tree, grand_parent, right);
-        break;
-    }
-
-    assert(starpu_rbtree_is_black(tree->root));
+		struct starpu_rbtree_node *uncle;
+		int left, right;
+
+		if (parent == NULL)
+		{
+			starpu_rbtree_set_black(node);
+			break;
+		}
+
+		if (starpu_rbtree_is_black(parent))
+			break;
+
+		grand_parent = starpu_rbtree_parent(parent);
+		assert(grand_parent != NULL);
+
+		left = starpu_rbtree_index(parent, grand_parent);
+		right = 1 - left;
+
+		uncle = grand_parent->children[right];
+
+		/*
+		 * Uncle is red. Flip colors and repeat at grand parent.
+		 */
+		if ((uncle != NULL) && starpu_rbtree_is_red(uncle))
+		{
+			starpu_rbtree_set_black(uncle);
+			starpu_rbtree_set_black(parent);
+			starpu_rbtree_set_red(grand_parent);
+			node = grand_parent;
+			parent = starpu_rbtree_parent(node);
+			continue;
+		}
+
+		/*
+		 * Node is the right child of its parent. Rotate left at parent.
+		 */
+		if (parent->children[right] == node)
+		{
+			starpu_rbtree_rotate(tree, parent, left);
+			tmp = node;
+			node = parent;
+			parent = tmp;
+		}
+
+		/*
+		 * Node is the left child of its parent. Handle colors, rotate right
+		 * at grand parent, and leave.
+		 */
+		starpu_rbtree_set_black(parent);
+		starpu_rbtree_set_red(grand_parent);
+		starpu_rbtree_rotate(tree, grand_parent, right);
+		break;
+	}
+
+	assert(starpu_rbtree_is_black(tree->root));
 }
 
 void starpu_rbtree_remove(struct starpu_rbtree *tree, struct starpu_rbtree_node *node)
 {
-    struct starpu_rbtree_node *child, *parent, *brother;
-    int color, left, right;
-
-    if (node->children[STARPU_RBTREE_LEFT] == NULL)
-        child = node->children[STARPU_RBTREE_RIGHT];
-    else if (node->children[STARPU_RBTREE_RIGHT] == NULL)
-        child = node->children[STARPU_RBTREE_LEFT];
-    else
-    {
-        struct starpu_rbtree_node *successor;
-
-        /*
-         * Two-children case: replace the node with its successor.
-         */
-
-        successor = node->children[STARPU_RBTREE_RIGHT];
-
-        while (successor->children[STARPU_RBTREE_LEFT] != NULL)
-            successor = successor->children[STARPU_RBTREE_LEFT];
-
-        color = starpu_rbtree_color(successor);
-        child = successor->children[STARPU_RBTREE_RIGHT];
-        parent = starpu_rbtree_parent(node);
-
-        if (unlikely(parent == NULL))
-            tree->root = successor;
-        else
-            parent->children[starpu_rbtree_index(node, parent)] = successor;
-
-        parent = starpu_rbtree_parent(successor);
-
-        /*
-         * Set parent directly to keep the original color.
-         */
-        successor->parent = node->parent;
-        successor->children[STARPU_RBTREE_LEFT] = node->children[STARPU_RBTREE_LEFT];
-        starpu_rbtree_set_parent(successor->children[STARPU_RBTREE_LEFT], successor);
-
-        if (node == parent)
-            parent = successor;
-        else
-	{
-            successor->children[STARPU_RBTREE_RIGHT] = node->children[STARPU_RBTREE_RIGHT];
-            starpu_rbtree_set_parent(successor->children[STARPU_RBTREE_RIGHT], successor);
-            parent->children[STARPU_RBTREE_LEFT] = child;
-
-            if (child != NULL)
-                starpu_rbtree_set_parent(child, parent);
-        }
-
-        goto update_color;
-    }
-
-    /*
-     * Node has at most one child.
-     */
-
-    color = starpu_rbtree_color(node);
-    parent = starpu_rbtree_parent(node);
-
-    if (child != NULL)
-        starpu_rbtree_set_parent(child, parent);
-
-    if (unlikely(parent == NULL))
-        tree->root = child;
-    else
-        parent->children[starpu_rbtree_index(node, parent)] = child;
-
-    /*
-     * The node has been removed, update the colors. The child pointer can
-     * be null, in which case it is considered a black leaf.
-     */
-update_color:
-    if (color == STARPU_RBTREE_COLOR_RED)
-        return;
-
-    for (;;)
-    {
-        if ((child != NULL) && starpu_rbtree_is_red(child))
+	struct starpu_rbtree_node *child, *parent, *brother;
+	int color, left, right;
+
+	if (node->children[STARPU_RBTREE_LEFT] == NULL)
+		child = node->children[STARPU_RBTREE_RIGHT];
+	else if (node->children[STARPU_RBTREE_RIGHT] == NULL)
+		child = node->children[STARPU_RBTREE_LEFT];
+	else
 	{
-            starpu_rbtree_set_black(child);
-            break;
-        }
-
-        if (parent == NULL)
-            break;
-
-        left = starpu_rbtree_index(child, parent);
-        right = 1 - left;
-
-        brother = parent->children[right];
-
-        /*
-         * Brother is red. Recolor and rotate left at parent so that brother
-         * becomes black.
-         */
-        if (starpu_rbtree_is_red(brother))
-	{
-            starpu_rbtree_set_black(brother);
-            starpu_rbtree_set_red(parent);
-            starpu_rbtree_rotate(tree, parent, left);
-            brother = parent->children[right];
-        }
-
-        /*
-         * Brother has no red child. Recolor and repeat at parent.
-         */
-        if (((brother->children[STARPU_RBTREE_LEFT] == NULL)
-             || starpu_rbtree_is_black(brother->children[STARPU_RBTREE_LEFT]))
-            && ((brother->children[STARPU_RBTREE_RIGHT] == NULL)
-                || starpu_rbtree_is_black(brother->children[STARPU_RBTREE_RIGHT])))
-	{
-            starpu_rbtree_set_red(brother);
-            child = parent;
-            parent = starpu_rbtree_parent(child);
-            continue;
-        }
-
-        /*
-         * Brother's right child is black. Recolor and rotate right at brother.
-         */
-        if ((brother->children[right] == NULL)
-            || starpu_rbtree_is_black(brother->children[right]))
+		struct starpu_rbtree_node *successor;
+
+		/*
+		 * Two-children case: replace the node with its successor.
+		 */
+
+		successor = node->children[STARPU_RBTREE_RIGHT];
+
+		while (successor->children[STARPU_RBTREE_LEFT] != NULL)
+			successor = successor->children[STARPU_RBTREE_LEFT];
+
+		color = starpu_rbtree_color(successor);
+		child = successor->children[STARPU_RBTREE_RIGHT];
+		parent = starpu_rbtree_parent(node);
+
+		if (unlikely(parent == NULL))
+			tree->root = successor;
+		else
+			parent->children[starpu_rbtree_index(node, parent)] = successor;
+
+		parent = starpu_rbtree_parent(successor);
+
+		/*
+		 * Set parent directly to keep the original color.
+		 */
+		successor->parent = node->parent;
+		successor->children[STARPU_RBTREE_LEFT] = node->children[STARPU_RBTREE_LEFT];
+		starpu_rbtree_set_parent(successor->children[STARPU_RBTREE_LEFT], successor);
+
+		if (node == parent)
+			parent = successor;
+		else
+		{
+			successor->children[STARPU_RBTREE_RIGHT] = node->children[STARPU_RBTREE_RIGHT];
+			starpu_rbtree_set_parent(successor->children[STARPU_RBTREE_RIGHT], successor);
+			parent->children[STARPU_RBTREE_LEFT] = child;
+
+			if (child != NULL)
+				starpu_rbtree_set_parent(child, parent);
+		}
+
+		goto update_color;
+	}
+
+	/*
+	 * Node has at most one child.
+	 */
+
+	color = starpu_rbtree_color(node);
+	parent = starpu_rbtree_parent(node);
+
+	if (child != NULL)
+		starpu_rbtree_set_parent(child, parent);
+
+	if (unlikely(parent == NULL))
+		tree->root = child;
+	else
+		parent->children[starpu_rbtree_index(node, parent)] = child;
+
+	/*
+	 * The node has been removed, update the colors. The child pointer can
+	 * be null, in which case it is considered a black leaf.
+	 */
+ update_color:
+	if (color == STARPU_RBTREE_COLOR_RED)
+		return;
+
+	for (;;)
 	{
-            starpu_rbtree_set_black(brother->children[left]);
-            starpu_rbtree_set_red(brother);
-            starpu_rbtree_rotate(tree, brother, right);
-            brother = parent->children[right];
-        }
-
-        /*
-         * Brother's left child is black. Exchange parent and brother colors
-         * (we already know brother is black), set brother's right child black,
-         * rotate left at parent and leave.
-         */
-        starpu_rbtree_set_color(brother, starpu_rbtree_color(parent));
-        starpu_rbtree_set_black(parent);
-        starpu_rbtree_set_black(brother->children[right]);
-        starpu_rbtree_rotate(tree, parent, left);
-        break;
-    }
-
-    assert((tree->root == NULL) || starpu_rbtree_is_black(tree->root));
+		if ((child != NULL) && starpu_rbtree_is_red(child))
+		{
+			starpu_rbtree_set_black(child);
+			break;
+		}
+
+		if (parent == NULL)
+			break;
+
+		left = starpu_rbtree_index(child, parent);
+		right = 1 - left;
+
+		brother = parent->children[right];
+
+		/*
+		 * Brother is red. Recolor and rotate left at parent so that brother
+		 * becomes black.
+		 */
+		if (starpu_rbtree_is_red(brother))
+		{
+			starpu_rbtree_set_black(brother);
+			starpu_rbtree_set_red(parent);
+			starpu_rbtree_rotate(tree, parent, left);
+			brother = parent->children[right];
+		}
+
+		/*
+		 * Brother has no red child. Recolor and repeat at parent.
+		 */
+		if (((brother->children[STARPU_RBTREE_LEFT] == NULL)
+		     || starpu_rbtree_is_black(brother->children[STARPU_RBTREE_LEFT]))
+		    && ((brother->children[STARPU_RBTREE_RIGHT] == NULL)
+			|| starpu_rbtree_is_black(brother->children[STARPU_RBTREE_RIGHT])))
+		{
+			starpu_rbtree_set_red(brother);
+			child = parent;
+			parent = starpu_rbtree_parent(child);
+			continue;
+		}
+
+		/*
+		 * Brother's right child is black. Recolor and rotate right at brother.
+		 */
+		if ((brother->children[right] == NULL)
+		    || starpu_rbtree_is_black(brother->children[right]))
+		{
+			starpu_rbtree_set_black(brother->children[left]);
+			starpu_rbtree_set_red(brother);
+			starpu_rbtree_rotate(tree, brother, right);
+			brother = parent->children[right];
+		}
+
+		/*
+		 * Brother's left child is black. Exchange parent and brother colors
+		 * (we already know brother is black), set brother's right child black,
+		 * rotate left at parent and leave.
+		 */
+		starpu_rbtree_set_color(brother, starpu_rbtree_color(parent));
+		starpu_rbtree_set_black(parent);
+		starpu_rbtree_set_black(brother->children[right]);
+		starpu_rbtree_rotate(tree, parent, left);
+		break;
+	}
+
+	assert((tree->root == NULL) || starpu_rbtree_is_black(tree->root));
 }
 
 struct starpu_rbtree_node * starpu_rbtree_nearest(struct starpu_rbtree_node *parent, int index,
-                                    int direction)
+						  int direction)
 {
-    assert(starpu_rbtree_check_index(direction));
+	assert(starpu_rbtree_check_index(direction));
 
-    if (parent == NULL)
-        return NULL;
+	if (parent == NULL)
+		return NULL;
 
-    assert(starpu_rbtree_check_index(index));
+	assert(starpu_rbtree_check_index(index));
 
-    if (index != direction)
-        return parent;
+	if (index != direction)
+		return parent;
 
-    return starpu_rbtree_walk(parent, direction);
+	return starpu_rbtree_walk(parent, direction);
 }
 
 struct starpu_rbtree_node * starpu_rbtree_firstlast(const struct starpu_rbtree *tree, int direction)
 {
-    struct starpu_rbtree_node *prev, *cur;
+	struct starpu_rbtree_node *prev, *cur;
 
-    assert(starpu_rbtree_check_index(direction));
+	assert(starpu_rbtree_check_index(direction));
 
-    prev = NULL;
+	prev = NULL;
 
-    for (cur = tree->root; cur != NULL; cur = cur->children[direction])
-        prev = cur;
+	for (cur = tree->root; cur != NULL; cur = cur->children[direction])
+		prev = cur;
 
-    return prev;
+	return prev;
 }
 
 struct starpu_rbtree_node * starpu_rbtree_walk(struct starpu_rbtree_node *node, int direction)
 {
-    int left, right;
+	int left, right;
 
-    assert(starpu_rbtree_check_index(direction));
+	assert(starpu_rbtree_check_index(direction));
 
-    left = direction;
-    right = 1 - left;
+	left = direction;
+	right = 1 - left;
 
-    if (node == NULL)
-        return NULL;
+	if (node == NULL)
+		return NULL;
 
-    if (node->children[left] != NULL)
-    {
-        node = node->children[left];
+	if (node->children[left] != NULL)
+	{
+		node = node->children[left];
 
-        while (node->children[right] != NULL)
-            node = node->children[right];
-    }
-    else
-    {
-        for (;;)
+		while (node->children[right] != NULL)
+			node = node->children[right];
+	}
+	else
 	{
-            struct starpu_rbtree_node *parent;
-	    int index;
+		for (;;)
+		{
+			struct starpu_rbtree_node *parent;
+			int index;
 
-            parent = starpu_rbtree_parent(node);
+			parent = starpu_rbtree_parent(node);
 
-            if (parent == NULL)
-                return NULL;
+			if (parent == NULL)
+				return NULL;
 
-            index = starpu_rbtree_index(node, parent);
-            node = parent;
+			index = starpu_rbtree_index(node, parent);
+			node = parent;
 
-            if (index == right)
-                break;
-        }
-    }
+			if (index == right)
+				break;
+		}
+	}
 
-    return node;
+	return node;
 }
 
 /*
@@ -442,59 +442,59 @@ struct starpu_rbtree_node * starpu_rbtree_walk(struct starpu_rbtree_node *node,
  */
 static struct starpu_rbtree_node * starpu_rbtree_find_deepest(struct starpu_rbtree_node *node)
 {
-    struct starpu_rbtree_node *parent;
+	struct starpu_rbtree_node *parent;
 
-    assert(node != NULL);
+	assert(node != NULL);
 
-    for (;;)
-    {
-        parent = node;
-        node = node->children[STARPU_RBTREE_LEFT];
-
-        if (node == NULL)
+	for (;;)
 	{
-            node = parent->children[STARPU_RBTREE_RIGHT];
+		parent = node;
+		node = node->children[STARPU_RBTREE_LEFT];
+
+		if (node == NULL)
+		{
+		node = parent->children[STARPU_RBTREE_RIGHT];
 
-            if (node == NULL)
-                return parent;
-        }
-    }
+		if (node == NULL)
+		    return parent;
+		}
+	}
 }
 
 struct starpu_rbtree_node * starpu_rbtree_postwalk_deepest(const struct starpu_rbtree *tree)
 {
-    struct starpu_rbtree_node *node;
+	struct starpu_rbtree_node *node;
 
-    node = tree->root;
+	node = tree->root;
 
-    if (node == NULL)
-        return NULL;
+	if (node == NULL)
+		return NULL;
 
-    return starpu_rbtree_find_deepest(node);
+	return starpu_rbtree_find_deepest(node);
 }
 
 struct starpu_rbtree_node * starpu_rbtree_postwalk_unlink(struct starpu_rbtree_node *node)
 {
-    struct starpu_rbtree_node *parent;
-    int index;
+	struct starpu_rbtree_node *parent;
+	int index;
 
-    if (node == NULL)
-        return NULL;
+	if (node == NULL)
+		return NULL;
 
-    assert(node->children[STARPU_RBTREE_LEFT] == NULL);
-    assert(node->children[STARPU_RBTREE_RIGHT] == NULL);
+	assert(node->children[STARPU_RBTREE_LEFT] == NULL);
+	assert(node->children[STARPU_RBTREE_RIGHT] == NULL);
 
-    parent = starpu_rbtree_parent(node);
+	parent = starpu_rbtree_parent(node);
 
-    if (parent == NULL)
-        return NULL;
+	if (parent == NULL)
+		return NULL;
 
-    index = starpu_rbtree_index(node, parent);
-    parent->children[index] = NULL;
-    node = parent->children[STARPU_RBTREE_RIGHT];
+	index = starpu_rbtree_index(node, parent);
+	parent->children[index] = NULL;
+	node = parent->children[STARPU_RBTREE_RIGHT];
 
-    if (node == NULL)
-        return parent;
+	if (node == NULL)
+		return parent;
 
-    return starpu_rbtree_find_deepest(node);
+	return starpu_rbtree_find_deepest(node);
 }

+ 10 - 6
src/core/sched_ctx.h

@@ -216,19 +216,23 @@ int _starpu_get_index_in_ctx_of_workerid(unsigned sched_ctx, unsigned workerid);
 /** Get the mutex corresponding to the global workerid */
 starpu_pthread_mutex_t *_starpu_get_sched_mutex(struct _starpu_sched_ctx *sched_ctx, int worker);
 
-/** Get workers belonging to a certain context, it returns the number of workers
- take care: no mutex taken, the list of workers might not be updated */
+/** Get workers belonging to a certain context, it returns the number
+ * of workers take care: no mutex taken, the list of workers might not
+ * be updated
+ */
 int _starpu_get_workers_of_sched_ctx(unsigned sched_ctx_id, int *pus, enum starpu_worker_archtype arch);
 
-/** Let the worker know it does not belong to the context and that
-   it should stop poping from it */
+/** Let the worker know it does not belong to the context and that it
+ * should stop poping from it
+ */
 void _starpu_worker_gets_out_of_ctx(unsigned sched_ctx_id, struct _starpu_worker *worker);
 
 /** Check if the worker belongs to another sched_ctx */
 unsigned _starpu_worker_belongs_to_a_sched_ctx(int workerid, unsigned sched_ctx_id);
 
-/** indicates wheather this worker should go to sleep or not
-   (if it is the last one awake in a context he should better keep awake) */
+/** indicates wheather this worker should go to sleep or not (if it is
+ * the last one awake in a context he should better keep awake)
+ */
 unsigned _starpu_sched_ctx_last_worker_awake(struct _starpu_worker *worker);
 
 /** If starpu_sched_ctx_set_context() has been called, returns the context

+ 25 - 27
src/debug/traces/starpu_fxt.c

@@ -1897,8 +1897,8 @@ static void handle_end_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_opti
 	ongoing_computation[worker] = comp;
 
 	if (distrib_time)
-	     fprintf(distrib_time, "%s\t%s%d\t%ld\t%"PRIx32"\t%.9f\n", _starpu_last_codelet_symbol[worker],
-		     prefix, worker, (unsigned long) codelet_size, codelet_hash, codelet_length);
+		fprintf(distrib_time, "%s\t%s%d\t%ld\t%"PRIx32"\t%.9f\n", _starpu_last_codelet_symbol[worker],
+			prefix, worker, (unsigned long) codelet_size, codelet_hash, codelet_length);
 
 	if (options->dumped_codelets)
 	{
@@ -2547,9 +2547,9 @@ static void handle_job_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *opt
 		scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
 		poti_SetVariable(current_timestamp, container, "nready", (double)curq_size);
 
-               char paje_value[STARPU_POTI_STR_LEN];
-               snprintf(paje_value, sizeof(paje_value), "%u", task);
-               snprintf(container, sizeof(container), "%sp", options->file_prefix);
+		char paje_value[STARPU_POTI_STR_LEN];
+		snprintf(paje_value, sizeof(paje_value), "%u", task);
+		snprintf(container, sizeof(container), "%sp", options->file_prefix);
 		if (!options->no_events)
 			poti_NewEvent(get_event_time_stamp(ev, options), container, "pu", paje_value);
 #else
@@ -2820,7 +2820,7 @@ static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *op
 
 	char *prefix = options->file_prefix;
 	struct task_info *task = get_task(job_id, options->file_rank);
-        int worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
+	int worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
 
 	const char *color;
 	char buffer[32];
@@ -2902,9 +2902,7 @@ static void handle_tag_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *opt
 
 	unsigned long has_name = ev->param[2];
 	char *name = has_name?get_fxt_string(ev,3):"unknown";
-
-        int worker;
-        worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
+	int worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
 
 	const char *color;
 	char buffer[32];
@@ -3285,7 +3283,7 @@ void _starpu_fxt_process_bandwidth(struct starpu_fxt_options *options)
 		/* This communication is complete */
 		_starpu_communication_list_erase(&communication_list, itor);
 
-		current_bandwidth_out_per_node[itor->src_node] +=  itor->bandwidth;
+		current_bandwidth_out_per_node[itor->src_node] += itor->bandwidth;
 		if (out_paje_file)
 		{
 #ifdef STARPU_HAVE_POTI
@@ -3298,7 +3296,7 @@ void _starpu_fxt_process_bandwidth(struct starpu_fxt_options *options)
 #endif
 		}
 
-		current_bandwidth_in_per_node[itor->dst_node] +=  itor->bandwidth;
+		current_bandwidth_in_per_node[itor->dst_node] += itor->bandwidth;
 		if (out_paje_file)
 		{
 #ifdef STARPU_HAVE_POTI
@@ -3361,8 +3359,8 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 	fut = fxt_fdopen(fd_in);
 	if (!fut)
 	{
-	        perror("fxt_fdopen :");
-	        exit(-1);
+		perror("fxt_fdopen :");
+		exit(-1);
 	}
 
 	fxt_blockev_t block;
@@ -3676,12 +3674,12 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 					handle_data_request(&ev, options, "rc");
 				}
 				break;
-		  case _STARPU_FUT_PAPI_TASK_EVENT_VALUE:
+			case _STARPU_FUT_PAPI_TASK_EVENT_VALUE:
 				handle_papi_event(&ev, options);
 				break;
 			case _STARPU_FUT_DATA_COPY:
 				if (!options->no_bus)
-				     handle_data_copy();
+					handle_data_copy();
 				break;
 
 			case _STARPU_FUT_DATA_LOAD:
@@ -3740,14 +3738,14 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 				if (!options->no_bus)
 				{
 					handle_push_memnode_event(&ev, options, "A");
-                                       handle_memnode_event_start_4(&ev, options, "Al");
+					handle_memnode_event_start_4(&ev, options, "Al");
 				}
 				break;
 			case _STARPU_FUT_START_ALLOC_REUSE:
 				if (!options->no_bus)
 				{
 					handle_push_memnode_event(&ev, options, "Ar");
-                                       handle_memnode_event_start_4(&ev, options, "Alr");
+					handle_memnode_event_start_4(&ev, options, "Alr");
 				}
 				break;
 			case _STARPU_FUT_END_ALLOC:
@@ -4191,8 +4189,8 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 #else
 	if (close(fd_in))
 	{
-	        perror("close failed :");
-	        exit(-1);
+		perror("close failed :");
+		exit(-1);
 	}
 #endif
 }
@@ -4598,8 +4596,8 @@ uint64_t _starpu_fxt_find_start_time(char *filename_in)
 	fut = fxt_fdopen(fd_in);
 	if (!fut)
 	{
-	        perror("fxt_fdopen :");
-	        exit(-1);
+		perror("fxt_fdopen :");
+		exit(-1);
 	}
 
 	fxt_blockev_t block;
@@ -4620,8 +4618,8 @@ uint64_t _starpu_fxt_find_start_time(char *filename_in)
 #else
 	if (close(fd_in))
 	{
-	        perror("close failed :");
-	        exit(-1);
+		perror("close failed :");
+		exit(-1);
 	}
 #endif
 	return (ev.time);
@@ -4882,8 +4880,8 @@ void starpu_fxt_write_data_trace_in_dir(char *filename_in, char *dir)
 	fut = fxt_fdopen(fd_in);
 	if (!fut)
 	{
-	        perror("fxt_fdopen :");
-	        exit(-1);
+		perror("fxt_fdopen :");
+		exit(-1);
 	}
 
 	char filename_out[512];
@@ -4975,8 +4973,8 @@ void starpu_fxt_write_data_trace_in_dir(char *filename_in, char *dir)
 #else
 	if (close(fd_in))
 	{
-	        perror("close failed :");
-	        exit(-1);
+		perror("close failed :");
+		exit(-1);
 	}
 #endif
 

+ 6 - 6
src/debug/traces/starpu_fxt_mpi.c

@@ -51,16 +51,16 @@ int _starpu_fxt_mpi_find_sync_point(char *filename_in, uint64_t *offset, int *ke
 	fd_in = open(filename_in, O_RDONLY);
 	if (fd_in < 0)
 	{
-	        perror("open failed :");
-	        exit(-1);
+		perror("open failed :");
+		exit(-1);
 	}
 
 	static fxt_t fut;
 	fut = fxt_fdopen(fd_in);
 	if (!fut)
 	{
-	        perror("fxt_fdopen :");
-	        exit(-1);
+		perror("fxt_fdopen :");
+		exit(-1);
 	}
 
 	fxt_blockev_t block;
@@ -93,8 +93,8 @@ int _starpu_fxt_mpi_find_sync_point(char *filename_in, uint64_t *offset, int *ke
 	/* Close the trace file */
 	if (close(fd_in))
 	{
-	        perror("close failed :");
-	        exit(-1);
+		perror("close failed :");
+		exit(-1);
 	}
 
 	return func_ret;

+ 3 - 3
src/debug/traces/starpu_paje.c

@@ -258,8 +258,8 @@ void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED, struct st
 	poti_DefineContainerType("MPICt", "P", "MPI Communication Thread");
 	poti_DefineContainerType("Sc", "P", "Scheduler");
 	poti_DefineEventType("prog_event", "P", "program event type");
-       poti_DefineEventType("pu", "P", "task push");
-       poti_DefineEventType("po", "P", "task pop");
+	poti_DefineEventType("pu", "P", "task push");
+	poti_DefineEventType("po", "P", "task pop");
 	poti_DefineEventType("register", "P", "data registration");
 	poti_DefineEventType("unregister", "P", "data unregistration");
 
@@ -269,7 +269,7 @@ void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED, struct st
 	poti_DefineEventType("SO", "Mm", "data state owner");
 	poti_DefineEventType("WU", "Mm", "data wont use");
 	poti_DefineEventType("Al", "Mm", "Allocating Start");
-       poti_DefineEventType("rc", "Mm", "Request Created");
+	poti_DefineEventType("rc", "Mm", "Request Created");
 	poti_DefineEventType("AlE", "Mm", "Allocating End");
 	poti_DefineEventType("Alr", "Mm", "Allocating Async Start");
 	poti_DefineEventType("AlrE", "Mm", "Allocating Async End");

+ 6 - 7
src/worker_collection/worker_list.c

@@ -103,7 +103,7 @@ static unsigned _worker_belongs_to_ctx(struct starpu_worker_collection *workers,
 {
 	int *workerids = (int *)workers->workerids;
 	unsigned nworkers = workers->nworkers;
-	
+
 	unsigned i;
 	for(i = 0; i < nworkers; i++)
 	{
@@ -125,7 +125,7 @@ static int list_add(struct starpu_worker_collection *workers, int worker)
 		workerids[(*nworkers)++] = worker;
 		return worker;
 	}
-	else 
+	else
 		return -1;
 }
 
@@ -140,8 +140,8 @@ static int _get_first_free_worker(int *workerids, int nworkers)
 }
 
 /* rearange array of workerids in order not to have {-1, -1, 5, -1, 7}
-   and have instead {5, 7, -1, -1, -1} 
-   it is easier afterwards to iterate the array
+ * and have instead {5, 7, -1, -1, -1}
+ * it is easier afterwards to iterate the array
 */
 static void _rearange_workerids(int *workerids, int old_nworkers)
 {
@@ -171,7 +171,7 @@ static int list_remove(struct starpu_worker_collection *workers, int worker)
 
 	int *masters = (int *)workers->masters;
 	unsigned nmasters = workers->nmasters;
-	
+
 	unsigned i;
 	int found_worker = -1;
 	for(i = 0; i < nworkers; i++)
@@ -280,7 +280,7 @@ static void list_init_iterator_for_parallel_tasks(struct starpu_worker_collectio
 	unsigned nworkers = workers->nworkers;
 	unsigned i;
 	int nm = 0, nub = 0;
-	for(i = 0;  i < nworkers; i++)
+	for(i = 0; i < nworkers; i++)
 	{
 		if(!starpu_worker_is_blocked_in_parallel(workerids[i]))
 		{
@@ -307,4 +307,3 @@ struct starpu_worker_collection starpu_worker_list =
 	.init_iterator_for_parallel_tasks = list_init_iterator_for_parallel_tasks,
 	.type = STARPU_WORKER_LIST
 };
-

+ 6 - 6
src/worker_collection/worker_tree.c

@@ -171,9 +171,9 @@ static int tree_get_next_master(struct starpu_worker_collection *workers, struct
 static unsigned tree_has_next(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
 {
 	if(it->possibly_parallel == 1)
-                return tree_has_next_master(workers, it);
-        else if(it->possibly_parallel == 0)
-                return tree_has_next_unblocked_worker(workers, it);
+		return tree_has_next_master(workers, it);
+	else if(it->possibly_parallel == 0)
+		return tree_has_next_unblocked_worker(workers, it);
 
 	STARPU_ASSERT(it != NULL);
 	if(workers->nworkers == 0)
@@ -229,9 +229,9 @@ static unsigned tree_has_next(struct starpu_worker_collection *workers, struct s
 static int tree_get_next(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
 {
 	if(it->possibly_parallel == 1)
-                return tree_get_next_master(workers, it);
-        else if(it->possibly_parallel == 0)
-                return tree_get_next_unblocked_worker(workers, it);
+		return tree_get_next_master(workers, it);
+	else if(it->possibly_parallel == 0)
+		return tree_get_next_unblocked_worker(workers, it);
 
 	int ret = -1;