Example #1
0
File: ebgc.py Project: rohit-mp/pgc
# -*- mode: python -*-

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")
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"
                    ]),
Example #2
0
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]"]),
Example #3
0
File: ipgc.py Project: rohit-mp/pgc
# -*- mode: python -*-

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(["typedef int edge_data_type", "typedef int node_data_type"]),
    Kernel("ipgc_init", [G.param(), ("int *", "max_degree")], [
        ForAll("node", G.nodes(), [
            CBlock([
                "graph.node_data[node] = 0",
                "atomicMax(max_degree, graph.getOutDegree(node))"
            ]),
            WL.push("node")
        ])
    ]),  #initializing all nodes to color 0        
    Kernel(
        "assignColors",
        [G.param(), ("bool *", "forbidden"), ("int *", "max_degree")],
        [
            ForAll(
                "wlnode",
                WL.items(),
                [