From a7cdb751beedcba967b9e5597bf054bc28d617f0 Mon Sep 17 00:00:00 2001 From: "Parzyszek, Krzysztof" Date: Thu, 12 May 2022 13:20:51 -0500 Subject: [PATCH] [Hexagon] Remove sim_options from tvm.target.hexagon() We no longer run simulator automatically, so this is not necessary. Also, the only way to pass options to the simulator was by setting an environment variable. That variable (HEXAGON_SIM_ARGS) should be set independently by the user from now on. --- python/tvm/target/target.py | 77 +++---------------------------------- 1 file changed, 5 insertions(+), 72 deletions(-) diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py index 03115612c5ce..b1dea003fd68 100644 --- a/python/tvm/target/target.py +++ b/python/tvm/target/target.py @@ -16,7 +16,6 @@ # under the License. """Target data structure.""" import json -import os import re import warnings @@ -586,11 +585,6 @@ def hexagon(cpu_ver="v66", **kwargs): ----------------------------- hvx : int (default: 128) Size of HVX vector in bytes. Value of 0 disables HVX codegen. - sim_options : str or list of str (default: None) - User defined sim arguments. CPU version defaults to cpu_ver. - Otherwise, separate versions are used for codegen and sim. Not - all allowed cpu strings will be valid, simulator will throw an - error if invalid. Does not affect codegen. llvm_options : str or list of str (default: None) User defined compiler arguments. use_qfloat : bool (default: True for cpu_ver >= v68, False otherwise) @@ -629,7 +623,6 @@ def get_arch_version(cpu_ver): arch_version = get_arch_version(cpu_ver) config = { "hvx": 128, - "sim_options": None, "llvm_options": None, "use_qfloat": arch_version >= 68, "use_ieee_fp": False, @@ -638,10 +631,12 @@ def get_arch_version(cpu_ver): config.update(kwargs) # Warn about obsolete parameter names. - if config.get("sim_args"): - msg = "The keyword parameter 'sim_args' is deprecated, use 'sim_options' instead" + if config.get("sim_args") or config.get("sim_options"): + msg = ( + "Setting simulator options in target is deprecated, set environment variable " + "HEXAGON_SIM_ARGS instead" + ) warnings.warn(msg, stacklevel=2) - config.update({"sim_options": config["sim_args"]}) if config.get("llvm_args"): msg = "The keyword parameter 'llvm_args' is deprecated, use 'llvm_options' instead" warnings.warn(msg, stacklevel=2) @@ -678,65 +673,6 @@ def create_target_features(config): return target + mcpu + " " + create_target_features(config) - # Simulator options string - def create_sim_options(cpu_ver, config): - """Create simulator option string.""" - - def validate_hvx_length(codegen_hvx, sim_options): - if sim_options and "--hvx_length" in sim_options: - # If --hvx_length was specified, check HVX length of sim - # vs codegen - i = sim_options.index("hvx_length") + len("hvx_length") + 1 - sim_hvx = sim_options[i : i + 3] - if sim_hvx != str(codegen_hvx): - msg = "sim hvx {} and codegen hvx {} mismatch!".format(sim_hvx, codegen_hvx) - # Set the stacklevel to the tvm.target.hexagon() call. - warnings.warn(msg, stacklevel=4) - elif codegen_hvx != 0: - # If --hvx_length was not given, add it if HVX is enabled - sim_options = sim_options + " " if isinstance(sim_options, str) else "" - sim_options += "--hvx_length " + str(codegen_hvx) - return sim_options or "" - - hvx = config["hvx"] - sim_options = config["sim_options"] - if not sim_options: - return cpu_ver + " " + validate_hvx_length(hvx, sim_options) - - sim_cpu = cpu_ver + " " - - # Add user defined args - if isinstance(sim_options, list): - sim_options = " ".join(sim_options) - - # Check for supplied sim cpu version - if "v6" in sim_options: - sim_cpu = "" - - # Regex match for allowed cpus - valid_cpu_str_regex = ( - r"(?P
--.*\s)?(--m)?"
-                + r"(?Pv6[25678])(?P[a-z])?"
-                + r"(?P_[0-9]+)?(?P_rev[0-9])?\s?(?P--.*)?"
-            )
-            m = re.match(valid_cpu_str_regex, sim_options.lower())
-            if not m:
-                raise ValueError('Invalid simulator argument string "{}"'.format(sim_options))
-
-            # Parse options into correct order
-            cpu_attr = {x: str(m.groupdict()[x] or "") for x in m.groupdict()}
-            sim_options = (
-                cpu_attr["base_version"]
-                + cpu_attr["sub_version"]
-                + cpu_attr["l2_size"]
-                + cpu_attr["rev"]
-                + " "
-                + cpu_attr["pre"]
-                + cpu_attr["post"]
-            )
-
-        return sim_cpu + " " + validate_hvx_length(hvx, sim_options)
-
     # LLVM options string
     def create_llvm_options(cpu_ver, config):  # pylint: disable=unused-argument
         """Create LLVM options string."""
@@ -764,9 +700,6 @@ def create_tvm_options(cpu_ver, config):  # pylint: disable=unused-argument
                 opts += " --" + features[k] + "=" + str(config[k])
         return opts
 
-    # Sim args
-    os.environ["HEXAGON_SIM_ARGS"] = create_sim_options(cpu_ver, config)
-
     target_str = create_llvm_target(cpu_ver, config)
     llvm_str = create_llvm_options(cpu_ver, config)
     tvm_str = create_tvm_options(cpu_ver, config)