Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 39519d8981266d65f5291b28900156d1e9c2f13d
  • master par défaut protégée
2 résultats

pass_mpi_collective.hpp

Blame
  • pass_mpi_collective.hpp 2,32 Kio
    // dependance de tree-pass.H
    #include <gcc-plugin.h>
    // declare opt_pass
    #include <tree-pass.h>
    // set
    #include <set>
    
    /* Enum to represent the collective operations */
    #define DEFMPICOLLECTIVES(CODE, NAME) CODE,
    enum mpi_collective_code
    {
    #include "mpi_collectives.def"
    	LAST_AND_UNUSED_MPI_COLLECTIVE_CODE
    };
    #undef DEFMPICOLLECTIVES
    
    /* Name of each MPI collective operations */
    #define DEFMPICOLLECTIVES(CODE, NAME) NAME,
    const char *const mpi_collective_name[] =
    {
    #include "mpi_collectives.def"
    };
    #undef DEFMPICOLLECTIVES
    
    struct bb_data
    {
    	mpi_collective_code mpi_code;
    	std::set<basic_block> dom;
    	std::set<basic_block> post_dom;
    	std::set<basic_block> dom_front;
    	std::set<basic_block> post_dom_front;
    	int mark; // for graph parkour
    	int collective_rank;
    };
    
    struct edge_data
    {
    	// exclude adge that make loop
    	// excluding edge tag with loop remove all loop from the graph
    	// used to calculate collectives ranks
    	bool loop;
    };
    
    class pass_mpi_collective : public opt_pass
    {
    
    public:
    
    	pass_mpi_collective(gcc::context *ctxt);
    	pass_mpi_collective *clone();
    
    	bool gate(function *fun);
    	unsigned int execute(function *fun);
    
    	void print_tree(function *fun);
    
    	// MPI function / collectives detections
    	bool is_func(gimple *stmt);
    	bool is_mpi_func(gimple *stmt);
    	mpi_collective_code is_mpi_collec(gimple *stmt);
    
    	// split blocks according to mpi collectives
    	void split_blocks(function *fun);
    
    	// gestions des aux
    	void alloc_bb_aux(function *fun);
    	void label_collec(function *fun);
    	void free_bb_aux(function *fun);
    
    	// calculate dominances
    	void label_dom(function *fun);
    	void label_dom_front(function *fun);
    	void free_dom_data();
    
    	// parkour de graph
    	void reset_bb_mark(function *fun);
    	void alloc_edge_aux(function *fun);
    	void free_edge_aux(function *fun);
    	void mark_edge(function *fun);
    	void mark_edge(basic_block bb, int mark);
    
    	// rank definition
    	void rank_collective(function *fun);
    	int rank_collective(basic_block bb,
    	                    mpi_collective_code mpi_code, int rank);
    
    private:
    	// MPI function / collectives detections
    	bool __is_mpi_func(gimple *stmt);
    	mpi_collective_code __is_mpi_collec(gimple *stmt);
    
    	// GRAPHVIZ
    	char *cfgviz_generate_filename(function *fun,
    	                               const char *suffix);
    	void cfgviz_internal_dump(function *fun, FILE *out);
    	void cfgviz_dump(function *fun, const char *suffix);
    };