CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
57 lines
1.9 KiB
Python
Executable File
57 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import json5 as json #json5 supports comments in json files
|
|
import os
|
|
import argparse
|
|
from jinja2 import Environment, PackageLoader
|
|
|
|
env = Environment(loader=PackageLoader("generate_config_defaults"))
|
|
|
|
def load_default_configs_json(in_dir: str) -> dict:
|
|
"""
|
|
Reads the config_defaults.json object for rocRAND's generators,
|
|
converts their name to the corresponding rocrand_rng_type and returns them as dict.
|
|
"""
|
|
|
|
with open(os.path.join(in_dir, "config_defaults.json")) as f:
|
|
json_data = json.load(f)
|
|
|
|
def generator_type(generator_name: str) -> str:
|
|
if 'SOBOL' in generator_name:
|
|
return 'QUASI'
|
|
return 'PSEUDO'
|
|
|
|
def get_rocrand_rng_type(generator_name: str) -> str:
|
|
return "ROCRAND_RNG_" + generator_type(generator_name) + "_" + generator_name
|
|
|
|
default_configs = {}
|
|
for generator_name, configs in json_data.items():
|
|
generator_rocrand_enum = get_rocrand_rng_type(generator_name.upper())
|
|
default_configs[generator_rocrand_enum] = configs
|
|
|
|
return default_configs
|
|
|
|
def generate_config_file(out_dir: str, default_configs: dict) -> None:
|
|
"""
|
|
Generates config_defaults.hpp from the config_defaults.json file.
|
|
"""
|
|
|
|
algorithm_template = env.get_template("config_defaults_template")
|
|
|
|
with open(os.path.join(out_dir, f"config_defaults.hpp"), "w") as text_file:
|
|
text_file.write(algorithm_template.render(configs=default_configs))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
'--in-dir',
|
|
default=os.path.dirname(os.path.realpath(__file__)),
|
|
help="Path to the directory that contains 'config_defaults.json',"
|
|
"usually located in 'scripts/config-tuning/'")
|
|
parser.add_argument('--out-dir', default=".")
|
|
args = parser.parse_args()
|
|
|
|
default_configs = load_default_configs_json(args.in_dir)
|
|
generate_config_file(args.out_dir, default_configs)
|