mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-04 10:10:08 +01:00
huge refactoring
This commit is contained in:
62
EUsched.py
62
EUsched.py
@@ -30,7 +30,11 @@ class Scheduler(object):
|
|||||||
def schedule_FCFS(self):
|
def schedule_FCFS(self):
|
||||||
'''
|
'''
|
||||||
Schedules Instruction Form list via First Come First Serve algorithm.
|
Schedules Instruction Form list via First Come First Serve algorithm.
|
||||||
Returns a tuple containing the graphic output as string and the total throughput time as int
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
(str, int)
|
||||||
|
A tuple containing the graphic output as string and the total throughput time as int.
|
||||||
'''
|
'''
|
||||||
sched = ''
|
sched = ''
|
||||||
total = 0
|
total = 0
|
||||||
@@ -41,7 +45,7 @@ class Scheduler(object):
|
|||||||
searchString = instrForm[0]+'-'+self.get_operand_suffix(instrForm)
|
searchString = instrForm[0]+'-'+self.get_operand_suffix(instrForm)
|
||||||
entry = self.df.loc[lambda df: df.instr == searchString,'LT':'ports']
|
entry = self.df.loc[lambda df: df.instr == searchString,'LT':'ports']
|
||||||
tup = entry.ports.values[0]
|
tup = entry.ports.values[0]
|
||||||
if(len(tup) == 1 and tup[0] == -1):
|
if(len(tup) == 1 and tup[0][0] == -1):
|
||||||
raise IndexError()
|
raise IndexError()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# Instruction form not in CSV
|
# Instruction form not in CSV
|
||||||
@@ -68,7 +72,20 @@ class Scheduler(object):
|
|||||||
|
|
||||||
def test_ports_FCFS(self, occ_ports, needed_ports):
|
def test_ports_FCFS(self, occ_ports, needed_ports):
|
||||||
'''
|
'''
|
||||||
tests if current configuration of ports is possible and returns boolean
|
Test if current configuration of ports is possible and returns boolean
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
occ_ports : [int]
|
||||||
|
Tuple to inspect for current port occupation
|
||||||
|
needed_ports : (int)
|
||||||
|
Tuple with needed port(s) for particular instruction form
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
bool
|
||||||
|
True if needed ports can get scheduled on current port occupation
|
||||||
|
False if not
|
||||||
'''
|
'''
|
||||||
for port in needed_ports:
|
for port in needed_ports:
|
||||||
if(occ_ports[port] != 0):
|
if(occ_ports[port] != 0):
|
||||||
@@ -76,10 +93,21 @@ class Scheduler(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def schedule_Tomasulo(self):
|
def schedule_Tomasulo(self):
|
||||||
|
'''
|
||||||
|
Not implement yet. Schedules Instruction Form list via Tomasulo algorithm.
|
||||||
|
'''
|
||||||
print('Scheduling with Tomasulo algorithm...')
|
print('Scheduling with Tomasulo algorithm...')
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def get_head(self):
|
def get_head(self):
|
||||||
|
'''
|
||||||
|
Creates right heading for CPU architecture.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
String containing the header
|
||||||
|
'''
|
||||||
analysis = 'Throughput Analysis Report\n'+('-'*26)+'\n'
|
analysis = 'Throughput Analysis Report\n'+('-'*26)+'\n'
|
||||||
annotations = ( '* - No information for this instruction in database\n'
|
annotations = ( '* - No information for this instruction in database\n'
|
||||||
'\n')
|
'\n')
|
||||||
@@ -93,6 +121,21 @@ class Scheduler(object):
|
|||||||
return head
|
return head
|
||||||
|
|
||||||
def get_line(self, occ_ports, instrName):
|
def get_line(self, occ_ports, instrName):
|
||||||
|
'''
|
||||||
|
Create line with port occupation for output.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
occ_ports : (int)
|
||||||
|
Integer tuple containing needed ports
|
||||||
|
instrName : str
|
||||||
|
Name of instruction form for output
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
String for output containing port scheduling for instrName
|
||||||
|
'''
|
||||||
line = ''
|
line = ''
|
||||||
for i in occ_ports:
|
for i in occ_ports:
|
||||||
cycles = ' ' if (i == 0) else float(i)
|
cycles = ' ' if (i == 0) else float(i)
|
||||||
@@ -102,6 +145,19 @@ class Scheduler(object):
|
|||||||
|
|
||||||
|
|
||||||
def get_operand_suffix(self, instrForm):
|
def get_operand_suffix(self, instrForm):
|
||||||
|
'''
|
||||||
|
Creates operand suffix out of list of Parameters.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
instrForm : [str, Parameter, ..., Parameter, str]
|
||||||
|
Instruction Form data structure
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
Operand suffix for searching in database
|
||||||
|
'''
|
||||||
extension = ''
|
extension = ''
|
||||||
opExt = []
|
opExt = []
|
||||||
for i in range(1, len(instrForm)-1):
|
for i in range(1, len(instrForm)-1):
|
||||||
|
|||||||
24
Params.py
24
Params.py
@@ -7,6 +7,14 @@ class Parameter(object):
|
|||||||
raise NameError("Type not supported: "+ptype)
|
raise NameError("Type not supported: "+ptype)
|
||||||
|
|
||||||
def print(self):
|
def print(self):
|
||||||
|
'''
|
||||||
|
Prints Parameter.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
Parameter as string
|
||||||
|
'''
|
||||||
if(self.ptype == "NONE"):
|
if(self.ptype == "NONE"):
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
@@ -44,6 +52,14 @@ class MemAddr(Parameter):
|
|||||||
raise NameError("Type not supported: "+name)
|
raise NameError("Type not supported: "+name)
|
||||||
|
|
||||||
def print(self):
|
def print(self):
|
||||||
|
'''
|
||||||
|
Prints MemAddr.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
MemAddr as string
|
||||||
|
'''
|
||||||
mem_format = "MEM("
|
mem_format = "MEM("
|
||||||
if(self.sreg):
|
if(self.sreg):
|
||||||
mem_format += "sreg:"
|
mem_format += "sreg:"
|
||||||
@@ -100,6 +116,14 @@ class Register(Parameter):
|
|||||||
# print(lncnt)
|
# print(lncnt)
|
||||||
|
|
||||||
def print(self):
|
def print(self):
|
||||||
|
'''
|
||||||
|
Prints Register.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
Register as string
|
||||||
|
'''
|
||||||
opmask = ""
|
opmask = ""
|
||||||
if(self.mask):
|
if(self.mask):
|
||||||
opmask = "{opmask}"
|
opmask = "{opmask}"
|
||||||
|
|||||||
82
Testcase.py
82
Testcase.py
@@ -54,7 +54,7 @@ class Testcase(object):
|
|||||||
##----------------------------------------------------------------
|
##----------------------------------------------------------------
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
def __init__(self, _mnemonic, _param_list, _num_instr='12'):
|
def __init__(self, _mnemonic, _param_list, _num_instr='32'):
|
||||||
self.instr = _mnemonic.lower()
|
self.instr = _mnemonic.lower()
|
||||||
self.param_list = _param_list
|
self.param_list = _param_list
|
||||||
# num_instr must be an even number
|
# num_instr must be an even number
|
||||||
@@ -71,6 +71,9 @@ class Testcase(object):
|
|||||||
|
|
||||||
|
|
||||||
def write_testcase(self):
|
def write_testcase(self):
|
||||||
|
"""
|
||||||
|
Write testcase for class attributes in a file.
|
||||||
|
"""
|
||||||
regs = self.param_list
|
regs = self.param_list
|
||||||
extension = ''
|
extension = ''
|
||||||
# Add operands
|
# Add operands
|
||||||
@@ -94,6 +97,15 @@ class Testcase(object):
|
|||||||
|
|
||||||
# Check operands
|
# Check operands
|
||||||
def __define_operands(self):
|
def __define_operands(self):
|
||||||
|
"""
|
||||||
|
Check for the number of operands and initialise the GPRs if necessary.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
(str, str, str, str, str, str)
|
||||||
|
String tuple containing types of operands and if needed push/pop operations, the
|
||||||
|
initialisation of general purpose regs and the copy if registers.
|
||||||
|
"""
|
||||||
oprnds = self.param_list
|
oprnds = self.param_list
|
||||||
op_a, op_b, op_c = ('', '', '')
|
op_a, op_b, op_c = ('', '', '')
|
||||||
gprPush, gprPop, zeroGPR = ('', '', '')
|
gprPush, gprPop, zeroGPR = ('', '', '')
|
||||||
@@ -138,8 +150,17 @@ class Testcase(object):
|
|||||||
copy = ''
|
copy = ''
|
||||||
return (op_a, op_b, op_c, gprPush, gprPop, zeroGPR, copy)
|
return (op_a, op_b, op_c, gprPush, gprPop, zeroGPR, copy)
|
||||||
|
|
||||||
# Initialise 11 general purpose registers and set them to zero
|
|
||||||
def __initialise_gprs(self):
|
def __initialise_gprs(self):
|
||||||
|
"""
|
||||||
|
Initialise eleven general purpose registers and set them to zero.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
(str, str, str)
|
||||||
|
String tuple for push, pop and initalisation operations
|
||||||
|
"""
|
||||||
|
|
||||||
gprPush = ''
|
gprPush = ''
|
||||||
gprPop = ''
|
gprPop = ''
|
||||||
zeroGPR = ''
|
zeroGPR = ''
|
||||||
@@ -154,6 +175,19 @@ class Testcase(object):
|
|||||||
|
|
||||||
# Copy created values in specific register
|
# Copy created values in specific register
|
||||||
def __copy_regs(self, reg):
|
def __copy_regs(self, reg):
|
||||||
|
"""
|
||||||
|
Copy created values in specific register.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
reg : Register
|
||||||
|
Register for copying the value
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
String containing the copy instructions
|
||||||
|
"""
|
||||||
copy = '\t\t# copy DP 1.0\n'
|
copy = '\t\t# copy DP 1.0\n'
|
||||||
# Different handling for GPR, MMX and SSE/AVX registers
|
# Different handling for GPR, MMX and SSE/AVX registers
|
||||||
if(reg.reg_type == 'GPR'):
|
if(reg.reg_type == 'GPR'):
|
||||||
@@ -188,6 +222,14 @@ class Testcase(object):
|
|||||||
|
|
||||||
|
|
||||||
def __define_header(self):
|
def __define_header(self):
|
||||||
|
"""
|
||||||
|
Define header.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
(str, str, str, str)
|
||||||
|
String tuple containing the header, value initalisations and extensions
|
||||||
|
"""
|
||||||
def_instr = '#define INSTR '+self.instr+'\n'
|
def_instr = '#define INSTR '+self.instr+'\n'
|
||||||
ninstr = '#define NINST '+self.num_instr+'\n'
|
ninstr = '#define NINST '+self.num_instr+'\n'
|
||||||
pi = ('PI:\n'
|
pi = ('PI:\n'
|
||||||
@@ -226,8 +268,16 @@ class Testcase(object):
|
|||||||
'\t\tvinsert64x4 zmm0, zmm0, ymm0, 0x1\n')
|
'\t\tvinsert64x4 zmm0, zmm0, ymm0, 0x1\n')
|
||||||
return (def_instr, ninstr, init, expand)
|
return (def_instr, ninstr, init, expand)
|
||||||
|
|
||||||
# Create latency loop
|
|
||||||
def __define_loop_lat(self):
|
def __define_loop_lat(self):
|
||||||
|
"""
|
||||||
|
Create latency loop.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
Latency loop as string
|
||||||
|
"""
|
||||||
loop_lat = ('loop:\n'
|
loop_lat = ('loop:\n'
|
||||||
'\t\tinc i\n')
|
'\t\tinc i\n')
|
||||||
if(self.num_operands == 1):
|
if(self.num_operands == 1):
|
||||||
@@ -253,8 +303,16 @@ class Testcase(object):
|
|||||||
'\t\tjl loop\n')
|
'\t\tjl loop\n')
|
||||||
return loop_lat
|
return loop_lat
|
||||||
|
|
||||||
# Create throughput loop
|
|
||||||
def __define_loop_thrpt(self):
|
def __define_loop_thrpt(self):
|
||||||
|
"""
|
||||||
|
Create throughput loop.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
Throughput loop as string
|
||||||
|
"""
|
||||||
loop_thrpt = ('loop:\n'
|
loop_thrpt = ('loop:\n'
|
||||||
'\t\tinc i\n')
|
'\t\tinc i\n')
|
||||||
ext = ''
|
ext = ''
|
||||||
@@ -278,6 +336,22 @@ class Testcase(object):
|
|||||||
|
|
||||||
|
|
||||||
def __is_in_dir(self, name, path):
|
def __is_in_dir(self, name, path):
|
||||||
|
"""
|
||||||
|
Check if file with the name name is in directory path.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
name : str
|
||||||
|
Name of file
|
||||||
|
path : str
|
||||||
|
Path of directory
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
bool
|
||||||
|
True if file is in directory
|
||||||
|
False if file is not in directory
|
||||||
|
"""
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
if name in files:
|
if name in files:
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user