Skip to content

Commit 6c339ea

Browse files
author
Krzysztof Parzyszek
authored
[Hexagon] Remove sim_options from tvm.target.hexagon() (#11293)
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.
1 parent 80d8270 commit 6c339ea

File tree

1 file changed

+5
-72
lines changed

1 file changed

+5
-72
lines changed

python/tvm/target/target.py

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717
"""Target data structure."""
1818
import json
19-
import os
2019
import re
2120
import warnings
2221

@@ -586,11 +585,6 @@ def hexagon(cpu_ver="v66", **kwargs):
586585
-----------------------------
587586
hvx : int (default: 128)
588587
Size of HVX vector in bytes. Value of 0 disables HVX codegen.
589-
sim_options : str or list of str (default: None)
590-
User defined sim arguments. CPU version defaults to cpu_ver.
591-
Otherwise, separate versions are used for codegen and sim. Not
592-
all allowed cpu strings will be valid, simulator will throw an
593-
error if invalid. Does not affect codegen.
594588
llvm_options : str or list of str (default: None)
595589
User defined compiler arguments.
596590
use_qfloat : bool (default: True for cpu_ver >= v68, False otherwise)
@@ -629,7 +623,6 @@ def get_arch_version(cpu_ver):
629623
arch_version = get_arch_version(cpu_ver)
630624
config = {
631625
"hvx": 128,
632-
"sim_options": None,
633626
"llvm_options": None,
634627
"use_qfloat": arch_version >= 68,
635628
"use_ieee_fp": False,
@@ -638,10 +631,12 @@ def get_arch_version(cpu_ver):
638631
config.update(kwargs)
639632

640633
# Warn about obsolete parameter names.
641-
if config.get("sim_args"):
642-
msg = "The keyword parameter 'sim_args' is deprecated, use 'sim_options' instead"
634+
if config.get("sim_args") or config.get("sim_options"):
635+
msg = (
636+
"Setting simulator options in target is deprecated, set environment variable "
637+
"HEXAGON_SIM_ARGS instead"
638+
)
643639
warnings.warn(msg, stacklevel=2)
644-
config.update({"sim_options": config["sim_args"]})
645640
if config.get("llvm_args"):
646641
msg = "The keyword parameter 'llvm_args' is deprecated, use 'llvm_options' instead"
647642
warnings.warn(msg, stacklevel=2)
@@ -678,65 +673,6 @@ def create_target_features(config):
678673

679674
return target + mcpu + " " + create_target_features(config)
680675

681-
# Simulator options string
682-
def create_sim_options(cpu_ver, config):
683-
"""Create simulator option string."""
684-
685-
def validate_hvx_length(codegen_hvx, sim_options):
686-
if sim_options and "--hvx_length" in sim_options:
687-
# If --hvx_length was specified, check HVX length of sim
688-
# vs codegen
689-
i = sim_options.index("hvx_length") + len("hvx_length") + 1
690-
sim_hvx = sim_options[i : i + 3]
691-
if sim_hvx != str(codegen_hvx):
692-
msg = "sim hvx {} and codegen hvx {} mismatch!".format(sim_hvx, codegen_hvx)
693-
# Set the stacklevel to the tvm.target.hexagon() call.
694-
warnings.warn(msg, stacklevel=4)
695-
elif codegen_hvx != 0:
696-
# If --hvx_length was not given, add it if HVX is enabled
697-
sim_options = sim_options + " " if isinstance(sim_options, str) else ""
698-
sim_options += "--hvx_length " + str(codegen_hvx)
699-
return sim_options or ""
700-
701-
hvx = config["hvx"]
702-
sim_options = config["sim_options"]
703-
if not sim_options:
704-
return cpu_ver + " " + validate_hvx_length(hvx, sim_options)
705-
706-
sim_cpu = cpu_ver + " "
707-
708-
# Add user defined args
709-
if isinstance(sim_options, list):
710-
sim_options = " ".join(sim_options)
711-
712-
# Check for supplied sim cpu version
713-
if "v6" in sim_options:
714-
sim_cpu = ""
715-
716-
# Regex match for allowed cpus
717-
valid_cpu_str_regex = (
718-
r"(?P<pre>--.*\s)?(--m)?"
719-
+ r"(?P<base_version>v6[25678])(?P<sub_version>[a-z])?"
720-
+ r"(?P<l2_size>_[0-9]+)?(?P<rev>_rev[0-9])?\s?(?P<post>--.*)?"
721-
)
722-
m = re.match(valid_cpu_str_regex, sim_options.lower())
723-
if not m:
724-
raise ValueError('Invalid simulator argument string "{}"'.format(sim_options))
725-
726-
# Parse options into correct order
727-
cpu_attr = {x: str(m.groupdict()[x] or "") for x in m.groupdict()}
728-
sim_options = (
729-
cpu_attr["base_version"]
730-
+ cpu_attr["sub_version"]
731-
+ cpu_attr["l2_size"]
732-
+ cpu_attr["rev"]
733-
+ " "
734-
+ cpu_attr["pre"]
735-
+ cpu_attr["post"]
736-
)
737-
738-
return sim_cpu + " " + validate_hvx_length(hvx, sim_options)
739-
740676
# LLVM options string
741677
def create_llvm_options(cpu_ver, config): # pylint: disable=unused-argument
742678
"""Create LLVM options string."""
@@ -764,9 +700,6 @@ def create_tvm_options(cpu_ver, config): # pylint: disable=unused-argument
764700
opts += " --" + features[k] + "=" + str(config[k])
765701
return opts
766702

767-
# Sim args
768-
os.environ["HEXAGON_SIM_ARGS"] = create_sim_options(cpu_ver, config)
769-
770703
target_str = create_llvm_target(cpu_ver, config)
771704
llvm_str = create_llvm_options(cpu_ver, config)
772705
tvm_str = create_tvm_options(cpu_ver, config)

0 commit comments

Comments
 (0)