Commit a2d5883d authored by Sudheer Chunduri's avatar Sudheer Chunduri
Browse files

APMPI python script updates

parent c5384dbe
......@@ -34,6 +34,82 @@ def get_apmpi_defs():
return structdefs
# load header record
def log_get_apmpi_record(log, mod_type, dtype='dict'):
from darshan.backend.cffi_backend import ffi, libdutil, log_get_modules, counter_names
mod_name = 'APMPI'
modules = log_get_modules(log)
rec = {}
buf = ffi.new("void **")
r = libdutil.darshan_log_get_record(log['handle'], modules[mod_name]['idx'], buf)
if r < 1:
return None
if mod_type == 'struct darshan_apmpi_header_record **':
hdr = ffi.cast(mod_type, buf)
rec['id'] = hdr[0].base_rec.id
rec['rank'] = hdr[0].base_rec.rank
rec['magic'] = hdr[0].magic
rec['variance_total_mpitime'] = hdr[0].apmpi_f_variance_total_mpitime
rec['variance_total_mpisynctime'] = hdr[0].apmpi_f_variance_total_mpisynctime
else:
prf = ffi.cast(mod_type, buf)
rec['id'] = prf[0].base_rec.id
rec['rank'] = prf[0].base_rec.rank
rec['node_name'] = ffi.string(prf[0].node_name).decode("utf-8")
lst = []
for i in range(0, len(prf[0].counters)):
lst.append(prf[0].counters[i])
np_counters = np.array(lst, dtype=np.uint64)
d_counters = dict(zip(counter_names(mod_name), np_counters))
lst = []
for i in range(0, len(prf[0].fcounters)):
lst.append(prf[0].fcounters[i])
np_fcounters = np.array(lst, dtype=np.float64)
d_fcounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpiop_totaltime_'), np_fcounters))
lst = []
for i in range(0, len(prf[0].fsynccounters)):
lst.append(prf[0].fsynccounters[i])
np_fsynccounters = np.array(lst, dtype=np.float64)
d_fsynccounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpiop_synctime_'), np_fsynccounters))
lst = []
for i in range(0, len(prf[0].fglobalcounters)):
lst.append(prf[0].fglobalcounters[i])
np_fglobalcounters = np.array(lst, dtype=np.float64)
d_fglobalcounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpi_global_'), np_fglobalcounters))
rec['all_counters'] = {}
rec['all_counters'].update(d_counters)
rec['all_counters'].update(d_fcounters)
rec['all_counters'].update(d_fsynccounters)
rec['all_counters'].update(d_fglobalcounters)
return rec
'''
if dtype == 'numpy':
rec['counters'] = np_counters
rec['fcounters'] = np_fcounters
rec['fsynccounters'] = np_fsynccounters
rec['fglobalcounters'] = np_fglobalcounters
else:
rec['counters'] = d_counters
rec['fcounters'] = d_fcounters
rec['fsynccounters'] = d_fsynccounters
rec['fglobalcounters'] = d_fglobalcounters
'''
'''
# load header record
def log_get_apmpi_record(log, dtype='dict'):
from darshan.backend.cffi_backend import ffi, libdutil, log_get_modules, counter_names
......@@ -49,7 +125,6 @@ def log_get_apmpi_record(log, dtype='dict'):
return None
hdr = ffi.cast('struct darshan_apmpi_header_record **', buf)
prf = ffi.cast('struct darshan_apmpi_perf_record **', buf)
rec['id'] = hdr[0].base_rec.id
rec['rank'] = hdr[0].base_rec.rank
......@@ -59,31 +134,32 @@ def log_get_apmpi_record(log, dtype='dict'):
rec['variance_total_mpitime'] = hdr[0].apmpi_f_variance_total_mpitime
rec['variance_total_mpisynctime'] = hdr[0].apmpi_f_variance_total_mpisynctime
else:
prf = ffi.cast('struct darshan_apmpi_perf_record **', buf)
rec['node_name'] = ffi.string(prf[0].node_name).decode("utf-8")
lst = []
for i in range(0, len(prf[0].counters)):
lst.append(prf[0].counters[i])
np_counters = np.array(lst, dtype=np.uint64)
d_counters = dict(zip(counter_names(mod_name), np_counters))
np_counters = np.array(lst, dtype=np.uint64)
d_counters = dict(zip(counter_names(mod_name), np_counters))
lst = []
for i in range(0, len(prf[0].fcounters)):
lst.append(prf[0].fcounters[i])
np_fcounters = np.array(lst, dtype=np.float64)
d_fcounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpiop_totaltime_'), np_fcounters))
np_fcounters = np.array(lst, dtype=np.float64)
d_fcounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpiop_totaltime_'), np_fcounters))
lst = []
for i in range(0, len(prf[0].fsynccounters)):
lst.append(prf[0].fsynccounters[i])
np_fsynccounters = np.array(lst, dtype=np.float64)
d_fsynccounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpiop_synctime_'), np_fsynccounters))
np_fsynccounters = np.array(lst, dtype=np.float64)
d_fsynccounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpiop_synctime_'), np_fsynccounters))
lst = []
for i in range(0, len(prf[0].fglobalcounters)):
lst.append(prf[0].fglobalcounters[i])
np_fglobalcounters = np.array(lst, dtype=np.float64)
d_fglobalcounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpi_global_'), np_fglobalcounters))
np_fglobalcounters = np.array(lst, dtype=np.float64)
d_fglobalcounters = dict(zip(counter_names(mod_name, fcnts=True, special='mpi_global_'), np_fglobalcounters))
if dtype == 'numpy':
rec['counters'] = np_counters
......@@ -98,3 +174,4 @@ def log_get_apmpi_record(log, dtype='dict'):
return rec
'''
......@@ -74,8 +74,8 @@ def log_get_apxc_record(log, dtype='dict'):
lst = []
for i in range(0, len(prf[0].counters)):
lst.append(prf[0].counters[i])
np_counters = np.array(lst, dtype=np.uint64)
d_counters = dict(zip(counter_names(mod_name), np_counters))
np_counters = np.array(lst, dtype=np.uint64)
d_counters = dict(zip(counter_names(mod_name), np_counters))
if dtype == 'numpy':
rec['counters'] = np_counters
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment