Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multi-analyzer support for MLPerf power, SPEC PTD version updated to 1.11.1 #623

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions script/get-spec-ptd/customize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from cmind import utils
import os
import shutil
import stat


def preprocess(i):
Expand All @@ -19,9 +20,19 @@ def postprocess(i):
binary_name = "ptd-windows-x86.exe"
else:
binary_name = "ptd-linux-x86"
if 'CM_MLPERF_PTD_PATH' not in env:
if env.get('CM_MLPERF_PTD_PATH', '') == '':
env['CM_MLPERF_PTD_PATH'] = os.path.join(
env['CM_MLPERF_POWER_SOURCE'], 'inference_v1.0', binary_name)
env['CM_MLPERF_POWER_SOURCE'], 'PTD', 'binaries', binary_name)

file_path = env['CM_MLPERF_PTD_PATH']
current_permissions = os.stat(file_path).st_mode

# Check if the file already has execute permissions
if not (current_permissions & stat.S_IXUSR): # Check user execute permission
# Add execute permissions for the user
os.chmod(file_path, current_permissions | stat.S_IXUSR)


env['CM_SPEC_PTD_PATH'] = env['CM_MLPERF_PTD_PATH']

return {'return': 0}
53 changes: 44 additions & 9 deletions script/run-mlperf-power-server/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,56 @@ def preprocess(i):

os_info = i['os_info']
env = i['env']


# Initialize ConfigParser
config = configparser.ConfigParser()

# Define the server config file path
server_config_file = os.path.join(
env['CM_MLPERF_POWER_SOURCE'],
env.get('CM_MLPERF_POWER_SOURCE', ''),
'ptd_client_server',
'server.template.conf')
'server.template.conf'
)

# Read the configuration file with error handling
if not os.path.exists(server_config_file):
raise FileNotFoundError(f"Server config file not found: {server_config_file}")

config.read(server_config_file)
config['server']['ntpServer'] = env['CM_MLPERF_POWER_NTP_SERVER']
config['server']['listen'] = env['CM_MLPERF_POWER_SERVER_ADDRESS'] + \
" " + env['CM_MLPERF_POWER_SERVER_PORT']
config['ptd']['ptd'] = env['CM_MLPERF_PTD_PATH']
config['ptd']['interfaceFlag'] = env['CM_MLPERF_POWER_INTERFACE_FLAG']
config['ptd']['deviceType'] = env['CM_MLPERF_POWER_DEVICE_TYPE']
config['ptd']['devicePort'] = env['CM_MLPERF_POWER_DEVICE_PORT']
# Update the server section
try:
config['server']['ntpServer'] = env['CM_MLPERF_POWER_NTP_SERVER']
config['server']['listen'] = f"{env['CM_MLPERF_POWER_SERVER_ADDRESS']} {env['CM_MLPERF_POWER_SERVER_PORT']}"
except KeyError as e:
raise KeyError(f"Missing required environment variable: {e}")

# Define number of analyzers and network port start
num_analyzers = int(env.get('CM_MLPERF_POWER_NUM_ANALYZERS', 1))
network_port_start = int(env.get('CM_MLPERF_POWER_NETWORK_PORT_START', 8888))

# Ensure 'ptd' section exists
if 'ptd' in config:
config.remove_section('ptd')

config.add_section('ptd')
config['ptd']['ptd'] = str(env.get('CM_MLPERF_PTD_PATH', ''))

# Add analyzers to the configuration
for aid in range(1, num_analyzers + 1):
analyzer_section = f'analyzer{aid}'
if analyzer_section not in config:
config.add_section(analyzer_section)

# Add the analyzer subsection as keys under the 'ptd' section
config[f'{analyzer_section}']['interfaceFlag'] = str(env.get('CM_MLPERF_POWER_INTERFACE_FLAG', ''))
config[f'{analyzer_section}']['deviceType'] = str(env.get('CM_MLPERF_POWER_DEVICE_TYPE', ''))
config[f'{analyzer_section}']['devicePort'] = str(env.get('CM_MLPERF_POWER_DEVICE_PORT', ''))
config[f'{analyzer_section}']['networkPort'] = str(network_port_start + aid - 1)

with open('power-server.conf', 'w') as configfile:
config.write(configfile)

print({section: dict(config[section]) for section in config.sections()})

if env['CM_HOST_OS_TYPE'] == "windows":
Expand Down
Loading