-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_our_executables_triangle_counting.py
84 lines (71 loc) · 3.62 KB
/
run_our_executables_triangle_counting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import socket
import time_out_util
from config import *
from exec_utils import *
def run_exp(env_tag=knl_tag, data_path_tag=exec_path_tag):
with open('config.json') as ifs:
my_config_dict = json.load(ifs)[env_tag]
######################
our_exec_path = my_config_dict[data_path_tag]
data_set_path = my_config_dict[data_set_path_tag]
######################
# our_exec_name_lst = filter(lambda name: 'roaring' in name, my_config_dict[triangle_exec_lst_tag])
# our_exec_name_lst = filter(lambda name: 'roaring' in name, my_config_dict[triangle_exec_lst_tag])
our_exec_name_lst = my_config_dict[triangle_exec_lst_tag]
print 'our exec folder', our_exec_path
print 'our exec name list', our_exec_name_lst
data_set_lst = my_config_dict[data_set_lst_tag]
print data_set_lst
exp_res_root_name = 'exp_results'
folder_name = 'exp-03-25-study-tri-cnt'
reorder_method_lst = ['gro', 'org', 'deg', 'kcore']
# reorder_method_lst = ['org', 'deg', 'kcore']
# reorder_method_lst = ['gro']
def one_round():
for data_set_name in data_set_lst:
for our_algorithm in our_exec_name_lst:
thread_num_lst = my_config_dict[thread_num_lst_tag]
for t_num in thread_num_lst:
for reorder_method in reorder_method_lst:
statistics_dir = os.sep.join(
map(str,
['.',
exp_res_root_name, folder_name, data_set_name, reorder_method, t_num]))
os.system('mkdir -p ' + statistics_dir)
statistics_file_path = statistics_dir + os.sep + our_algorithm + '.txt'
print statistics_file_path
# 1st: write header
os.system(
' '.join(
['echo', my_splitter + time.ctime() + my_splitter, '>>', statistics_file_path]))
# 2nd: run exec cmd
algorithm_path = our_exec_path + os.sep + our_algorithm
params_lst = map(str,
[algorithm_path,
data_set_path + os.sep + data_set_name,
t_num, reorder_method, statistics_file_path, '> /dev/null 2>&1'])
cmd = ' '.join(params_lst)
print 'cmd: ', cmd
time_out = 300
my_env = os.environ.copy()
tle_flag, info, correct_info = time_out_util.run_with_timeout(cmd, timeout_sec=time_out,
env=my_env)
# 3rd: append outputs
write_split(statistics_file_path)
with open(statistics_file_path, 'a+') as ifs:
ifs.write(correct_info)
ifs.write('\nis_time_out:' + str(tle_flag) + '\n')
ifs.write(my_splitter + time.ctime() + my_splitter)
ifs.write('\n\n\n\n')
print 'finish:', cmd
# normal case
one_round()
if __name__ == '__main__':
hostname = socket.gethostname()
if hostname.startswith('lccpu12'):
run_exp(env_tag=lccpu12_tag)
elif hostname.startswith('gpu23'):
run_exp(env_tag=gpu23_tag)
else:
# run_exp(env_tag=knl_tag, data_path_tag=exec_path_tag)
run_exp(env_tag=knl_tag, data_path_tag=exec_path_non_hbw_tag)