Skip to content

Commit

Permalink
first draft of verrou_dd_stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
lathuili committed Jul 5, 2023
1 parent f1a4cce commit 26db94c
Show file tree
Hide file tree
Showing 5 changed files with 394 additions and 140 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pkginclude_HEADERS = verrou.h synchroLib/verrouSynchroLib.h

PYTHON_REP=pyTools

bin_SCRIPTS = ${PYTHON_REP}/verrou_dd_line ${PYTHON_REP}/verrou_dd_sym ${PYTHON_REP}/genCovBB ${PYTHON_REP}/verrou_plot_stat ${PYTHON_REP}/paraview_script.py ${PYTHON_REP}/verrou_dd_synchro ${PYTHON_REP}/post_verrou_dd
bin_SCRIPTS = ${PYTHON_REP}/verrou_dd_line ${PYTHON_REP}/verrou_dd_sym ${PYTHON_REP}/genCovBB ${PYTHON_REP}/verrou_plot_stat ${PYTHON_REP}/paraview_script.py ${PYTHON_REP}/verrou_dd_synchro ${PYTHON_REP}/post_verrou_dd ${PYTHON_REP}/verrou_dd_stdout

pkgpython_PYTHON = ${PYTHON_REP}/DD.py ${PYTHON_REP}/dd_config.py ${PYTHON_REP}/DD_stoch.py ${PYTHON_REP}/DD_exec_stat.py ${PYTHON_REP}/convNumLineTool.py ${PYTHON_REP}/post_config.py ${PYTHON_REP}/gen_config.py ${PYTHON_REP}/rounding_tool.py

Expand Down
25 changes: 16 additions & 9 deletions pyTools/DD_stoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def failure():

class DDStoch(DD.DD):
def __init__(self, config, prefix,
selectBlocAndNumLine=lambda x: (x,0), joinBlocAndNumLine= lambda x,y: x ):
selectBlocAndNumLine=lambda x: (x,0), joinBlocAndNumLine= lambda x,y: x,
parseRef=None):
DD.DD.__init__(self)
self.config_=config
if not self.config_.get_quiet():
Expand All @@ -333,7 +334,7 @@ def __init__(self, config, prefix,
self.prepareCache()
prepareOutput(self.ref_)
self.reference() #generate the reference computation
self.mergeList() #generate the search space
self.mergeList(parseRef) #generate the search space
self.rddminHeuristicLoadRep(selectBlocAndNumLine, joinBlocAndNumLine) # at the end because need the search space


Expand Down Expand Up @@ -506,7 +507,7 @@ def reference(self):
print("PASS")


def mergeList(self):
def mergeList(self, parseRef):
"""merge the file name.$PID into a uniq file called name """
dirname=self.ref_
name=self.getDeltaFileName()
Expand All @@ -520,11 +521,17 @@ def mergeList(self):
# for excludeFile in listOfExcludeFile[1:]:
excludeMerged=[]
for excludeFile in listOfExcludeFile:
with open(os.path.join(dirname,excludeFile), "r") as f:
for line in f.readlines():
rsline=line.rstrip()
if rsline not in excludeMerged:
excludeMerged+=[rsline]
lines=None
if parseRef==None:
with open(os.path.join(dirname,excludeFile), "r") as f:
lines=[x.rstrip() for x in f.readlines()]
else:
lines=parseRef(os.path.join(dirname,excludeFile))

for line in lines:
if line not in excludeMerged:
excludeMerged+=[line]

with open(os.path.join(dirname, name), "w" )as f:
for line in excludeMerged:
f.write(line+"\n")
Expand Down Expand Up @@ -946,7 +953,7 @@ def fullPerturbationSucceedsFailure(self):
failure()

def noPerturbationFailsFailure(self):
print("FAILURE: the comparison between the reference (code instrumented with nearest mode) andthe code without instrumentation failed")
print("FAILURE: the comparison between the reference (code instrumented with nearest mode) and the code without instrumentation failed")

print("Suggestions:")
print("\t1) check if reproducibilty discrepancies are larger than the failure criteria of the script %s"%self.compare_)
Expand Down
155 changes: 155 additions & 0 deletions pyTools/verrou_dd_stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/usr/bin/env python3

# This file is part of Verrou, a FPU instrumentation tool.

# Copyright (C) 2014-2021 EDF
# F. Févotte <francois.fevotte@edf.fr>
# B. Lathuilière <bruno.lathuiliere@edf.fr>


# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307, USA.

# The GNU Lesser General Public License is contained in the file COPYING.

import sys
import os
import subprocess
from valgrind import dd_config
from valgrind import DD_stoch
from valgrind import DD_exec_stat



import re

#adapatation from https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers
regExp="([+-]?(?:\d+([.]\d*)(?:[eE][+-]?\d+)?|[.]\d+(?:[eE][+-]?\d+)?))"
regCompiled=re.compile(regExp)

def floatReplace(lineStr):
return regCompiled.sub("*",lineStr)



def selectFloatTask(logFile):
currentTask=None
taskRes=[]

taskPattern="match [0]: "
fpInstrPattern="fp_instr: "
taskName=None
for line in open(logFile).readlines():
if line.startswith(taskPattern):
taskName=line[len(taskPattern):]
if taskName.endswith("\n"):
taskName=taskName[0:-1]
if line.startswith(fpInstrPattern):
if taskName==None:
if len(taskRes)==0:
taskName="__verrou__stdout__init__"
else:
print("Failure selectFloatTask")
sys.exit(42)
nbInstr=int(line[len(fpInstrPattern):])
if nbInstr!=0:
taskName=floatReplace(taskName)
if not (taskName in taskRes):
taskRes+=[taskName]

return taskRes


class DDstdout(DD_stoch.DDStoch):
def __init__(self, config, prefix="dd.stdout"):
DD_stoch.DDStoch.__init__(self, config, prefix,parseRef=selectFloatTask)


def referenceRunEnv(self):
refPath=os.path.join(self.ref_, "vr_expect_ref.txt")
refFile=open(refPath,"w")
refFile.write("verbose: 1\n")
refFile.write("post-init: nb_instr\n")
refFile.write("match: *\n")
refFile.write("apply: reset_counter\n")
refFile.write("post-apply: nb_instr\n")
refFile.write("begin:\n")
refFile.close()
return {"PYTHONUNBUFFERED": "x",
"VERROU_ROUNDING_MODE": "nearest",
"VERROU_MCA_MODE": "ieee",
"VERROU_EXPECT_CLR":refPath}

def isFileValidToMerge(self, name):
return name.startswith("vr_expect_ref.txt.log-")

def getDeltaFileName(self):
return "dd.expect"


def genExcludeIncludeFile(self, dirname, deltas, include=False, exclude=False):
"""Generate the *.exclude and *.include file in dirname rep from deltas"""
excludes=self.getDelta0()
dd=self.getDeltaFileName()

with open(os.path.join(dirname,"vr_expect.txt"), "w") as f:
f.write("verbose: 1\n")
if "__verrou__stdout__init__" in excludes:
if "__verrou__stdout__init__" in deltas:
f.write("init: start\n")
else:
f.write("init: stop\n" )

for line in excludes:
if line=="__verrou__stdout__init__":
continue
f.write("match: "+ line+"\n")
if line in deltas:
f.write("apply: start\n")
else:
f.write("apply: stop\n")
f.write("begin:")

if include:
with open(os.path.join(dirname,dd+".include"), "w") as f:
for d in deltas:
f.write(d+"\n")

if exclude:
with open(os.path.join(dirname,dd+".exclude"), "w") as f:
for d in deltas:
excludes.remove(d)

for line in excludes:
f.write(line+"\n")

def sampleRunEnv(self,dirName):
return {"PYTHONUNBUFFERED": "x",
"VERROU_EXPECT_CLR": os.path.join(dirName, "vr_expect.txt")}

def coerce(self, delta_config):
return "\n "+" \n ".join(["%s"%e for e in [l.strip() for l in delta_config ]])
# return "\n " + "\n ".join(["%s:%d (%s)" % e for e in
# [(col[0], int(col[1]), self.demangle(col[2])) for col in
# [(l.strip()+"\t\t").split("\t") for l in delta_config]]])



if __name__ == "__main__":
et=DD_exec_stat.exec_stat("dd.stdout")
config=dd_config.ddConfig(sys.argv,os.environ, ["INTERFLOP","VERROU"])
dd = DDstdout(config)
dd.run()
et.terminate()
2 changes: 1 addition & 1 deletion synchroLib/tstDDPython/Muller.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def muller(nt,verbose=False):


if __name__=="__main__":
muller(12)
muller(12, True)

0 comments on commit 26db94c

Please sign in to comment.