Skip to content
Extraits de code Groupes Projets
Valider 3cc9dfa1 rédigé par Anzo's avatar Anzo
Parcourir les fichiers

fixed arcane dotfiles naming

parent 5aca88fc
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -18,7 +18,7 @@ DEBUG_TEST_FLAGS=-fdump-tree-all -fdump-tree-all-graph ...@@ -18,7 +18,7 @@ DEBUG_TEST_FLAGS=-fdump-tree-all -fdump-tree-all-graph
# Comment to disable debug # Comment to disable debug
FLAGS+=$(DEBUG_FLAGS) FLAGS+=$(DEBUG_FLAGS)
TEST_FLAGS+=$(DEBUG_TEST_FLAGS) #TEST_FLAGS+=$(DEBUG_TEST_FLAGS)
...@@ -29,12 +29,17 @@ LIBD=lib ...@@ -29,12 +29,17 @@ LIBD=lib
TARGETD=bin TARGETD=bin
TESTD=test TESTD=test
TESTSRCD=$(SRCD)/test TESTSRCD=$(SRCD)/test
DOTD=dot
# Files # Files
SRCS=$(notdir $(wildcard ($(SRCD)/*.cpp)) SRCS=$(notdir $(wildcard ($(SRCD)/*.cpp))
OBJS=$(addprefix $(OBJD)/, $(SRCS:cpp=o)) OBJS=$(addprefix $(OBJD)/, $(SRCS:cpp=o))
.PHONY: all
all:
$(MAKE) plugin
$(MAKE) test
.PHONY: plugin .PHONY: plugin
plugin: plugin:
...@@ -45,7 +50,9 @@ plugin: ...@@ -45,7 +50,9 @@ plugin:
.PHONY: test .PHONY: test
test: test:
mkdir -p $(TESTD) mkdir -p $(TESTD)
mkdir -p $(DOTD)
$(MAKE) $(TESTD)/test2 $(MAKE) $(TESTD)/test2
$(MAKE) $(TESTD)/test3
$(TESTD)/%: $(TESTSRCD)/%.c $(TESTD)/%: $(TESTSRCD)/%.c
$(CC) $(TEST_FLAGS) $(PLUGIN_FLAGS) $^ -o $@ $(CC) $(TEST_FLAGS) $(PLUGIN_FLAGS) $^ -o $@
...@@ -58,6 +65,8 @@ $(LIBD)/libplugin.so: $(OBJD)/plugin.o $(OBJD)/pass_mpi_collective.o ...@@ -58,6 +65,8 @@ $(LIBD)/libplugin.so: $(OBJD)/plugin.o $(OBJD)/pass_mpi_collective.o
# removing test scince plugin was rebuild # removing test scince plugin was rebuild
rm -rf $(TESTD) rm -rf $(TESTD)
%.png: %.dot
dot -Tpng $< -o $@
.PHONY: clean .PHONY: clean
clean: clean:
...@@ -65,6 +74,7 @@ clean: ...@@ -65,6 +74,7 @@ clean:
rm -rf $(TARGETD) rm -rf $(TARGETD)
rm -rf $(LIBD) rm -rf $(LIBD)
rm -rf $(TESTD) rm -rf $(TESTD)
rm -rf $(DOTD)
.PHONY: style .PHONY: style
style: style:
......
...@@ -37,6 +37,9 @@ public: ...@@ -37,6 +37,9 @@ public:
mpi_collective_code is_mpi_collec(gimple *stmt); mpi_collective_code is_mpi_collec(gimple *stmt);
void split_blocks(function *fun); void split_blocks(function *fun);
void label_bb(function *fun);
void clean_aux(function *fun);
private: private:
bool __is_mpi_func(gimple *stmt); bool __is_mpi_func(gimple *stmt);
mpi_collective_code __is_mpi_collec(gimple *stmt); mpi_collective_code __is_mpi_collec(gimple *stmt);
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <gimple.h> #include <gimple.h>
// gsi // gsi
#include <gimple-iterator.h> #include <gimple-iterator.h>
// basename
#include <filesystem>
// our pass // our pass
#include "pass_mpi_collective.hpp" #include "pass_mpi_collective.hpp"
...@@ -47,7 +49,11 @@ unsigned int pass_mpi_collective::execute(function *fun) ...@@ -47,7 +49,11 @@ unsigned int pass_mpi_collective::execute(function *fun)
print_tree(fun); print_tree(fun);
split_blocks(fun); split_blocks(fun);
printf("\t------------------------------[split]-------------------------------\n");
print_tree(fun); print_tree(fun);
label_bb(fun);
cfgviz_dump(fun, "_split");
clean_aux(fun);
return 0; return 0;
} }
...@@ -86,6 +92,8 @@ void pass_mpi_collective::print_tree(function *fun) ...@@ -86,6 +92,8 @@ void pass_mpi_collective::print_tree(function *fun)
} }
} }
bool pass_mpi_collective::is_func(gimple *stmt) bool pass_mpi_collective::is_func(gimple *stmt)
{return is_gimple_call(stmt);} {return is_gimple_call(stmt);}
...@@ -148,8 +156,9 @@ void pass_mpi_collective::split_blocks(function *fun) ...@@ -148,8 +156,9 @@ void pass_mpi_collective::split_blocks(function *fun)
prev_stmt = stmt; prev_stmt = stmt;
stmt = gsi_stmt(gsi); stmt = gsi_stmt(gsi);
if (is_mpi_collec(stmt) != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE) if (is_mpi_collec(stmt) != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE)
++nb_collective; { ++nb_collective; }
if (nb_collective >= 2){ if (nb_collective >= 2)
{
split_block(bb, prev_stmt); split_block(bb, prev_stmt);
split = true; split = true;
//The inner for doesn't stop naturally, whereas the FOR_EACH_BB_FN //The inner for doesn't stop naturally, whereas the FOR_EACH_BB_FN
...@@ -166,16 +175,52 @@ char *pass_mpi_collective::cfgviz_generate_filename(function *fun, ...@@ -166,16 +175,52 @@ char *pass_mpi_collective::cfgviz_generate_filename(function *fun,
char *target_filename; char *target_filename;
target_filename = (char *)xmalloc(1024 * sizeof(char)); target_filename = (char *)xmalloc(1024 * sizeof(char));
int line = LOCATION_LINE(fun->function_start_locus);
snprintf(target_filename, 1024, "%s_%s_%d_%s.dot", const char * mfilename =
current_function_name(), std::filesystem::path(LOCATION_FILE(fun->function_start_locus))
LOCATION_FILE(fun->function_start_locus), .filename().c_str();
LOCATION_LINE(fun->function_start_locus),
snprintf(target_filename, 1024, "%s%s_%s_%d_%s.dot",
"dot/",
mfilename,
function_name(fun),
line,
suffix); suffix);
return target_filename; return target_filename;
} }
void pass_mpi_collective::label_bb(function *fun)
{
basic_block bb;
gimple_stmt_iterator gsi;
gimple *stmt;
//size_t line;
FOR_EACH_BB_FN(bb, fun)
{
printf("\tBasic block: %d\n", bb->index);
for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi))
{
stmt = gsi_stmt(gsi);
int mpi_code = is_mpi_collec(stmt);
if (mpi_code != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE)
{bb->aux = (void *) (new int(mpi_code));}
}
}
}
void pass_mpi_collective::clean_aux(function *fun)
{
basic_block bb;
FOR_ALL_BB_FN(bb, fun)
{
if (bb->aux != NULL)
{delete (int *) bb->aux; bb->aux = NULL;}
}
}
//============================ GRAPHVIZ =====================================
/* Dump the graphviz representation of function 'fun' in file 'out' */ /* Dump the graphviz representation of function 'fun' in file 'out' */
void pass_mpi_collective::cfgviz_internal_dump( void pass_mpi_collective::cfgviz_internal_dump(
function *fun, FILE *out) function *fun, FILE *out)
...@@ -232,3 +277,4 @@ void pass_mpi_collective::cfgviz_dump(function *fun, ...@@ -232,3 +277,4 @@ void pass_mpi_collective::cfgviz_dump(function *fun,
fclose(out); fclose(out);
free(target_filename); free(target_filename);
} }
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main(int argc, char * argv[])
{
MPI_Init(&argc, &argv);
int i;
int a = 2;
int b = 3;
int c=0;
for(i=0; i<10; i++)
{
MPI_Barrier(MPI_COMM_WORLD);
if(c<10)
{
printf("je suis dans le if (c=%d)\n", c);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if(c <5)
{
a = a*a +1;
}
else
{
c = c*3;
if(c <20)
{
return c;
}
}
}
else
{
printf("je suis dans le else (c=%d)\n", c);
MPI_Barrier(MPI_COMM_WORLD);
return 1;
}
c+= (a+b);
printf("fin du for\n");
}
printf("c=%d\n", c);
MPI_Finalize();
return 1;
}
Digraph G{
0 [label="BB 0 " shape=ellipse]
0 -> 2 [color=red label=""]
2 [label="BB 2 MPI_Init" shape=ellipse]
2 -> 4 [color=red label=""]
3 [label="BB 3 " shape=ellipse]
3 -> 4 [color=red label=""]
4 [label="BB 4 " shape=ellipse]
4 -> 3 [color=red label="true"]
4 -> 5 [color=red label="false"]
5 [label="BB 5 MPI_Finalize" shape=ellipse]
5 -> 6 [color=red label=""]
6 [label="BB 6 " shape=ellipse]
6 -> 1 [color=red label=""]
1 [label="BB 1 " shape=ellipse]
}
Digraph G{
0 [label="BB 0 " shape=ellipse]
0 -> 2 [color=red label=""]
2 [label="BB 2 MPI_Init" shape=ellipse]
2 -> 10 [color=red label=""]
3 [label="BB 3 MPI_Barrier" shape=ellipse]
3 -> 4 [color=red label="true"]
3 -> 8 [color=red label="false"]
4 [label="BB 4 MPI_Barrier" shape=ellipse]
4 -> 13 [color=red label=""]
13 [label="BB 13 MPI_Barrier" shape=ellipse]
13 -> 5 [color=red label="true"]
13 -> 6 [color=red label="false"]
5 [label="BB 5 " shape=ellipse]
5 -> 9 [color=red label=""]
6 [label="BB 6 " shape=ellipse]
6 -> 7 [color=red label="true"]
6 -> 9 [color=red label="false"]
7 [label="BB 7 " shape=ellipse]
7 -> 12 [color=red label=""]
8 [label="BB 8 MPI_Barrier" shape=ellipse]
8 -> 12 [color=red label=""]
9 [label="BB 9 " shape=ellipse]
9 -> 10 [color=red label=""]
10 [label="BB 10 " shape=ellipse]
10 -> 3 [color=red label="true"]
10 -> 11 [color=red label="false"]
11 [label="BB 11 MPI_Finalize" shape=ellipse]
11 -> 12 [color=red label=""]
12 [label="BB 12 " shape=ellipse]
12 -> 1 [color=red label=""]
1 [label="BB 1 " shape=ellipse]
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter