Created
March 8, 2016 18:41
-
-
Save adhithyan15/cb227dc0c536185c23cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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