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

Introduce -N switch to not use hidden implications #2246

Merged
merged 1 commit into from
Jun 5, 2018

Conversation

frankluebeck
Copy link
Member

If GAP is normally called then this patch only causes

  • that the kernel list HIDDEN_IMPS is visible from GAP level
  • that two debugging functions are available
    • WriteFilterRanks(filename);
    • WriteMethodOverview(filename);

Furthermore a command line switch -N is introduced. When gap is called with
this -N then:

  • no hidden implications are installed anymore
  • RankFilter only uses proper implications
  • InstallMethod uses only proper implication during its check if
    the installation fits to one declaration. When it does not find
    an appropriate declaration then it does not run into an error but only
    prints a line of useful information. (This allows to systematically
    either add explicit filter implications or change the filters in some
    method installations until these messages disappear.)

This patch should be safe to be merged into master. Actual changes in
filter implications will be provided in separate patches.

@frankluebeck
Copy link
Member Author

This could also be interesting in the context of pull request #2222.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

I did not yet have a chance to look at this closer, but I really like the general direction!

lib/oper1.g Outdated
Error("the number of arguments does not match a declaration of ",
NAME_FUNC(opr) );
else
Print("IM: the number of arguments does not ",
Copy link
Member

Choose a reason for hiding this comment

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

Why "IM: "?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps "IM" is meant to be a shorthand for InstallMethod?

If one sees this message as a user, it's a bit unclear what it implies. Perhaps this would be better? "Warning, the number of ..."

@ChrisJefferson
Copy link
Contributor

So I had a look at this, it looks fine, the only problem is the same changes need making to HPC-GAP, else (at the moment) this breaks HPC-GAP from starting.

@fingolfin
Copy link
Member

I am also somewhat unhappy about using up a single-letter option for this rather obscure debugging tool. How about instead naming it, --disable-hidden-implications or --no-hidden-imps or so?

@frankluebeck
Copy link
Member Author

@ChrisJefferson: I think it is just not needed that this (hopefully short term) temporary switch works with HPCGAP.

@fingolfin: I chose -N because it was already there (but not used for anything). Since the switch is really only meant for temporary debugging I would prefer to not put more effort in introducing a new switch in all necessary places.

lib/oper1.g Outdated
Error("the number of arguments does not match a declaration of ",
NAME_FUNC(opr) );
else
Print("IM: the number of arguments does not ",
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps "IM" is meant to be a shorthand for InstallMethod?

If one sees this message as a user, it's a bit unclear what it implies. Perhaps this would be better? "Warning, the number of ..."

lib/operdebug.g Outdated
nam := NameFunction(op);
for i in [0..6] do
m := METHODS_OPERATION(op, i);
s := 4+i;
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be changed to s := BASE_SIZE_METHODS_OPER_ENTRY + i;

Copy link
Member

Choose a reason for hiding this comment

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

I also suggest rebasing this PR on master and verifying these functions still work. Ideally, there'd be a test case for them, too, just to make sure we don't break them horribly. Of course one may argue they are just debugging tools; but also debugging tools are more useful if in order to use them you don't first have to track down what caused a regression in them some time in the past ;-).

lib/operdebug.g Outdated
for j in [1..Length(m)/s] do
Print(nam,";\c",i,";",
name(m[j*s-2]),
sline(m[j*s-2]),";\c",
Copy link
Member

Choose a reason for hiding this comment

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

This writes out the location of the definition of the function, if available. It does not yet take advantage of the location of the method installation, which we now also track (see e.g. the code of ApplicableMethodTypes)

@@ -4394,6 +4394,7 @@ static Int InitLibrary (
SET_LEN_PLIST(HIDDEN_IMPS, 0);
WITH_HIDDEN_IMPS_FLAGS_CACHE = NEW_PLIST(T_PLIST, HIDDEN_IMPS_CACHE_LENGTH * 2);
SET_LEN_PLIST(WITH_HIDDEN_IMPS_FLAGS_CACHE, HIDDEN_IMPS_CACHE_LENGTH * 2);
AssGVar(GVarName("HIDDEN_IMPS"), HIDDEN_IMPS);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be able to see the content of HIDDEN_IMPS from GAP level.

InstallHiddenTrueMethod( tofilt, from );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( tofilt, from );
fi;
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be much easier to put the check for the command line option into InstallHiddenTrueMethod? Then one can even keep calling WITH_HIDDEN_IMPS_FLAGS below, as we'd be guaranteed that there are not hidden implications beyond the regular implications, and almost all changes on the library side could be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

The if GAPInfo.CommandLineOptions.N are introduced such that it is easy to find the places where the behaviour is changed by the -N switch.

@frankluebeck
Copy link
Member Author

frankluebeck commented May 29, 2018

The branch is

  • rebased on current master
  • the "IM" in messages is changed to "InstallMethod warning"
  • the utility debug function WriteMethodOverview is adjusted to use the new info on method installation locations
  • added one line comments before the two utility functions
  • also adjusted the hpcgap/src/c_*.c files

@codecov
Copy link

codecov bot commented May 29, 2018

Codecov Report

Merging #2246 into master will decrease coverage by 0.05%.
The diff coverage is 42.39%.

@@            Coverage Diff             @@
##           master    #2246      +/-   ##
==========================================
- Coverage   74.27%   74.21%   -0.06%     
==========================================
  Files         484      485       +1     
  Lines      245343   245597     +254     
==========================================
+ Hits       182225   182280      +55     
- Misses      63118    63317     +199
Impacted Files Coverage Δ
lib/system.g 67.13% <ø> (ø) ⬆️
lib/operdebug.g 0% <0%> (ø)
src/opers.c 94.01% <100%> (ø) ⬆️
lib/oper.g 80.56% <100%> (+0.27%) ⬆️
src/c_oper1.c 88.03% <42.3%> (-2.85%) ⬇️
hpcgap/src/c_oper1.c 85.83% <45.51%> (-2.91%) ⬇️
lib/filter.g 94.01% <87.5%> (-0.58%) ⬇️
hpcgap/lib/hpc/stdtasks.g 63.42% <0%> (-1.28%) ⬇️
src/compiler.c 87.25% <0%> (+0.04%) ⬆️
... and 3 more

If GAP is normally called then this patch only causes
 - that the kernel list HIDDEN_IMPS is visible from GAP level
 - that two debugging functions are available
     - WriteFilterRanks(filename);
     - WriteMethodOverview(filename);

Furthermore a command line switch -N is introduced. When gap is called with
this -N then:
  - no hidden implications are installed anymore
  - RankFilter only uses proper implications
  - InstallMethod uses only proper implication during its check if
    the installation fits to one declaration. When it does not find
    an appropriate declaration then it does not run into an error but only
    prints a line of useful information. (This allows to systematically
    either add explicit filter implications or change the filters in some
    method installations until these messages disappear.)

This patch should be safe to be merged into master. Actual changes in
filter implications will be provided in separate patches.
@fingolfin fingolfin merged commit 954b478 into gap-system:master Jun 5, 2018
@olexandr-konovalov
Copy link
Member

@frankluebeck any reasons why this is not documented in Chapter 3 ?

Perhaps one should check whether there are more cases like this...

@@ -92,7 +92,7 @@ BIND_GLOBAL( "GAPInfo", rec(
rec( short:= "B", default := "", arg := "<name>", help := [ "current architecture"] ),
rec( short:= "D", default := false, help := ["enable/disable debugging the loading of files"] ),
rec( short:= "M", default := false, help := ["disable/enable loading of compiled modules"] ),
rec( short:= "N", default := false, help := ["unused, for backward compatibility only"] ),
rec( short:= "N", default := false, help := ["do not use hidden implications"] ),
Copy link
Member

Choose a reason for hiding this comment

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

@frankluebeck The comment above says "These options must be kept in sync with those in system.c" but that file is not even modified by this PR. Am I missing something?

@frankluebeck
Copy link
Member Author

@alex-konovalov: As discussed above, this -N switch is a temporary change, just for debugging. This should not be documented. Once the "hidden implications" are no longer used we can revert the change in 'system.g' (and simplify the few places where the -N switch is used).

@fingolfin fingolfin added the release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes label Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants