get_matrix_times.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/usr/bin/env python
  2. import sys, os, stat
  3. num_of_apps = int(sys.argv[1])
  4. MS = 1000000
  5. mean_idag = 0
  6. mean_init = 0
  7. mean_agent = 0
  8. in_app_filename = './app_input.txt'
  9. fd_app = open(in_app_filename, 'r')
  10. times_dir_base = './matrix_times/'
  11. for i in range(0,num_of_apps):
  12. input_filename = './app_logs/' + str(i) + '.txt'
  13. fd_r = open(input_filename, 'r')
  14. one_line = fd_app.readline().split()
  15. array_size = one_line[2]
  16. workld = int(one_line[3])
  17. print str(i) + ' ' + array_size
  18. times_dir = times_dir_base + array_size + '/'
  19. #[5:13:26:477789]: I am agent 31 . Init ok!! my_cores_count = 5 array_size = 2048
  20. one_line_app = fd_r.readline()
  21. one_line_app = fd_r.readline()
  22. one_line_app = fd_r.readline()
  23. app_line = one_line_app.split()
  24. active_cores = str(int(app_line[10]) - 1)
  25. if app_line[13] != array_size:
  26. print 'error ' + array_size + ' ' + app_line[13] + '\n'
  27. if int(active_cores) == 0:
  28. while True:
  29. one_line_app = fd_r.readline()
  30. if one_line_app.find('Self opt ok') != -1:
  31. app_line = one_line_app.split()
  32. active_cores = str(int(app_line[len(app_line) - 1]) - 1)
  33. break
  34. while workld > 0 :
  35. out_filename = times_dir + active_cores + '.txt'
  36. fd_w = open(out_filename, 'a')
  37. #first one will always be init
  38. while True:
  39. one_line_app = fd_r.readline()
  40. if one_line_app.find('work to') != -1:
  41. app_line = one_line_app.split()
  42. init_work = app_line[0].strip('[]')
  43. break
  44. while True:
  45. one_line_app = fd_r.readline()
  46. if one_line_app.find('atrix mul') != -1:
  47. app_line = one_line_app.split()
  48. finish_work = app_line[0].strip('[]')
  49. break
  50. workld -= 1;
  51. if workld > 0:
  52. #[5:13:28:341226] A matrix mul is over. Remaining workload is 3 active cores = 7
  53. active_cores = app_line[len(app_line) - 1]
  54. #while True:
  55. # one_line_app = fd_r.readline()
  56. # if one_line_app.find('Actual finish') != -1:
  57. # app_line = one_line_app.split()
  58. # actual_finish_work = app_line[0].strip('[]')
  59. # break
  60. #out_str = active_cores + ' -> ' + init_work + ' - ' + finish_work + ' = '
  61. time_m = init_work.split(':')
  62. time_m2 = finish_work.split(':')
  63. dif = ((int(time_m2[0]) - int(time_m[0])) * 3600 * MS) + ((int(time_m2[1]) - int(time_m[1])) * 60 * MS) + ((int(time_m2[2]) - int(time_m[2])) * MS) + ((int(time_m2[3]) - int(time_m[3])))
  64. if dif < 0:
  65. print 'gamhthhke'
  66. #out_str += str(dif)# + '\n'
  67. #print out_str
  68. write_line= str(dif) + '\n'
  69. fd_w.write(write_line)
  70. fd_w.close()
  71. fd_r.close()
  72. #print '\n'
  73. #write_line = str(mean_idag) + '\n' + str(mean_init) + '\n' + str(mean_agent) + '\n'
  74. #fd_w.write(write_line)
  75. #fd_w.close()
  76. fd_app.close()