More trailing whitespace
This commit is contained in:
parent
483fa8458d
commit
568fa2a6f8
41
driver.py
41
driver.py
@ -20,10 +20,10 @@ import optparse;
|
|||||||
def computeMissScore(miss, lower, upper, full_score):
|
def computeMissScore(miss, lower, upper, full_score):
|
||||||
if miss <= lower:
|
if miss <= lower:
|
||||||
return full_score
|
return full_score
|
||||||
if miss >= upper:
|
if miss >= upper:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
score = (miss - lower) * 1.0
|
score = (miss - lower) * 1.0
|
||||||
range = (upper- lower) * 1.0
|
range = (upper- lower) * 1.0
|
||||||
return round((1 - score / range) * full_score, 1)
|
return round((1 - score / range) * full_score, 1)
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ def main():
|
|||||||
maxscore['trans64'] = 8
|
maxscore['trans64'] = 8
|
||||||
maxscore['trans61'] = 10
|
maxscore['trans61'] = 10
|
||||||
|
|
||||||
# Parse the command line arguments
|
# Parse the command line arguments
|
||||||
p = optparse.OptionParser()
|
p = optparse.OptionParser()
|
||||||
p.add_option("-A", action="store_true", dest="autograde",
|
p.add_option("-A", action="store_true", dest="autograde",
|
||||||
help="emit autoresult string for Autolab");
|
help="emit autoresult string for Autolab");
|
||||||
opts, args = p.parse_args()
|
opts, args = p.parse_args()
|
||||||
autograde = opts.autograde
|
autograde = opts.autograde
|
||||||
@ -50,7 +50,7 @@ def main():
|
|||||||
# Check the correctness of the cache simulator
|
# Check the correctness of the cache simulator
|
||||||
print "Part A: Testing cache simulator"
|
print "Part A: Testing cache simulator"
|
||||||
print "Running ./test-csim"
|
print "Running ./test-csim"
|
||||||
p = subprocess.Popen("./test-csim",
|
p = subprocess.Popen("./test-csim",
|
||||||
shell=True, stdout=subprocess.PIPE)
|
shell=True, stdout=subprocess.PIPE)
|
||||||
stdout_data = p.communicate()[0]
|
stdout_data = p.communicate()[0]
|
||||||
|
|
||||||
@ -66,25 +66,25 @@ def main():
|
|||||||
# 32x32 transpose
|
# 32x32 transpose
|
||||||
print "Part B: Testing transpose function"
|
print "Part B: Testing transpose function"
|
||||||
print "Running ./test-trans -M 32 -N 32"
|
print "Running ./test-trans -M 32 -N 32"
|
||||||
p = subprocess.Popen("./test-trans -M 32 -N 32 | grep TEST_TRANS_RESULTS",
|
p = subprocess.Popen("./test-trans -M 32 -N 32 | grep TEST_TRANS_RESULTS",
|
||||||
shell=True, stdout=subprocess.PIPE)
|
shell=True, stdout=subprocess.PIPE)
|
||||||
stdout_data = p.communicate()[0]
|
stdout_data = p.communicate()[0]
|
||||||
result32 = re.findall(r'(\d+)', stdout_data)
|
result32 = re.findall(r'(\d+)', stdout_data)
|
||||||
|
|
||||||
# 64x64 transpose
|
# 64x64 transpose
|
||||||
print "Running ./test-trans -M 64 -N 64"
|
print "Running ./test-trans -M 64 -N 64"
|
||||||
p = subprocess.Popen("./test-trans -M 64 -N 64 | grep TEST_TRANS_RESULTS",
|
p = subprocess.Popen("./test-trans -M 64 -N 64 | grep TEST_TRANS_RESULTS",
|
||||||
shell=True, stdout=subprocess.PIPE)
|
shell=True, stdout=subprocess.PIPE)
|
||||||
stdout_data = p.communicate()[0]
|
stdout_data = p.communicate()[0]
|
||||||
result64 = re.findall(r'(\d+)', stdout_data)
|
result64 = re.findall(r'(\d+)', stdout_data)
|
||||||
|
|
||||||
# 61x67 transpose
|
# 61x67 transpose
|
||||||
print "Running ./test-trans -M 61 -N 67"
|
print "Running ./test-trans -M 61 -N 67"
|
||||||
p = subprocess.Popen("./test-trans -M 61 -N 67 | grep TEST_TRANS_RESULTS",
|
p = subprocess.Popen("./test-trans -M 61 -N 67 | grep TEST_TRANS_RESULTS",
|
||||||
shell=True, stdout=subprocess.PIPE)
|
shell=True, stdout=subprocess.PIPE)
|
||||||
stdout_data = p.communicate()[0]
|
stdout_data = p.communicate()[0]
|
||||||
result61 = re.findall(r'(\d+)', stdout_data)
|
result61 = re.findall(r'(\d+)', stdout_data)
|
||||||
|
|
||||||
# Compute the scores for each step
|
# Compute the scores for each step
|
||||||
csim_cscore = map(int, resultsim[0:1])
|
csim_cscore = map(int, resultsim[0:1])
|
||||||
trans_cscore = int(result32[0]) * int(result64[0]) * int(result61[0]);
|
trans_cscore = int(result32[0]) * int(result64[0]) * int(result61[0]);
|
||||||
@ -99,40 +99,39 @@ def main():
|
|||||||
# Summarize the results
|
# Summarize the results
|
||||||
print "\nCache Lab summary:"
|
print "\nCache Lab summary:"
|
||||||
print "%-22s%8s%10s%12s" % ("", "Points", "Max pts", "Misses")
|
print "%-22s%8s%10s%12s" % ("", "Points", "Max pts", "Misses")
|
||||||
print "%-22s%8.1f%10d" % ("Csim correctness", csim_cscore[0],
|
print "%-22s%8.1f%10d" % ("Csim correctness", csim_cscore[0],
|
||||||
maxscore['csim'])
|
maxscore['csim'])
|
||||||
|
|
||||||
misses = str(miss32)
|
misses = str(miss32)
|
||||||
if miss32 == 2**31-1 :
|
if miss32 == 2**31-1 :
|
||||||
misses = "invalid"
|
misses = "invalid"
|
||||||
print "%-22s%8.1f%10d%12s" % ("Trans perf 32x32", trans32_score,
|
print "%-22s%8.1f%10d%12s" % ("Trans perf 32x32", trans32_score,
|
||||||
maxscore['trans32'], misses)
|
maxscore['trans32'], misses)
|
||||||
|
|
||||||
misses = str(miss64)
|
misses = str(miss64)
|
||||||
if miss64 == 2**31-1 :
|
if miss64 == 2**31-1 :
|
||||||
misses = "invalid"
|
misses = "invalid"
|
||||||
print "%-22s%8.1f%10d%12s" % ("Trans perf 64x64", trans64_score,
|
print "%-22s%8.1f%10d%12s" % ("Trans perf 64x64", trans64_score,
|
||||||
maxscore['trans64'], misses)
|
maxscore['trans64'], misses)
|
||||||
|
|
||||||
misses = str(miss61)
|
misses = str(miss61)
|
||||||
if miss61 == 2**31-1 :
|
if miss61 == 2**31-1 :
|
||||||
misses = "invalid"
|
misses = "invalid"
|
||||||
print "%-22s%8.1f%10d%12s" % ("Trans perf 61x67", trans61_score,
|
print "%-22s%8.1f%10d%12s" % ("Trans perf 61x67", trans61_score,
|
||||||
maxscore['trans61'], misses)
|
maxscore['trans61'], misses)
|
||||||
|
|
||||||
print "%22s%8.1f%10d" % ("Total points", total_score,
|
print "%22s%8.1f%10d" % ("Total points", total_score,
|
||||||
maxscore['csim'] +
|
maxscore['csim'] +
|
||||||
maxscore['trans32'] +
|
maxscore['trans32'] +
|
||||||
maxscore['trans64'] +
|
maxscore['trans64'] +
|
||||||
maxscore['trans61'])
|
maxscore['trans61'])
|
||||||
|
|
||||||
# Emit autoresult string for Autolab if called with -A option
|
# Emit autoresult string for Autolab if called with -A option
|
||||||
if autograde:
|
if autograde:
|
||||||
autoresult="%.1f:%d:%d:%d" % (total_score, miss32, miss64, miss61)
|
autoresult="%.1f:%d:%d:%d" % (total_score, miss32, miss64, miss61)
|
||||||
print "\nAUTORESULT_STRING=%s" % autoresult
|
print "\nAUTORESULT_STRING=%s" % autoresult
|
||||||
|
|
||||||
|
|
||||||
# execute main only if called as a script
|
# execute main only if called as a script
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user