From 9ce44e10793a842db4b928baa5300b6bfc534eed Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Mon, 4 Jan 2021 20:51:23 +0100 Subject: [PATCH] high8 registers --- kernelNanoBench.py | 3 +- tools/cpuBench/cpuBench.py | 127 +++++++++++++++++++++++++++---------- tools/cpuBench/x64_lib.py | 43 ++++++------- 3 files changed, 115 insertions(+), 58 deletions(-) diff --git a/kernelNanoBench.py b/kernelNanoBench.py index 5220ae3..8ae82d4 100644 --- a/kernelNanoBench.py +++ b/kernelNanoBench.py @@ -13,7 +13,8 @@ def writeFile(fileName, content): def assemble(code, objFile, asmFile='/tmp/ramdisk/asm.s'): try: code = '.intel_syntax noprefix;' + code + ';1:;.att_syntax prefix\n' - with open(asmFile, 'w') as f: f.write(code); + with open(asmFile, 'w') as f: + f.write(code); subprocess.check_call(['as', asmFile, '-o', objFile]) except subprocess.CalledProcessError as e: sys.stderr.write("Error (assemble): " + str(e)) diff --git a/tools/cpuBench/cpuBench.py b/tools/cpuBench/cpuBench.py index 688fb92..7f8356c 100755 --- a/tools/cpuBench/cpuBench.py +++ b/tools/cpuBench/cpuBench.py @@ -111,7 +111,9 @@ def getRegMemInit(instrNode, opRegDict, memOffset, useIndexedAddr): reg = opRegDict[opIdx] regPrefix = re.sub('\d', '', reg) - if 'MM' in regPrefix and xtype.startswith('f'): + if reg in High8Regs: + init += ['MOV {}, 0'.format(reg)] + elif 'MM' in regPrefix and xtype.startswith('f'): init += ['MOV RAX, 0x4000000040000000'] for i in range(0, getRegSize(reg)/8, 8): init += ['MOV [R14+' + str(i) + '], RAX'] @@ -155,6 +157,7 @@ def runExperiment(instrNode, instrCode, init=None, unrollCount=500, loopCount=0, init = list(OrderedDict.fromkeys(init)) # remove duplicates while maintaining the order initCode = '; '.join(init) + useLateInit = any((reg in initCode.upper()) for reg in High8Regs) if instrNode is not None and (instrNode.attrib.get('vex', '') == '1' or instrNode.attrib.get('evex', '') == '1'): # vex and evex encoded instructions need a warm-up period before memory reads operate at full speed; @@ -174,19 +177,25 @@ def runExperiment(instrNode, instrCode, init=None, unrollCount=500, loopCount=0, nanoBenchCmd += ' -asm "' + instrCode + '"' initObjFile = None + lateInitObjFile=None if initCode: if debugOutput: print 'init: ' + initCode - initObjFile = '/tmp/ramdisk/init.o' - assemble(initCode, initObjFile, asmFile='/tmp/ramdisk/init.s') + objFile = '/tmp/ramdisk/init.o' + if useLateInit: + lateInitObjFile = objFile + nanoBenchCmd += ' -asm_late_init "' + initCode + '"' + else: + initObjFile = objFile + nanoBenchCmd += ' -asm_init "' + initCode + '"' + assemble(initCode, objFile, asmFile='/tmp/ramdisk/init.s') localHtmlReports.append('
  • Init:
    ' + re.sub(';[ \t]*(.)', r';\n\1', initCode) + '
  • \n') - nanoBenchCmd += ' -asm_init "' + initCode + '"' localHtmlReports.append('
  • Show nanoBench command
  • \n') if debugOutput: print nanoBenchCmd setNanoBenchParameters(unrollCount=unrollCount, loopCount=loopCount, warmUpCount=warmUpCount, basicMode=basicMode) - ret = runNanoBench(codeObjFile=codeObjFile, initObjFile=initObjFile) + ret = runNanoBench(codeObjFile=codeObjFile, initObjFile=initObjFile, lateInitObjFile=lateInitObjFile) localHtmlReports.append('
  • Results:\n