hlsfactory.flow_harp

Module Contents

Classes

Functions

create_pseudo_node_block

add_to_graph

copy_files

copy the generated files to the project directory

read_json_graph

reads a graph in json format as a netwrokx graph

llvm_to_nx

reads a LLVM IR and converts it to a netwrokx graph

make_json_readable

gets a json file and beautifies it to make it readable

extract_function_names

extract the names of the function in c code along with their line number

get_tc_for_loop

get trip count of the for loop

get_icmp

gets an llvm file and returns the icmp instructions of each for loop

get_pragmas_loops

gets a c kernel and returns the pragmas of each for loop

create_pragma_nodes

creates nodes for each pragma to be added to the graph

prune_redundant_nodes

process_graph

adjusts the node/edge attributes, removes redundant nodes,

and writes the final graph to be used by GNN-DSE

args:

name: kernel name dest: where to store the graph

graph_generator

runs ProGraML [ICML’21] to generate the graph, adds the pragma nodes,

processes the final graph to be accepted by GNN-DSE

args:

name: kernel name path: path to parent directory of the kernel file benchmark: [machsuite|poly] None: simple program

get_for_blocks_info

augment_graph_hierarchy

add_auxiliary_nodes

remove_extra_header

write_csv_file

run_graph_gen

Data

API

hlsfactory.flow_harp.PRAGMA_POSITION = None
hlsfactory.flow_harp.BENCHMARK = 'machsuite'
hlsfactory.flow_harp.type_graph = 'harp'
hlsfactory.flow_harp.processed_gexf_folder = 'join(...)'
hlsfactory.flow_harp.auxiliary_node_gexf_folder = 'join(...)'
hlsfactory.flow_harp.MACHSUITE_KERNEL = ['aes', 'gemm-blocked', 'gemm-ncubed', 'spmv-crs', 'spmv-ellpack', 'stencil_stencil2d', 'nw', 'md', ...
hlsfactory.flow_harp.poly_KERNEL = ['2mm', '3mm', 'adi', 'atax', 'bicg', 'bicg-large', 'covariance', 'doitgen', 'doitgen-red', 'fdtd-2d...
hlsfactory.flow_harp.ALL_KERNEL = None
class hlsfactory.flow_harp.Node(block, function, text, type_n, features=None)

Initialization

get_attr(after_process=True)
args:
after_processTrue if nodes are added to existing GNN-DSE graphs

False for initial graph generation in GNN-DSE

class hlsfactory.flow_harp.Edge(src, dst, flow, position)

Initialization

get_attr()
hlsfactory.flow_harp.create_pseudo_node_block(block, function)
hlsfactory.flow_harp.add_to_graph(g_nx, nodes, edges)
hlsfactory.flow_harp.copy_files(name, src, dest)

copy the generated files to the project directory

args:

name: the kernel name src: the path to the files dest: where you want to copy the files

hlsfactory.flow_harp.read_json_graph(name, readable=True)

reads a graph in json format as a netwrokx graph

args:

name: name of the json file/ kernel’s name reaable: whether to store a readable format of the json file

returns:

g_nx: graph in networkx format

hlsfactory.flow_harp.llvm_to_nx(name)

reads a LLVM IR and converts it to a netwrokx graph

args:

name: name of the LLVM file/ kernel’s name

returns:

g_nx: graph in networkx format

hlsfactory.flow_harp.make_json_readable(name, js_graph)

gets a json file and beautifies it to make it readable

args:

name: kernel name js_graph: the graph in networkx format read from the json file

writes:

a readable json file with name {name}_pretty.json

hlsfactory.flow_harp.extract_function_names(c_code)

extract the names of the function in c code along with their line number

args:

c_code: the c_code read with code.read()

return:

a list of tuples of (function name, line number)

hlsfactory.flow_harp.get_tc_for_loop(for_loop_text)

get trip count of the for loop

hlsfactory.flow_harp.get_icmp(path, name, log=False)

gets an llvm file and returns the icmp instructions of each for loop

args:

path: parent directory of the llvm file name: kernel name

returns:
a dictionary corresponding to the icmp instructions:

{for loop id: [icmp instruction, for.cond line number, icmp line number]}

number of for loops

hlsfactory.flow_harp.get_pragmas_loops(path, name, EXT='c', log=False)

gets a c kernel and returns the pragmas of each for loop

args:

path: parent directory of the kernel file name: kernel name

returns:
a dictionary with each entry showing the for loop and its pragmas

{for loop id: [for loop source code, [list of pragmas]]}

number of for loops

hlsfactory.flow_harp.create_pragma_nodes(g_nx, g_nx_nodes, for_dict_source, for_dict_llvm, log=True)

creates nodes for each pragma to be added to the graph

args:

g_nx: the graph object g_nx_nodes: number of nodes of the graph object for_dict_source: the for loops along with their pragmas for_dict_llvm: the for loops along with their icmp instruction in llvm

returns:

a list of nodes and a list of edges to be added to the graph

hlsfactory.flow_harp.prune_redundant_nodes(g_new)
hlsfactory.flow_harp.process_graph(name, g, csv_dict=None)
adjusts the node/edge attributes, removes redundant nodes,

and writes the final graph to be used by GNN-DSE

args:

name: kernel name dest: where to store the graph

hlsfactory.flow_harp.graph_generator(name, path, benchmark, generate_programl=False, csv_dict=None)
runs ProGraML [ICML’21] to generate the graph, adds the pragma nodes,

processes the final graph to be accepted by GNN-DSE

args:

name: kernel name path: path to parent directory of the kernel file benchmark: [machsuite|poly] None: simple program

hlsfactory.flow_harp.get_for_blocks_info(name, path)
hlsfactory.flow_harp.augment_graph_hierarchy(name, for_blocks_info, src_path, dst_path, csv_dict=None, node_type='block')
hlsfactory.flow_harp.add_auxiliary_nodes(name, path, processed_path, csv_dict, node_type='block', connected=False)
hlsfactory.flow_harp.remove_extra_header(src_dir, kernel_name)
hlsfactory.flow_harp.write_csv_file(csv_dict, csv_header, file_path)
hlsfactory.flow_harp.run_graph_gen(mode='initial', connected=True, target=['machsuite', 'poly'], ALL_KERNEL=ALL_KERNEL)