Skip to content

Commit e38b748

Browse files
author
Daniel Nichols
committed
add build config flag to run all
1 parent 8f93530 commit e38b748

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

drivers/build-configs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"serial": {"CXX": "g++", "CXXFLAGS": "-std=c++17 -O3"},
3+
"omp": {"CXX": "g++", "CXXFLAGS": "-std=c++17 -O3 -fopenmp"},
4+
"mpi": {"CXX": "mpicxx", "CXXFLAGS": "-std=c++17 -O3"},
5+
"mpi+omp": {"CXX": "mpicxx", "CXXFLAGS": "-std=c++17 -O3 -fopenmp"},
6+
"kokkos": {"CXX": "g++", "CXXFLAGS": "-std=c++17 -O3 -fopenmp -I../tpl/kokkos/build/include ../tpl/kokkos/build/lib64/libkokkoscore.a ../tpl/kokkos/build/lib64/libkokkoscontainers.a ../tpl/kokkos/build/lib64/libkokkossimd.a"},
7+
"cuda": {"CXX": "nvcc", "CXXFLAGS": "-std=c++17 --generate-code arch=compute_80,code=sm_80 -O3 -Xcompiler \"-std=c++17 -O3\""},
8+
"hip": {"CXX": "hipcc", "CXXFLAGS": "-std=c++17 -O3 -Xcompiler \"-std=c++17\" -Xcompiler \"-O3\" -Wno-unused-result"}
9+
}

drivers/cpp/cpp_driver_wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class CppDriverWrapper(DriverWrapper):
5757

5858
def __init__(self, **kwargs):
5959
super().__init__(**kwargs)
60+
61+
self.build_configs = self.build_configs or COMPILER_SETTINGS
6062
self.model_driver_file = os.path.join("cpp", "models", DRIVER_MAP[self.parallelism_model])
6163

6264
def write_source(self, content: str, fpath: PathLike) -> bool:
@@ -125,7 +127,7 @@ def test_single_output(self, prompt: str, output: str, test_driver_file: PathLik
125127

126128
# compile and run the output
127129
exec_path = os.path.join(tmpdir, "a.out")
128-
compiler_kwargs = copy.deepcopy(COMPILER_SETTINGS[self.parallelism_model])
130+
compiler_kwargs = copy.deepcopy(self.build_configs[self.parallelism_model])
129131
compiler_kwargs["problem_size"] = problem_size # for kokkos
130132
compiler_kwargs["CXXFLAGS"] += f" -I{tmpdir} -DDRIVER_PROBLEM_SIZE=\"{problem_size}\""
131133
build_result = self.compile(self.model_driver_file, test_driver_file, output_path=exec_path, **compiler_kwargs)

drivers/driver_wrapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def __init__(
167167
self,
168168
parallelism_model: str = "serial",
169169
launch_configs: dict = {"format": "{exec_path} {args}", "params": [{}]},
170+
build_configs: Optional[dict] = None,
170171
problem_sizes: dict = {},
171172
scratch_dir: Optional[PathLike] = None,
172173
build_timeout: int = 20,
@@ -180,6 +181,7 @@ def __init__(
180181
self.validator = VALIDATORS[parallelism_model]
181182
self.scratch_dir = scratch_dir
182183
self.launch_configs = launch_configs[parallelism_model]
184+
self.build_configs = build_configs
183185
self.problem_sizes = problem_sizes
184186
self.build_timeout = build_timeout
185187
self.run_timeout = run_timeout

drivers/run-all.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def get_args():
3232
parser.add_argument("--scratch-dir", type=str, help="If provided, put scratch files here.")
3333
parser.add_argument("--launch-configs", type=str, default="launch-configs.json",
3434
help="config for how to run samples.")
35+
parser.add_argument("--build-configs", type=str, default="build-configs.json",
36+
help="config for how to build samples. If not provided, will use the default build settings for each model.")
3537
parser.add_argument("--problem-sizes", type=str, default="problem-sizes.json",
3638
help="config for how to run samples.")
3739
parser.add_argument("--yes-to-all", action="store_true", help="If provided, automatically answer yes to all prompts.")
@@ -102,6 +104,10 @@ def main():
102104
launch_configs = load_json(args.launch_configs)
103105
logging.info(f"Loaded launch configs from {args.launch_configs}.")
104106

107+
# load build configs
108+
build_configs = load_json(args.build_configs)
109+
logging.info(f"Loaded build configs from {args.build_configs}.")
110+
105111
# load problem sizes
106112
problem_sizes = load_json(args.problem_sizes)
107113
logging.info(f"Loaded problem sizes from {args.problem_sizes}.")
@@ -139,6 +145,7 @@ def main():
139145
prompt,
140146
args.scratch_dir,
141147
launch_configs,
148+
build_configs,
142149
problem_sizes,
143150
args.dry,
144151
display_build_errors=args.log_build_errors,

0 commit comments

Comments
 (0)