Skip to content

Commit

Permalink
Merge pull request #68 from ashwinktpu/WorkingBranch
Browse files Browse the repository at this point in the history
Working branch
  • Loading branch information
ashwinktpu authored May 18, 2024
2 parents f451531 + 1047521 commit 17fb75d
Show file tree
Hide file tree
Showing 637 changed files with 1,751,412 additions and 1,119 deletions.
28 changes: 25 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
lex.yy.c
src/parser/y.tab.h
.vscode/launch.json
src/parser/Makefile
src/Makefile
src/parser/y.tab.c
.vscode/
src/finalcode
src/finalcode.exe
src/bin/*.o
*.out
src/bin/
.history/
.history/*
../.history/*
StarPlat
StarPlat.exe
debug.txt
dump
*.pdf
To_be_done.txt
.github/
dump/
*.starplat
runtests.sh
cudadump/
testcases/testAMD/*
graphcode/generated_hip/*cc
graphcode/generated_hip/*h
.idea/
*.o
48 changes: 0 additions & 48 deletions .vscode/launch.json

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

27 changes: 27 additions & 0 deletions Py-Starplat/PageRank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def Compute_PR(g, beta, delta, maxIter):

num_nodes = g.num_nodes()
g.attachNodeProperty(pageRank=1/num_nodes, pageRank_nxt=0)
iterCount = 0

condition = True
while condition:
for v in g.nodes():
sum = 0.0

for nbr in g.nodes_to(v):
sum += g.pageRank[nbr] / g.count_outNbrs(nbr)

val = (1-delta)/num_nodes + delta*sum

if g.pageRank[v] >= 0:
diff += g.pageRank[v] - val
else:
diff += val - g.pageRank[v]

g.pageRank_nxt[v] = val

g.pageRank = g.pageRank_nxt.copy()
iterCount +=1

condition = (diff > beta) and (iterCount < maxIter)
42 changes: 42 additions & 0 deletions Py-Starplat/SSSP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from math import inf
from constructs import FixedPointUntil, FixedPoint

def Compute_SSSP(g, src_node):
g.attachNodeProperty(distance=inf, modified=False, modified_next=False)
g.modified[src_node] = True
g.distance[src_node] = 0

# finished = False

def condition():
finished = True
for v in g.modified.values():
finished = finished and (not v)

return finished

with FixedPointUntil(condition) as loop:

def block():

for v in filter(lambda node: g.modified[node] == True, g.nodes()):

# Changed loop to accessing via nodes
for nbr in g.getOutNeighbors(v):

e = g.get_edge(v, nbr)

new_distance = g.distance[v] + e.weight
if new_distance < g.distance[nbr]:

g.distance[nbr] = new_distance
g.modified_next[nbr] = True

# Making a deep copy
g.modified = g.modified_next.copy()

g.attachNodeProperty(modified_next=False)

loop.run(block)

return g.distance
10 changes: 10 additions & 0 deletions Py-Starplat/TriangleCounting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def Compute_TC(g):
triangle_count = 0

for v in g.nodes():
for u in list(filter(lambda u: u<v, g.neighbors(v))):
for w in list(filter(lambda w: w>v, g.neighbors(v))):
if g.is_an_edge(u,w):
triangle_count += 1

return triangle_count
20 changes: 20 additions & 0 deletions Py-Starplat/constructs/FixedPoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class FixedPoint:
def isFinished(self):
finished = True
for v in self.g.modified.values():
finished = finished and (not v)

return finished

def __init__(self, body, g, finished):
self.finished = finished
self.g = g
self.body = body

# Define the globals and locals dictionaries for the exec call
exec_globals = {'g': g}
exec_locals = {}

while not self.finished:
exec(self.body, exec_globals, exec_locals)
self.finished = self.isFinished()
13 changes: 13 additions & 0 deletions Py-Starplat/constructs/FixedPointUntil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class FixedPointUntil:
def __init__(self, condition):
self.condition = condition

def __enter__(self):
return self

def __exit__(self, exc_type, exc_value, traceback):
pass

def run(self, block):
while not self.condition():
block()
Empty file.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions Py-Starplat/get_ast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ast

class FunctionNamePrinter(ast.NodeVisitor):
def visit_FunctionDef(self, node):
print(f"Function name: {node.name}")
self.generic_visit(node)



class SSSPTransformer(ast.NodeTransformer):
def visit_
pass


with open("SSSP.py") as file:
tree = ast.parse(file.read())

print(ast.dump(tree, indent=2))
visitor = FunctionNamePrinter()
visitor.visit(tree)
Empty file added Py-Starplat/graphs/__init__.py
Empty file.
Binary file not shown.
Binary file added Py-Starplat/graphs/__pycache__/edge.cpython-310.pyc
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions Py-Starplat/graphs/edge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Edge:
def __init__(self):
self.src = None
self.dest = None
self.weight = None
self.id = None
self.dir = None


def __repr__(self):
return '<src: {}, dest: {}, weight: {}>'.format(self.src, self.dest, self.weight)

Loading

0 comments on commit 17fb75d

Please sign in to comment.