Skip to content

Commit

Permalink
Created package directory for veosinfo. Added pure python
Browse files Browse the repository at this point in the history
calc_metrics() function.
  • Loading branch information
efocht committed Dec 19, 2018
1 parent 4c1ce58 commit ba6f88d
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 66 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*~
*.o
*.so
_veosinfo.c
*.pyc
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
# ...
#

veosinfo.so: veosinfo.pyx
veosinfo/_veosinfo.so: veosinfo/_veosinfo.pyx
python setup.py build_ext -i --use-cython

test:
PATHONPATH=. python test_cython.py

clean:
rm -f *.so veosinfo.c
rm -f veosinfo/*.so veosinfo/_veosinfo.c veosinfo/*.pyc

install: veosinfo.so
install: veosinfo/_veosinfo.so
python setup.py install

sdist:
python setup.py sdist --use-cython

rpm: veosinfo.so
rpm: veosinfo/_veosinfo.so
python setup.py bdist_rpm

srpm: veosinfo.so
srpm: veosinfo/_veosinfo.so
python setup.py bdist_rpm --source-only

.PHONY: test clean install sdist rpm
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
ext = ".pyx"

_ext_mods=[
Extension("veosinfo",
sources=["veosinfo" + ext],
Extension("veosinfo._veosinfo",
sources=["veosinfo/_veosinfo" + ext],
libraries=["veosinfo"], # Unix-like specific
library_dirs=["/opt/nec/ve/veos/lib64"],
include_dirs=["/opt/nec/ve/veos/include"]
library_dirs=["veosinfo", "/opt/nec/ve/veos/lib64"],
include_dirs=["veosinfo", "/opt/nec/ve/veos/include"]
)
]

Expand Down Expand Up @@ -54,6 +54,7 @@
license = "GPLv2",
description = "Python bindings for the veosinfo library for the SX-Aurora Vector Engine",
long_description = _long_descr,
packages = [ "veosinfo" ],
data_files = [("share/py-veosinfo", ["README.md"])],
url = "https://github.com/sx-aurora/py-veosinfo",
classifiers=[
Expand Down
2 changes: 2 additions & 0 deletions veosinfo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from veosinfo._veosinfo import *
from metrics import *
57 changes: 0 additions & 57 deletions veosinfo.pyx → veosinfo/_veosinfo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -535,60 +535,3 @@ def ve_pid_perf(int nodeid, int pid):
res[regname] = regval[2 + i]
return res


ve_cpu_info_cache = dict()

def calc_metrics(nodeid, old, new):
"""
Calculate metrics from two perf counter values dicts.
nodeid needs to be passed in order to have the correct value of the clock.
The result is stored in a dict with keys being the metric names.
MOPS = (EX-VX+VE+FMAEC) / USRCC*clck
MFLOPS = FPEC/USRCC*clck
V.OP RATIO = VE/(EX-VX+VE)*100
AVER. V.LEN [-] = VE/VX
VECTOR TIME = VECC/1.4GHz
L1CACHE MISS = L1MCC/1.4GHz
CPU PORT CONF = PCCC/1.4GHz
VLD LLC HIT E [%] = (1-VLCME/VLEC)*100
"""
global ve_cpu_info
r = dict()
if nodeid not in ve_cpu_info_cache:
ve_cpu_info_cache[nodeid] = cpu_info(nodeid)
clck = float(ve_cpu_info_cache[nodeid]['mhz'])
clck_hz = clck * 1000000
for _r in ["EX", "VX", "VE", "FMAEC", "FPEC", "USRCC", "VECC",
"L1MCC", "PCCC", "VLCME", "VLEC", "T"]:
exec("d%s = float(new.get(\"%s\", 0) - old.get(\"%s\", 0))" % (_r, _r, _r))
#exec("print \"d%s=%%r new %s=%%r old %s=%%r\" %% (d%s, new.get(\"%s\", 0), old.get(\"%s\", 0))" %
# (_r, _r, _r, _r, _r, _r))


r["USRSEC"] = new.get("USRCC", 0) / clck_hz
r["USRTIME"] = dUSRCC / clck_hz
r["ELAPSED"] = dT

if r["ELAPSED"] > 0:
r["EFFTIME"] = r["USRTIME"] / r["ELAPSED"]

if dUSRCC > 0:
r["MOPS"] = (dEX - dVX + dVE + dFMAEC) * clck / dUSRCC
r["MFLOPS"] = dFPEC * clck / dUSRCC
r["VTIMERATIO"] = dVECC * 100 / dUSRCC
r["L1CACHEMISS"] = dL1MCC * 100 / dUSRCC
r["CPUPORTCONF"] = dPCCC * 100 / dUSRCC

if dEX > 0:
r["VOPRAT"] = dVE * 100 / (dEX - dVX + dVE)

if dVX > 0:
r["AVGVL"] = dVE / dVX

if dVLEC > 0:
r["VLDLLCHIT"] = (1 - dVLCME / dVLEC) * 100

return r

59 changes: 59 additions & 0 deletions veosinfo/metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from _veosinfo import cpu_info


ve_cpu_info_cache = dict()


def calc_metrics(nodeid, old, new):
"""
Calculate metrics from two perf counter values dicts.
nodeid needs to be passed in order to have the correct value of the clock.
The result is stored in a dict with keys being the metric names.
MOPS = (EX-VX+VE+FMAEC) / USRCC*clck
MFLOPS = FPEC/USRCC*clck
V.OP RATIO = VE/(EX-VX+VE)*100
AVER. V.LEN [-] = VE/VX
VECTOR TIME = VECC/1.4GHz
L1CACHE MISS = L1MCC/1.4GHz
CPU PORT CONF = PCCC/1.4GHz
VLD LLC HIT E [%] = (1-VLCME/VLEC)*100
"""
global ve_cpu_info_cache
r = dict()
if nodeid not in ve_cpu_info_cache:
ve_cpu_info_cache[nodeid] = cpu_info(nodeid)
clck = float(ve_cpu_info_cache[nodeid]['mhz'])
clck_hz = clck * 1000000
for _r in ["EX", "VX", "VE", "FMAEC", "FPEC", "USRCC", "VECC",
"L1MCC", "PCCC", "VLCME", "VLEC", "T"]:
exec("d%s = float(new.get(\"%s\", 0) - old.get(\"%s\", 0))" % (_r, _r, _r))
#exec("print \"d%s=%%r new %s=%%r old %s=%%r\" %% (d%s, new.get(\"%s\", 0), old.get(\"%s\", 0))" %
# (_r, _r, _r, _r, _r, _r))


r["USRSEC"] = new.get("USRCC", 0) / clck_hz
r["USRTIME"] = dUSRCC / clck_hz
r["ELAPSED"] = dT

if r["ELAPSED"] > 0:
r["EFFTIME"] = r["USRTIME"] / r["ELAPSED"]

if dUSRCC > 0:
r["MOPS"] = (dEX - dVX + dVE + dFMAEC) * clck / dUSRCC
r["MFLOPS"] = dFPEC * clck / dUSRCC
r["VTIMERATIO"] = dVECC * 100 / dUSRCC
r["L1CACHEMISS"] = dL1MCC * 100 / dUSRCC
r["CPUPORTCONF"] = dPCCC * 100 / dUSRCC

if dEX > 0:
r["VOPRAT"] = dVE * 100 / (dEX - dVX + dVE)

if dVX > 0:
r["AVGVL"] = dVE / dVX

if dVLEC > 0:
r["VLDLLCHIT"] = (1 - dVLCME / dVLEC) * 100

return r

0 comments on commit ba6f88d

Please sign in to comment.