Skip to content

Commit 3f244e3

Browse files
committed
style updates and improved MbConst init
1 parent 99dea77 commit 3f244e3

2 files changed

Lines changed: 65 additions & 55 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
files for each job run. A run name can be specified with the *--run_name* command line option. This
4545
name will be included in the name of the testData subdirectory for the current run.
4646

47-
## New on Master Branch - v2.0.0-Beta - Release Candidate
48-
* Complete rewrite of the core to integrate GPU_ITEM object that was previously only used in energy mode.
47+
## New on Master Branch - v2.0.0-RC2 - Release Candidate
48+
* Complete rewrite of the core to integrate GpuItem object that was previously only used in energy mode.
4949
* Implemented a more robust check of compute and energy compatibility for all installed GPUs. Switched from lshw to
5050
lspci and clinfo. Not working for [Intel GPUs](https://github.com/Ricks-Lab/benchMT/issues/6).
5151
* Many core improvements for better robustness and style. Added reST docstrings for better supportability

benchMT

Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ __copyright__ = 'Copyright (C) 2018 RueiKe'
6161
__credits__ = ['Keith Myers - Testing and Verification']
6262
__license__ = 'GNU General Public License'
6363
__program_name__ = 'benchMT'
64-
__version__ = 'v2.0.0'
64+
__version__ = 'v2.0.0-RC2'
6565
__maintainer__ = 'RueiKe'
6666
__status__ = 'Release Candidate'
6767
__docformat__ = 'reStructuredText'
@@ -80,13 +80,17 @@ from uuid import uuid4
8080
import glob
8181
import shutil
8282
from pathlib import Path
83-
from typing import Union
83+
#from typing import Union
8484

8585

86+
# pylint: disable=multiple-statements
87+
# pylint: disable=line-too-long
88+
8689
class ObjDict(dict):
8790
"""
8891
Allow access of dictionary keys by key name.
8992
"""
93+
# pylint: disable=attribute-defined-outside-init
9094
def __getattr__(self, name):
9195
if name in self:
9296
return self[name]
@@ -107,6 +111,44 @@ class MbConst(ObjDict):
107111
"""
108112
Defines benchMT constants used through out the code.
109113
"""
114+
# pylint: disable=too-many-instance-attributes
115+
def __init__(self):
116+
super().__init__({'boinc_home': '/home/boinc/BOINC/',
117+
'cpu_app_subdir': 'APPS_CPU/',
118+
'gpu_app_subdir': 'APPS_GPU/',
119+
'ref_app_subdir': 'APPS_REF/',
120+
'ref_results_subdir': 'REF_RESULTS/',
121+
'wu_subdir': 'WU_test/',
122+
'std_signal_subdir': 'WU_std_signal/',
123+
'testdata_subdir': 'testData/',
124+
'workdir_subdir': 'workdir/',
125+
'slots_subdir': 'Slots/',
126+
'command_line_filename': 'BenchCFG',
127+
'boinccmd': 'boinccmd',
128+
'template_file': 'init_data.xml.template',
129+
'coproc_file_name': 'coproc_info.xml',
130+
'wu_cmp': 'rescmpv5_l',
131+
'suspend_args': ['boinccmd --set_gpu_mode never 172800',
132+
'boinccmd --set_run_mode never 172800'],
133+
'resume_args': ['boinccmd --set_gpu_mode never 1',
134+
'boinccmd --set_run_mode never 1'],
135+
'activeWU': 'work_unit.sah',
136+
'activeAPWU': 'in.dat',
137+
'DEBUG': False,
138+
'noBS': False,
139+
'env': None,
140+
# Items required for Energy feature
141+
'card_root': '/sys/class/drm/',
142+
'hwmon_sub': 'hwmon/hwmon',
143+
# System command definitions
144+
'cmd_lspci': None,
145+
'cmd_lshw': None,
146+
'cmd_lscpu': None,
147+
'cmd_clinfo': None,
148+
'cmd_time': None,
149+
'cmd_lsb_release': None,
150+
'cmd_nvidia_smi': None})
151+
110152
def __repr__(self):
111153
return '{} - {} items'.format(self.__class__.__name__, len(self))
112154

@@ -132,39 +174,6 @@ class MbConst(ObjDict):
132174

133175

134176
MB_CONST = MbConst()
135-
MB_CONST.update({'boinc_home': '/home/boinc/BOINC/',
136-
'cpu_app_subdir': 'APPS_CPU/',
137-
'gpu_app_subdir': 'APPS_GPU/',
138-
'ref_app_subdir': 'APPS_REF/',
139-
'ref_results_subdir': 'REF_RESULTS/',
140-
'wu_subdir': 'WU_test/',
141-
'std_signal_subdir': 'WU_std_signal/',
142-
'testdata_subdir': 'testData/',
143-
'workdir_subdir': 'workdir/',
144-
'slots_subdir': 'Slots/',
145-
'command_line_filename': 'BenchCFG',
146-
'boinccmd': 'boinccmd',
147-
'template_file': 'init_data.xml.template',
148-
'coproc_file_name': 'coproc_info.xml',
149-
'wu_cmp': 'rescmpv5_l',
150-
'suspend_args': ['boinccmd --set_gpu_mode never 172800', 'boinccmd --set_run_mode never 172800'],
151-
'resume_args': ['boinccmd --set_gpu_mode never 1', 'boinccmd --set_run_mode never 1'],
152-
'activeWU': 'work_unit.sah',
153-
'activeAPWU': 'in.dat',
154-
'DEBUG': False,
155-
'noBS': False,
156-
'env': None,
157-
# Items required for Energy feature
158-
'card_root': '/sys/class/drm/',
159-
'hwmon_sub': 'hwmon/hwmon',
160-
# System command definitions
161-
'cmd_lspci': None,
162-
'cmd_lshw': None,
163-
'cmd_lscpu': None,
164-
'cmd_clinfo': None,
165-
'cmd_time': None,
166-
'cmd_lsb_release': None,
167-
'cmd_nvidia_smi': None})
168177

169178

170179
class CfgModes:
@@ -874,6 +883,8 @@ class BenchEnv:
874883
print(v.format(appmode), file=fileptr)
875884
elif k == 'benchMT_version':
876885
print(v.format(__version__), file=fileptr)
886+
elif k == 'run_name' and not self.prm.run_name:
887+
continue
877888
elif k == 'gpu_details':
878889
print('GPU Details:', file=fileptr)
879890
for gpi in self.prm.gpu_details:
@@ -1738,24 +1749,23 @@ class JobList:
17381749
i = 0
17391750
num_jobs = self.jobcount_bystatus()
17401751
if title == '':
1741-
print('\n ' + str(num_jobs['COMPLETE']) + ' of ' + str(num_jobs['TOTAL']) +
1742-
' jobs complete\n', file=fileptr)
1752+
print('\n {} of {} jobs complete.\n'.format(num_jobs['COMPLETE'], num_jobs['TOTAL']), file=fileptr)
17431753
else:
1744-
print('\n ' + title)
1754+
print('\n {}'.format(title))
17451755
print('┌─'.ljust(5, '─'), '─'.ljust(4, '─'), '─'.ljust(3, '─'), '─'.ljust(60, '─'),
17461756
'─'.ljust(8, '─'), '─'.ljust(8, '─'), '─'.ljust(11, '─'),
17471757
'─'.ljust(8, '─') + '┐', file=fileptr, sep='┬')
17481758

17491759
if fileptr == sys.stdout:
1750-
print('│' + '\x1b[1;36m' + 'Job#'.ljust(4, ' ') + '\x1b[0m',
1760+
print('│\x1b[1;36m' + 'Job#'.ljust(4, ' ') + '\x1b[0m',
17511761
'\x1b[1;36m' + 'Slot'.ljust(4, ' ') + '\x1b[0m',
17521762
'\x1b[1;36m' + 'xPU'.ljust(3, ' ') + '\x1b[0m',
17531763
'\x1b[1;36m' + 'app_name'.ljust(60, ' ') + '\x1b[0m',
17541764
'\x1b[1;36m' + ' start'.ljust(8, ' ') + '\x1b[0m',
17551765
'\x1b[1;36m' + ' finish'.ljust(8, ' ') + '\x1b[0m',
17561766
'\x1b[1;36m' + 'tot_time'.ljust(11, ' ') + '\x1b[0m',
17571767
'\x1b[1;36m' + ' state'.ljust(8, ' ') + '\x1b[0m' + '│', file=fileptr, sep='│')
1758-
print('│' + '\x1b[1;36m' + ' '.ljust(4, ' ') + '\x1b[0m',
1768+
print('│\x1b[1;36m' + ' '.ljust(4, ' ') + '\x1b[0m',
17591769
'\x1b[1;36m' + ' '.ljust(4, ' ') + '\x1b[0m',
17601770
'\x1b[1;36m' + ' '.ljust(3, ' ') + '\x1b[0m',
17611771
'\x1b[1;36m' + 'app_args'.ljust(60, ' ') + '\x1b[0m',
@@ -2045,7 +2055,7 @@ class JobList:
20452055
elif time_item[0] == 'MajPF':
20462056
v.time_majpf = time_item[1]
20472057

2048-
# find ref-result file
2058+
# Find ref-result file
20492059
file_srch = glob.glob(os.path.join(env.prm.ref_results_path,
20502060
'ref-result.*.{}.sah'.format(v.wu_name)))
20512061
if file_srch:
@@ -2054,7 +2064,7 @@ class JobList:
20542064
ref_result_file = ''
20552065
v.error = v.error + '[Can not open ref-result file]'
20562066

2057-
# copy result and stderr files to testData
2067+
# Copy result and stderr files to testData
20582068
cur_result_file = os.path.join(env.prm.summary_path,
20592069
'result.{}.{}.{}.sah'.format(v.app_name, v.wu_name, v.uuid))
20602070
cur_stderr_file = os.path.join(env.prm.summary_path,
@@ -2063,12 +2073,12 @@ class JobList:
20632073
ap_result_file = os.path.join(v.slot_dir, 'work_unit.sah')
20642074
stderr_file = os.path.join(v.slot_dir, 'stderr.txt')
20652075
if os.path.isfile(mb_result_file):
2066-
# copy over MB data
2076+
# Copy over MB data
20672077
shutil.copy2(mb_result_file, cur_result_file)
20682078
os.remove(mb_result_file)
20692079
if MB_CONST.DEBUG: print('Copy2: {} to {}'.format(mb_result_file, cur_result_file))
20702080
elif os.path.isfile(ap_result_file):
2071-
# copy over astropulse data
2081+
# Copy over astropulse data
20722082
shutil.copy2(ap_result_file, cur_result_file)
20732083
os.remove(ap_result_file)
20742084
if MB_CONST.DEBUG: print('Copy2: {} to {}'.format(ap_result_file, cur_result_file))
@@ -2129,7 +2139,7 @@ class JobList:
21292139
print('Fatal Error: {} in reading results.'.format(except_err))
21302140
print(' Are you running AP benchmarks and not in astropulse mode?')
21312141

2132-
# write to run log
2142+
# Write to run log
21332143
print('App Name: {}'.format(v.app_name), file=env.sum_file_ptr)
21342144
print('App Args: {}'.format(v.app_args), file=env.sum_file_ptr)
21352145
print('WU Name: {}'.format(v.wu_name), file=env.sum_file_ptr)
@@ -2157,7 +2167,7 @@ class JobList:
21572167
print('', file=env.sum_file_ptr)
21582168

21592169
if ref_result_file != '' and not env.prm.mode_astropulse:
2160-
# compare results to reference
2170+
# Compare results to reference
21612171
v.similarity = 'Unknown'
21622172
v.q_value = 'Unknown'
21632173
command_str = '{} {} {} 2>/dev/null'.format(env.prm.wucmpcmd,
@@ -2191,7 +2201,7 @@ class JobList:
21912201
print('', file=env.sum_file_ptr)
21922202
else:
21932203
print('ERROR: can not open results file: {}'.format(cur_result_file))
2194-
# write to run log
2204+
# Write to run log
21952205
print('ERROR: can not open results file: {}'.format(cur_result_file,
21962206
file=env.sum_file_ptr))
21972207
print('App Name: {}'.format(v.app_name), file=env.sum_file_ptr)
@@ -2303,7 +2313,7 @@ class SlotsList:
23032313
print('Failed to make Slots directory [{}]'.format(env.prm.slots_path))
23042314
return False
23052315
if num_gpu_slots > 0:
2306-
# copy .cl files to workdir
2316+
# Copy .cl files to workdir
23072317
for cl_files in glob.glob(os.path.join(env.prm.gpu_app_path, '*.cl')):
23082318
shutil.copy2(cl_files, env.prm.workdir_path)
23092319
gpu_device_index = 0
@@ -2314,7 +2324,7 @@ class SlotsList:
23142324
print('Failed to make Slots directory [{}]'.format(v.slot_dir))
23152325
return False
23162326

2317-
# copy init_data.xml from template to slot
2327+
# Copy init_data.xml from template to slot
23182328
if not os.path.isfile(os.path.join(v.slot_dir, 'init_data.xml')):
23192329
shutil.copy2(env.prm.init_data_template_file, os.path.join(v.slot_dir, 'init_data.xml'))
23202330
if num_gpu_slots > 0:
@@ -2447,9 +2457,9 @@ class SlotsList:
24472457
job_str = 'None'
24482458
else:
24492459
job_str = v.job.uuid
2450-
print(slotnum_str, '| ', plat_str, '| ', dev_str, '| ', state_str, '| ', job_str, '| ', v.slot_dir, sep='')
2451-
2452-
print('##### ', i, ' total slots')
2460+
print('{}| {}| {}| {}| {}| {}'.format(slotnum_str, plat_str, dev_str,
2461+
state_str, job_str, v.slot_dir), sep='')
2462+
print('##### {} total slots'.format(i))
24532463

24542464
def print_activity(self, joblist, compact_flag=False, fileptr=sys.stdout):
24552465
"""
@@ -2470,7 +2480,7 @@ class SlotsList:
24702480
'─'.ljust(10, '─'), '─'.ljust(10, '─') + '┐', file=fileptr, sep='┬')
24712481

24722482
if fileptr == sys.stdout:
2473-
print('│' + '\x1b[1;36m' + 'Slot'.ljust(4, ' ') + '\x1b[0m',
2483+
print('│\x1b[1;36m' + 'Slot'.ljust(4, ' ') + '\x1b[0m',
24742484
'\x1b[1;36m' + 'xPU'.ljust(3, ' ') + '\x1b[0m',
24752485
'\x1b[1;36m' + 'DEV'.ljust(3, ' ') + '\x1b[0m',
24762486
'\x1b[1;36m' + 'app_name'.ljust(40, ' ') + '\x1b[0m',

0 commit comments

Comments
 (0)