def decode_mtx_sig(mtxSigPath, maxRows, maxCols, channels, parEntries, accLatency, memBits, txtPath):
    if not path.exists(mtxSigPath):
        print("ERROR: {} directory doesn't exist.".format(mtxPath))
        return
    subprocess.run(["mkdir", "-p", txtPath])
    l_nnzFileNames, l_nnzTxtFileNames = [],[]
    for i in range(channels):
        l_nnzFileNames.append(mtxSigPath+'/nnzVal_' + str(i) + '.dat')
        l_nnzTxtFileNames.append(txtPath+'/nnzVal_' + str(i) + '.txt')

    l_parParamFileName = mtxSigPath+'/parParam.dat'
    l_parParamTxtFileName = txtPath+'/parParam.txt'
    l_rbParamFileName = mtxSigPath+'/rbParam.dat'
    l_rbParamTxtFileName = txtPath+'/rbParam.txt'
    l_infoFileName = mtxSigPath+'/info.dat'
    l_infoTxtFileName = txtPath+'/info.txt'
    l_sig = signature(parEntries, accLatency, channels, maxRows, maxCols, memBits)
    l_sig.load_rbParam(l_rbParamFileName)
    l_sig.print_rbParam(l_rbParamTxtFileName)
    l_sig.load_parParam(l_parParamFileName)
    l_sig.print_parParam(l_parParamTxtFileName)
    l_sig.load_nnz(l_nnzFileNames)
    l_sig.print_nnz(l_nnzTxtFileNames)
    l_sig.load_info(l_infoFileName)
    l_sig.print_info(l_infoTxtFileName)
def partition_matrix(mtxName, mtxFullName, maxRows, maxCols, channels, parEntries, accLatency, memBits, mtxSigPath):
    l_nnzFileNames = []
    for i in range(channels):
        l_nnzFileNames.append(mtxSigPath+'/nnzVal_' + str(i) + '.dat')

    l_parParamFileName = mtxSigPath+'/parParam.dat'
    l_rbParamFileName = mtxSigPath+'/rbParam.dat'
    l_infoFileName = mtxSigPath+'/info.dat'
    l_sig = signature(parEntries, accLatency, channels, maxRows, maxCols, memBits)
    l_sig.process(mtxFullName, mtxName)
    l_sig.store_rbParam(l_rbParamFileName)
    l_sig.store_parParam(l_parParamFileName)
    l_sig.store_nnz(l_nnzFileNames)
    l_sig.store_info(l_infoFileName)
Exemple #3
0
    def decorate(func):
        sig = signature(func)
        bound_types = sig.bind_partial(*type_args, **type_kwargs).arguments

        @wraps(func)
        def wrapper(*args, **kwargs):
            bound_values = sig.bind(*args, **kwargs)
            for name, value in bound_values.arguments.items():
                if name in bound_types:
                    if not isinstance(value, bound_types[name]):
                        raise TypeError('Argument {} must be {}'.format(
                            name, bound_types[name]))
            return func(*args, **kwargs)

        return wrapper
def check_signature(mtxName, mtxFullName, maxRows, maxCols, channels, parEntries, accLatency, memBits, mtxSigPath):
    l_nnzFileNames = []
    for i in range(channels):
        l_nnzFileNames.append(mtxSigPath+'/nnzVal_' + str(i) + '.dat')

    l_parParamFileName = mtxSigPath+'/parParam.dat'
    l_rbParamFileName = mtxSigPath+'/rbParam.dat'
    l_infoFileName = mtxSigPath+'/info.dat'
    l_sig = signature(parEntries, accLatency, channels, maxRows, maxCols, memBits)
    l_sig.load_rbParam(l_rbParamFileName)
    l_sig.load_parParam(l_parParamFileName)
    l_sig.load_nnz(l_nnzFileNames)
    l_sig.load_info(l_infoFileName)
    if l_sig.check(mtxFullName, mtxName):
        print("INFO: {} signature verification pass!".format(mtxName))
        return True 
    else:
        print("ERROR: {} signature verification failed!".format(mtxName))
        return False
from signature import *

threshold = 0.85;
OLDDIR = os.getcwd()
DIR = ".\\.."

print "\n--------------------\ncompare_func_sig.py has been started\n"
os.chdir(DIR)
ea = ScreenEA()

for function in Functions(SegStart(ea), SegEnd(ea)):
	func = get_func(function)
	fc = FlowChart(func)

	G = graph(fc)	
	sig = signature(fc, G, True)

	similarities = sig.compare()

	similarities.sort()

	print '_____Results of function at %x (Threshold = %0.2f)_____' % (func.startEA, float(threshold * 100.0))

	for item in similarities:
		if item.sim >= threshold:
			print 'Algorithm: %s, Compiler: %s, Optimization: %s' % (item.alg, item.cmp, item.opt)
			print 'Similarity: %0.2f\n' % (float(item.sim))
			
	del G
	del sig
	del similarities
from idaapi import *
from graph import *
from signature import *

OLDDIR = os.getcwd()
DIR = ".\\.."

print "\n--------------------\ncreate_func_sig.py has been started"
os.chdir(DIR)

ea = ScreenEA()
fc = FlowChart(get_func(ea))

G = graph(fc)	
sig = signature(fc, G, False)
sig.printSig()
sig.save()
		
print "create_func_sig.py has completed\n--------------------\n"
os.chdir(OLDDIR)