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

apxc: pydarshan code cleanup

parent b7e44e2d
......@@ -414,7 +414,7 @@
X(AR_RTR_PT_5_7_INQ_PRF_REQ_ROWBUS_STALL_CNT) \
X(AR_RTR_PT_5_7_INQ_PRF_RSP_ROWBUS_STALL_CNT) \
/* end of counters */\
X(APXC_NUM_INDICES)
Z(APXC_NUM_INDICES)
#define APXC_MEMORY_MODES \
X(MM_UNKNOWN) \
......@@ -422,7 +422,7 @@
X(MM_EQUAL) \
X(MM_SPLIT) \
X(MM_CACHE) \
X(MM_NUM_INDICES)
Z(MM_NUM_INDICES)
#define APXC_CLUSTER_MODES \
X(CM_UNKNOWN) \
......@@ -431,9 +431,10 @@
X(CM_HEMI) \
X(CM_SNC4) \
X(CM_SNC2) \
X(CM_NUM_INDICIES)
Z(CM_NUM_INDICIES)
#define X(a) a,
#define Z(a) a
/* integer counters for the "APXC" example module */
enum darshan_apxc_perf_indices
{
......@@ -449,6 +450,7 @@ enum apxc_cluster_modes
{
APXC_CLUSTER_MODES
};
#undef Z
#undef X
/* the darshan_apxc_router_record structure encompasses the data/counters
......
......@@ -4,7 +4,7 @@ import ctypes
import numpy as np
import darshan.backend.cffi_backend
# apxc structure defs
# APXC structure defs
structdefs = '''
struct darshan_apxc_perf_record
{
......@@ -36,27 +36,26 @@ def get_apxc_defs():
# load header record
def log_get_apxc_record(log, dtype='dict'):
from darshan.backend.cffi_backend import ffi, libdutil, log_get_modules, counter_names
def log_get_apxc_record(log, mod_name, structname, dtype='dict'):
from darshan.backend.cffi_backend import ffi, libdutil, log_get_modules, counter_names, _structdefs
mod_name = 'APXC'
modules = log_get_modules(log)
rec = {}
buf = ffi.new("void **")
r = libdutil.darshan_log_get_record(log['handle'], modules[mod_name]['idx'], buf)
mod_type = _structdefs[mod_name+"-"+structname]
if r < 1:
return None
hdr = ffi.cast('struct darshan_apxc_header_record **', buf)
prf = ffi.cast('struct darshan_apxc_perf_record **', buf)
memory_modes = ['unknown', 'flat', 'equal', 'split', 'cache']
cluster_modes = ['unknown', 'all2all', 'quad', 'hemi', 'snc4', 'snc2']
rec['id'] = hdr[0].base_rec.id
rec['rank'] = hdr[0].base_rec.rank
if hdr[0].magic == 4707761685111591494:
if mod_type == 'struct darshan_apxc_header_record **':
hdr = ffi.cast(mod_type, buf)
rec['id'] = hdr[0].base_rec.id
rec['rank'] = hdr[0].base_rec.rank
mm = hdr[0].memory_mode & ~(1 << 31)
cm = hdr[0].cluster_mode & ~(1 << 31)
rec['nblades'] = hdr[0].nblades
......@@ -66,20 +65,22 @@ def log_get_apxc_record(log, dtype='dict'):
rec['cluster_mode'] = cluster_modes[cm]
rec['appid'] = hdr[0].appid
else:
prf = ffi.cast(mod_type, buf)
rec['id'] = prf[0].base_rec.id
rec['rank'] = prf[0].base_rec.rank
rec['group'] = prf[0].group
rec['chassis'] = prf[0].chassis
rec['blade'] = prf[0].blade
rec['node'] = prf[0].node
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))
if dtype == 'numpy':
rec['counters'] = np_counters
else:
rec['counters'] = d_counters
rec['counters'] = {}
rec['counters'].update(d_counters)
return rec
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