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

Convert HPL input generation to use template directive #816

Merged
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
32 changes: 32 additions & 0 deletions var/ramble/repos/builtin/base_applications/hpl/HPL.dat.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
HPLinpack benchmark input file
Innovative Computing Laboratory, University of Tennessee
{output_file} # output file name (if any)
{device_out} # (FORTRAN) device out (6=stdout,7=stderr,file)
{N-Ns} # Number of problem sizes (N)
{Ns} # Problem sizes {used_percent_comment}
{N-NBs} # Number of block sizes (NBs)
{NBs} # Block Sizes
{PMAP} # PMAP process mapping (0=Row-Major, 1=Column-Major)
{N-Grids} # Number of grids, process grids (P * Q)
{Ps} # Ps, Dimension 1 parallelization
{Qs} # Qs, Dimension 2 parallelization
{threshold} # Threshold
{NPFACTs} # Number of PFACTs, panel fact
{PFACTs} # PFACT values (0=Left, 1=Crout, 2=Right)
{N-NBMINs} # Number of NBMINs, recursive stopping criteria
{NBMINs} # NBMINs (>= 1)
{N-NDIVs} # Number of NDIVs, panels in recursion
{NDIVs} # NDIVs
{N-RFACTs} # Number of RFACTs, recursive panel fact.
{RFACTs} # RFACTs (0=Left, 1=Crout, 2=Right)
{N-BCASTs} # Number of BCASTs, broadcast
{BCASTs} # BCASTs (0=1rg,1=1rM,2=2rg,3=2rM,4=Lng,5=LnM,6=MKL BPUSH,7=AMD Hybrid Panel)
{N-DEPTHs} # Number of DEPTHs, lookahead depth
{DEPTHs} # DEPTHs (>=0)
{SWAP} # SWAP (0=bin-exch, 1=long, 2=mix)
{swapping_threshold} # Swapping threshold
{L1} # L1 in (0=transposed, 1=no-transposed) form
{U} # U in (0=transposed, 1=no-transposed) form
{Equilibration} # Equilibration (0=no, 1=yes)
{mem_alignment} # Memory alignment in double (> 0)
##### This line (no. 32) is ignored (it serves as a separator). ######
96 changes: 22 additions & 74 deletions var/ramble/repos/builtin/base_applications/hpl/base_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.

import os
from ramble.appkit import *

import math


def pad_value(val, desc):
return "{:<14}".format(val) + desc


class Hpl(ExecutableApplication):
"""Define a base HPL application."""

Expand Down Expand Up @@ -202,6 +197,20 @@ class Hpl(ExecutableApplication):
workload_group="standard",
)

workload_variable(
"used_percent_comment",
default="",
description="Comment about used percent of memory for workload",
workload_group="standard",
)

workload_variable(
"used_percent_comment",
default="= {percent_mem}% of total available memory",
description="Comment about used percent of memory for workload",
workload_group="calculator",
)

# calculator workload-specific variables:

workload_variable(
Expand Down Expand Up @@ -366,6 +375,13 @@ def _isqrt(self, n):
else:
return hi

register_template(
"hpl_dat",
src_name="HPL.dat.tpl",
dest_name="HPL.dat",
define_var=False,
)

register_phase(
"calculate_values", pipeline="setup", run_before=["make_experiments"]
)
Expand Down Expand Up @@ -441,78 +457,10 @@ def _calculate_values(self, workspace, app_inst):
# If workload is calculator, `calculated_settings` is defined
# If workload is standard, `calculated_settings` is empty
for setting, comment in self.hpl_settings:
pad_comment = ""
if comment is not None:
pad_comment = comment
value = self.expander.expand_var_name(setting)

if setting in calculated_settings:
if "value" in calculated_settings[setting]:
value = calculated_settings[setting]["value"]
if "comment" in calculated_settings[setting]:
pad_comment += (
" " + calculated_settings[setting]["comment"]
)

if "mxp" in self.expander.workload_name:
self.define_variable(setting, value)
else:
self.define_variable(setting, pad_value(value, pad_comment))

def _make_experiments(self, workspace, app_inst=None):
super()._make_experiments(workspace)

input_path = os.path.join(
self.expander.expand_var_name("experiment_run_dir"), "HPL.dat"
)

settings = [
"output_file",
"device_out",
"N-Ns",
"Ns",
"N-NBs",
"NBs",
"PMAP",
"N-Grids",
"Ps",
"Qs",
"threshold",
"NPFACTs",
"PFACTs",
"N-NBMINs",
"NBMINs",
"N-NDIVs",
"NDIVs",
"N-RFACTs",
"RFACTs",
"N-BCASTs",
"BCASTs",
"N-DEPTHs",
"DEPTHs",
"SWAP",
"swapping_threshold",
"L1",
"U",
"Equilibration",
"mem_alignment",
]

with open(input_path, "w+") as f:
f.write(" HPLinpack benchmark input file\n")
f.write(
"Innovative Computing Laboratory, University of Tennessee\n"
)

for setting in settings:
# This gets around an issue in expander where trailing comments
# after '#' are not printed
hash_replace_str = self.expander.expand_var_name(
setting
).replace("Number", "#")
f.write(hash_replace_str + "\n")

# Write some documentation at the bottom of the input file:
f.write(
"##### This line (no. 32) is ignored (it serves as a separator). ######"
)
self.define_variable(setting, value)
Loading