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

Add --deprecate option for proxy ports and interfaces #209

Conversation

mandolaerik
Copy link
Contributor

  • Shut up linter
  • Remove the --illegal-attrs flag
  • Remove --illegal-attrs flag
  • Remove --version, which was ignored
  • Migrate from optparse to argparse
  • Rename function
  • Refactor: Re-use common function
  • Factor out params for API version ranges
  • Add option for listing all warning tags
  • Add --deprecate=PORT_PROXY_IFACES
  • Add PORT_PROXY_ATTRS deprecation

@mandolaerik
Copy link
Contributor Author

See also #208 where I extracted the uncontroversial parts, and #205 which presents an alternative approach.

@mandolaerik
Copy link
Contributor Author

TODO:

  • extract documentation
  • convert --strict to deprecations
  • releasenote

Comment on lines 547 to 550
#if (!_DEPRECATE_PORT_PROXY_IFACES && !_api_6_or_older) {
error "The PORT_PROXY_IFACES feature can only be enabled"
+ " with API=6 or older";
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about this part -- explicit guards in DML code is one of the things that I liked with #205; it makes the logic easy to explore and understand; however, I don't think this error statement is reachable (there is no flag to disable deprecations, and the default setting doesn't trigger the error). So this code just serves as (statically) executable documentation; it validates that the feature is indeed deprecated in APIs newer than 6. Unfortunately it doesn't validate a tight bound; the #if would not happen if 6 was the first deprecated version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remember my --compat rant, I think we one day may trip into the situation where we will need to offer an option to revert a particular deprecation/semantic change. But those will be very particular situations, and the deprecation of proxy ports and interfaces certainly isn't one of them.
My opinion is that this only makes sense if we eventually plan to introduce a general --compat flag (as opposed to ad-hoc flags where we are selective about what kind of changes that users can turn off) -- I'm not particularly fond of a general --compat option, and I'm guessing you are even less so.
If we won't have a general --compat flag), there's no point to this. Why bother with executable documentation if you can just put a comment (here, or elsewhere?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have a generic compat flag, namely --simics-api.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... where the meaning of --simics-api=7 is sealed the day 7 is released.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "general" in this context I mean "granular and at will", e.g. --compat=PORT_PROXY_IFACES, like the opposite of --deprecate/--no-compat.

Copy link
Contributor

@lwaern-intel lwaern-intel Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And by "ad-hoc" I mean if we ever make a change that we discover "oops, people have legit reasons to want to reverse this change and keep using modern Simics, but we still want the reversal of the change to be 'opt-in' and lock out your model from certain features if necessary as to not shackle future development of DMLC" then instead of adding a full-fledged --compat we instead let people say --enable-deprecated-[feature name]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, we can later choose to allow opting out from certain deprecations in API versions where they are enabled by default. If the need should arise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed; and the gist of my argument is that seeing how we're very unlikely to want --compat in favor of ad-hoc compatibility flags, I don't think we want this executable documentaiton, especially if it incurs an unneeded auto param (unless we do want people to access it, but then it shouldn't be _ prefixed`.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the auto params are nice to have; in particular, good for workarounds in common code. The reason for the _ prefix is that they will be removed when they are obsolete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests for 1.2. This is on purpose, the 1.2-specific code is just that auto params are declared, and if they wouldn't exist, then a minimal 1.2 file would fail.

@syssimics
Copy link
Contributor

Verification #12227482: fail

py/dml/deprecations.py Outdated Show resolved Hide resolved
error "The PORT_PROXY_IFACES feature can only be enabled"
+ " with API=6 or older";
}
param _DEPRECATE_PORT_PROXY_ATTRS auto;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming scheme can be debated -- we don't use UPPER_SNAKE_CASE for other params, the uppercase is inherited from the command-line tags, which are uppercase for consistency with warning and error tags. I'm not sure that consistency is important; we could just lowercase deprecation tags. We could also mix-case, as in _deprecate_PORT_PROXY_ATTRS. Or just keep it uppercase; there is uncontroversial widespread use of uppercase param names, in particular for simulation-related constants or array size parameters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My vote is mixed case, but I agree that whatever choice we pick is likely to be uncontroversial.

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from d2688d9 to 631713b Compare September 22, 2023 10:37
@syssimics
Copy link
Contributor

Verification #12228488: pass

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 631713b to 37be595 Compare September 22, 2023 12:38
@syssimics
Copy link
Contributor

Verification #12229149: pass

@mandolaerik
Copy link
Contributor Author

Added first draft of documentation. Need to discuss terminology in more detail.

@syssimics
Copy link
Contributor

Verification #12231545: fail

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 05db6c6 to 78879d4 Compare September 22, 2023 19:54
@syssimics
Copy link
Contributor

Verification #12231565: pass

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 78879d4 to 769139e Compare September 24, 2023 15:18
@syssimics
Copy link
Contributor

Verification #12236973: fail

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 769139e to 4018e59 Compare September 24, 2023 16:32
@syssimics
Copy link
Contributor

Verification #12236979: pass

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch 2 times, most recently from be9c393 to a4143e1 Compare September 26, 2023 17:03
@mandolaerik
Copy link
Contributor Author

The conversion of some dml12 features into compat tags also requires that the tests for these are rewritten with /// DMLC-FLAG --no-compat=xyz and/or /// DMLC-FLAG --simics-api=6

@syssimics
Copy link
Contributor

Verification #12250481: pass

@mandolaerik
Copy link
Contributor Author

Also, one non-apparent change in this PR is that the dml12_* compat features are now disabled in 7; this can possibly cause issues in our builds of 7. Need to do some test build. If there are problems, we can bump last_api_version of problematic features to 7 within this PR, and update models in separate PRs.

@syssimics
Copy link
Contributor

Verification #12253365: fail

Copy link
Contributor

@lwaern-intel lwaern-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quite like this. Some changes needed though.

doc/1.4/deprecations-header.md Outdated Show resolved Hide resolved
DMLC provides a command-line flag `--api-version` to specify the API version to
be used for a model. When building with the standard Simics build system, this is controlled by the `SIMICS_API_VERSION` variable in `make`, or the `SIMICS_API`/`MODULE_SIMICS_API` variable in `CMake`.

DMLC also provides the <code>--no-compat=_tag_</code> flag, which disables the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, <code>the last word is _italicized_</code> works? Huh. In the ref manual we use <tt>the last work is <em>italicized</em></tt>. We should pick one for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree: I will not remember style at this level of detail so it will cost more than it gives. I can see two cases where markdown style matters:

  • we need to avoid markdown that relyies on corners that have non-local effect, such as an unescaped _underscore that works fine as long as no other underscore appears later in the same paragraph.
  • it's nice to ban other inconsistencies as long we can run a linter to enforce the rule.

lib/1.2/dml-builtins.dml Show resolved Hide resolved
py/dml/compat.py Outdated Show resolved Hide resolved
py/dml/compat.py Outdated Show resolved Hide resolved
py/dml/structure.py Show resolved Hide resolved
@@ -58,14 +60,13 @@
# types.TypeSequence -> codegen.TypeSequenceInfo
type_sequence_infos = {}

# 1.4 style integer operations in 1.2, --strict-dml12-int
strict_int_flag = None
enabled_compat = set()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set() vs. Set()? It certainly won't affect generated C, but may affect, say, if we want to ever print out what compatibility tags that are enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should print sorted(enabled_compat)

test/1.4/legacy/port_proxy_attrs.dml Outdated Show resolved Hide resolved
test/1.2/syntax/T_int.dml Show resolved Hide resolved
py/dml/dmlc.py Outdated Show resolved Hide resolved
@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 2e3573e to 9972dd0 Compare September 27, 2023 11:45
@syssimics
Copy link
Contributor

Verification #12254809: fail

@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 9972dd0 to 5dbb5b4 Compare September 27, 2023 14:18
This is nice because it allows comparisons like "simics_api < 7" to work
also in Simics 10.

We use the integer 4 to represent the API "4.8"
This also included some renames and change in polarities; in particular,
all deprecated features are now disabled by default, as required by some
unit tests.
Also flatten the compat.features dict and use string-only API
representation in env.py
Triggered by `VPOP + VPOP` when compiling with --no-compat=dml12_int,
or by 1.2/errors/EAPPLY when enabling --no-compat=dml12_int,dml12_misc
Passing --no-compat=dml12_misc triggers this in many tests.
@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 8aed632 to 2b06464 Compare October 10, 2023 14:31
@syssimics
Copy link
Contributor

Verification #12324952: fail

Deprecating requires updating lots of tests and components; better to push
that to a separate PR.
@mandolaerik mandolaerik force-pushed the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch from 2b06464 to 0019327 Compare October 10, 2023 15:54
@syssimics
Copy link
Contributor

Verification #12325435: pass

@syssimics
Copy link
Contributor

Verification #12325946: fail

Copy link
Contributor

@lwaern-intel lwaern-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Though I still don't like the _compat_ prefix of the autoparams.

# code from 1.2 with --no-compat=dml12_misc
dml.globals.dml_version != (1, 2)
or p.site.dml_version == (1, 2)
or p.site != sym.site):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OW
By the way, should we have some standard way to annotate hacks and todos? I've always used # HACK: and # TODO: because my editor highlights them.

if version != (1, 2):
for feature in [compat.dml12_inline, compat.dml12_not,
compat.dml12_misc]:
dml.globals.enabled_compat.discard(feature)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird this is done separately from all other compatibility enablement logic. Though we want to do such logic as early as possible, and we have no choice to place this part of it right here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and I notice that I forgot dml12_goto there! By sheer luck, this is not a problem since goto is forbidden by the grammar.

@syssimics
Copy link
Contributor

Verification #12330620: pass

@mandolaerik mandolaerik merged commit f81232c into intel:main Oct 11, 2023
1 check passed
@mandolaerik mandolaerik deleted the pr/add-deprecate-option-for-proxy-ports-and-interfaces branch October 11, 2023 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants