Skip to content

Commit

Permalink
add AE review perflowgraph validation
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyangJin committed Nov 22, 2021
1 parent afb2084 commit d09d9b8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion example/AE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(pag_validation)
add_subdirectory(pass_validation)
add_subdirectory(pass_validation)
add_subdirectory(perflowgraph_validation)
2 changes: 2 additions & 0 deletions example/AE/perflowgraph_validation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mpi_profiler.py ${CMAKE_CURRENT_BINARY_DIR}/mpi_profiler.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cg.B.8 ${CMAKE_CURRENT_BINARY_DIR}/cg.B.8 COPYONLY)
Binary file added example/AE/perflowgraph_validation/cg.B.8
Binary file not shown.
21 changes: 21 additions & 0 deletions example/AE/perflowgraph_validation/mpi_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
import os
proj_dir = os.environ['BAGUA_DIR']
sys.path.append(proj_dir + r"/python")
import json
import perflow as pf
from pag import *

pflow = pf.PerFlow()

# Run the binary and return a program abstraction graph
tdpag, ppag = pflow.run(binary = "./cg.B.8", cmd = "srun -n 8 -p V132 ./cg.B.8", nprocs = 8)

# Build a PerFlowGraph
## a filter pass
V_comm = pflow.filter(tdpag.vs, name = "mpi_")
## a hotspot detection pass
V_hot = pflow.hotspot_detection(V_comm)
## a report pass
attrs_list = ["name", "CYCAVGPERCENT", "saddr"]
pflow.report(V = V_hot, attrs = attrs_list)
12 changes: 8 additions & 4 deletions python/perflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def run(self, binary = '', cmd = '', mode = '', nprocs = 0, sampling_count = 0):

def filter(self, V, name = '', type = ''):
if name != '':
return V.select(name_attr = name)
#print(name)
return V.select(lambda v: (v["name"].find(name) != -1) )
if type != '':
return V.select(type_eq = type)

Expand All @@ -115,15 +116,18 @@ def hotspot_detection(self, V, metric = '', n = 0):
metric = 'time'
if n == 0:
n = 10
return V.select(lambda v: float(v['CYCAVGPERCENT']) >= 0.001)
return V.select(lambda v: float(v['CYCAVGPERCENT']) > 0.0001)
#return V.sort_by(metric).top(n)

def report(self, V, E, attrs=[]):
def report(self, V, attrs=[]):
if len(attrs) == 0:
attrs = ['name', 'type', 'time', 'debug']
for attr in attrs:
print(attr, end='\t')
print()
for v in V:
for attr in attrs:
print(v[attr], end=' ')
print(v[attr], end='\t')
print()

def draw(self, g, save_pdf = '', mark_edges = []):
Expand Down
1 change: 1 addition & 0 deletions src/core/perf_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void PerfData::Read(const char* infile_name) {
if (cnt == 4 && procs_id >= 0) {
unsigned long int x = __sync_fetch_and_add(&this->vertex_perf_data_count, 1);

//std::cout << count << " " << line_vec[1].c_str() <<std::endl;
this->vertex_perf_data[x].value = atof(line_vec[1].c_str());
this->vertex_perf_data[x].procs_id = atoi(line_vec[2].c_str());
this->vertex_perf_data[x].thread_id = atoi(line_vec[3].c_str());
Expand Down

0 comments on commit d09d9b8

Please sign in to comment.