Skip to content

Instantly share code, notes, and snippets.

@adhithyan15
Created March 8, 2016 18:41
Show Gist options
  • Save adhithyan15/cb227dc0c536185c23cc to your computer and use it in GitHub Desktop.
Save adhithyan15/cb227dc0c536185c23cc to your computer and use it in GitHub Desktop.
import sys
import subprocess
number_of_processes = int(sys.argv[1])
number_of_iterations = 5
barrier_time = []
execution_time = []
mpi_loc = "/opt/openmpi-1.4.3-gcc44/bin/mpirun"
for x in range(0, number_of_iterations):
p = subprocess.Popen(mpi_loc + ' -n ' + str(number_of_processes) + " ./test_db", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = p.stdout.readlines()
offset = 2*number_of_processes
for y in range(0, number_of_processes):
output[offset].strip()
b_time = output[offset].split(":")[1]
b_time.strip()
if int(b_time) > 0:
barrier_time.append(int(b_time))
output[offset+1].strip()
e_time = output[offset+1].split(":")[1]
e_time.strip()
if int(e_time) > 0:
execution_time.append(int(e_time))
offset += 2
b_time_avg = reduce(lambda x, y: x + y, barrier_time) / len(barrier_time)
e_time_avg = reduce(lambda x, y: x + y, execution_time) / len(execution_time)
print "Dissemination Barrier Results:"
print "Number of Processes: " + str(number_of_processes)
print "Number of Iterations of Experiment: " + str(number_of_iterations)
print "Avg time spent waiting at the barrier: " + str(b_time_avg)
print "Avg execution time for each process:" + str(e_time_avg)
print barrier_time
print execution_time
print ""
barrier_time = []
execution_time = []
for x in range(0, number_of_iterations):
p = subprocess.Popen(mpi_loc + ' -n ' + str(number_of_processes) + " ./test_tb", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = p.stdout.readlines()
offset = 2*number_of_processes
for y in range(0, number_of_processes):
output[offset].strip()
b_time = output[offset].split(":")[1]
b_time.strip()
if int(b_time) > 0:
barrier_time.append(int(b_time))
output[offset+1].strip()
e_time = output[offset+1].split(":")[1]
e_time.strip()
if int(e_time) > 0:
execution_time.append(int(e_time))
offset += 2
b_time_avg = reduce(lambda x, y: x + y, barrier_time) / len(barrier_time)
e_time_avg = reduce(lambda x, y: x + y, execution_time) / len(execution_time)
print "Tournament Barrier Results:"
print "Number of Processes: " + str(number_of_processes)
print "Number of Iterations of Experiment: " + str(number_of_iterations)
print "Avg time spent waiting at the barrier: " + str(b_time_avg)
print "Avg execution time for each process:" + str(e_time_avg)
print barrier_time
print execution_time
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment