from gg.ast import * from gg.lib.graph import Graph from gg.lib.wl import Worklist from gg.ast.params import GraphParam import cgen G = Graph("graph") WL = Worklist() ast = Module([ CBlock([cgen.Include("kernels/reduce.cuh", system=False)], parse=False), CBlock([cgen.Include("gen_cuda.cuh", system=False)], parse=False), Kernel("InitializeGraph", [ G.param(), ('unsigned int', '__begin'), ('unsigned int', '__end'), ('uint32_t *', 'p_comp_current'), ('uint32_t *', 'p_comp_old') ], [ ForAll("src", G.nodes("__begin", "__end"), [ CDecl([("bool", "pop", " = src < __end")]), If("pop", [ CBlock(["p_comp_current[src] = graph.node_data[src]"]), CBlock(["p_comp_old[src] = graph.node_data[src]"]), ]), ]), ]), Kernel("FirstItr_ConnectedComp", [ G.param(), ('unsigned int', '__begin'), ('unsigned int', '__end'), ('uint32_t *', 'p_comp_current'), ('uint32_t *', 'p_comp_old'), ('DynamicBitset&', 'bitset_comp_current') ], [ ForAll("src", G.nodes("__begin", "__end"), [ CDecl([("bool", "pop", " = src < __end")]), If("pop", [ CBlock(["p_comp_old[src] = p_comp_current[src]"]),
G = Graph("graph") EL = Worklist() # EdgeList ast = Module([ CBlock(["typedef int edge_data_type", "typedef int node_data_type"]), Kernel( "ebgc_init", [ G.param(), ("int *", "edge_src"), ("int *", "VForbidden"), ("int *", "CS"), ("int *", "TVForbidden") ], [ ForAll( "node", G.nodes(), [ CBlock([ "graph.node_data[node] = 0", # 0 represents not colored "VForbidden[node] = 0", "TVForbidden[node] = 0", "CS[node] = 0" ]), CDecl(('bool', 'pop', '')), CBlock(["pop = node < graph.nnodes"], parse=False), ClosureHint( ForAll("edge", G.edges("node"), [ CBlock([("edge_src[edge] = node")]), If("node < graph.getAbsDestination(edge)", [ EL.push("edge"), ])