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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 236 additions & 60 deletions hpcgap/src/c_oper1.c

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions lib/filter.g
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ BIND_GLOBAL( "InstallTrueMethodNewFilter", function ( tofilt, from )
fi;
fi;
od;
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.

end );


Expand Down Expand Up @@ -408,15 +410,20 @@ BIND_GLOBAL( "CANONICAL_BASIS_FLAGS", QUO_INT(SUM_FLAGS,5) );
## Compute the rank including the hidden implications.
##
BIND_GLOBAL( "RankFilter", function( filter )
local rank, flags, i;
local rank, flags, all, i;

rank := 0;
if IS_FUNCTION(filter) then
flags := FLAGS_FILTER(filter);
else
flags := filter;
fi;
for i in TRUES_FLAGS(WITH_HIDDEN_IMPS_FLAGS(flags)) do
if not GAPInfo.CommandLineOptions.N then
all := WITH_HIDDEN_IMPS_FLAGS(flags);
else
all := WITH_IMPS_FLAGS(flags);
fi;
for i in TRUES_FLAGS(all) do
if IsBound(RANK_FILTERS[i]) then
rank := rank + RANK_FILTERS[i];
else
Expand Down
24 changes: 16 additions & 8 deletions lib/oper.g
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,9 @@ BIND_GLOBAL( "DeclareAttributeKernel", function ( name, filter, getter )
od;

# clear the cache because <filter> is something old
InstallHiddenTrueMethod( filter, tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( filter, tester );
fi;
CLEAR_HIDDEN_IMP_CACHE( tester );

# run the attribute functions
Expand Down Expand Up @@ -1199,7 +1201,9 @@ BIND_GLOBAL( "OPER_SetupAttribute", function(getter, flags, mutflag, filter, ran

# the <tester> is newly made, therefore the cache cannot contain a flag
# list involving <tester>
InstallHiddenTrueMethod( filter, tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( filter, tester );
fi;
# CLEAR_HIDDEN_IMP_CACHE();

# run the attribute functions
Expand Down Expand Up @@ -1436,10 +1440,12 @@ BIND_GLOBAL( "DeclarePropertyKernel", function ( name, filter, getter )
INFO_FILTERS[ FLAG2_FILTER( getter ) ]:= 8;

# clear the cache because <filter> is something old
InstallHiddenTrueMethod( tester, getter );
CLEAR_HIDDEN_IMP_CACHE( getter );
InstallHiddenTrueMethod( filter, tester );
CLEAR_HIDDEN_IMP_CACHE( tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( tester, getter );
CLEAR_HIDDEN_IMP_CACHE( getter );
InstallHiddenTrueMethod( filter, tester );
CLEAR_HIDDEN_IMP_CACHE( tester );
fi;

# run the attribute functions
RUN_ATTR_FUNCS( filter, getter, setter, tester, false );
Expand Down Expand Up @@ -1511,8 +1517,10 @@ BIND_GLOBAL( "NewProperty", function ( arg )

# the <tester> and <getter> are newly made, therefore the cache cannot
# contain a flag list involving <tester> or <getter>
InstallHiddenTrueMethod( tester, getter );
InstallHiddenTrueMethod( filter, tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( tester, getter );
InstallHiddenTrueMethod( filter, tester );
fi;
# CLEAR_HIDDEN_IMP_CACHE();

# run the attribute functions
Expand Down
31 changes: 25 additions & 6 deletions lib/oper1.g
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,11 @@ BIND_GLOBAL( "INSTALL_METHOD",
# do check with implications
imp := [];
for i in flags do
ADD_LIST( imp, WITH_HIDDEN_IMPS_FLAGS( i ) );
if not GAPInfo.CommandLineOptions.N then
ADD_LIST( imp, WITH_HIDDEN_IMPS_FLAGS( i ) );
else
ADD_LIST( imp, WITH_IMPS_FLAGS( i ) );
fi;
od;

# Check that the requirements of the method match
Expand Down Expand Up @@ -527,12 +531,27 @@ BIND_GLOBAL( "INSTALL_METHOD",
# If the requirements do not match any of the declarations
# then something is wrong or `InstallOtherMethod' should be used.
if notmatch=0 then
Error("the number of arguments does not match a declaration of ",
NAME_FUNC(opr) );
if not GAPInfo.CommandLineOptions.N then
Error("the number of arguments does not match a declaration of ",
NAME_FUNC(opr) );
else
Print("InstallMethod warning: nr of args does not ",
"match a declaration of ", NAME_FUNC(opr), "\n" );
fi;
else
Error("required filters ", NamesFilter(imp[notmatch]),"\nfor ",
Ordinal(notmatch)," argument do not match a declaration of ",
NAME_FUNC(opr) );
if not GAPInfo.CommandLineOptions.N then
Error("required filters ", NamesFilter(imp[notmatch]),"\nfor ",
Ordinal(notmatch)," argument do not match a declaration of ",
NAME_FUNC(opr) );
else
Print("InstallMethod warning: ", NAME_FUNC(opr), "(\c",INPUT_FILENAME(),"\c +",
INPUT_LINENUMBER(),") \c","required filters \c");
for j in NamesFilter(imp[notmatch]) do
Print(j,"/\c");
od;
Print(" for ",Ordinal(notmatch)," argument do not match \ca ",
"declaration\n");
fi;
fi;

else
Expand Down
69 changes: 69 additions & 0 deletions lib/operdebug.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
##############################################################################
## operdebug.g Frank Lübeck
##
## Non-documented utilities to write out infos about all methods of all
## operations with location and rank, and to write out all filters by name
## and their rank. These can be useful to debug larger changes that influence
## the ranking of filters and methods.
##

# prints lines of format
# name of operation;nr of args;filename:line (of method installation);rank
BIND_GLOBAL("WriteMethodOverview", function(fname)
local name, sline, relname, f;
relname := function(path)
local ls, s;
for s in GAPInfo.RootPaths do
ls := Length(s);
if Length(path) >= ls and path{[1..ls]}=s then
return path{[ls+1..Length(path)]};
fi;
od;
return path;
end;
sline := function(f)
local n;
n := StartlineFunc(f);
if n=fail then
return "\c";
fi;
return Concatenation(":",String(n),"\c");
end;
f := function()
local nam, m, s, op, i, j;
for op in OPERATIONS do
nam := NameFunction(op);
for i in [0..6] do
m := METHODS_OPERATION(op, i);
s := BASE_SIZE_METHODS_OPER_ENTRY + i;
for j in [1..Length(m)/s] do
Print(nam,";\c",i,";",
relname(m[j*s][1]),":",m[j*s][2],";\c",
m[j*s-2],"\n");
od;
od;
od;
end;
PrintTo1(fname, f);
end);

# prints file with lines of format
# filter name (with some abbreviations);rank
BIND_GLOBAL("WriteFilterRanks", function(fname)
local f;
f := function()
local nams, rks, n, i;
nams := List(FILTERS, NameFunction);
rks := List(FILTERS, RankFilter);
SortParallel(nams, rks);
for i in [1..Length(nams)] do
n := SubstitutionSublist(nams[i],"CategoryCollections","CC");
if Length(n) > 75 then
n := Concatenation(n{[1..30]},"...",n{[Length(n)-29..Length(n)]});
fi;
Print(n,";",rks[i],"\n");
od;
end;
PrintTo1(fname, f);
end);

6 changes: 6 additions & 0 deletions lib/read8.g
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ ReadLib( "compiler.g" );
ReadLib( "teaching.g" );
ReadLib( "teachm2.g" );

#############################################################################
##
#X Debugging method and filter ranks
##
ReadLib( "operdebug.g" );

2 changes: 1 addition & 1 deletion lib/system.g
Original file line number Diff line number Diff line change
Expand Up @@ -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?

rec( short:= "O", default := false, help := ["disable/enable loading of obsolete files"] ),
rec( short:= "T", default := false, help := ["disable/enable break loop"] ),
rec( long := "quitonbreak", default := false, help := ["quit GAP with non-zero return value instead of entering break loop"]),
Expand Down
Loading