Skip to content

Commit

Permalink
Merge pull request #705 from zickgraf/precompiled_tower_constructors
Browse files Browse the repository at this point in the history
Add experimental code to AdditiveClosure which allows to load precompiled code automatically
  • Loading branch information
zickgraf authored Sep 1, 2021
2 parents 9e2064d + 1edc647 commit 39e0986
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CompilerForCAP/gap/PrecompileCategory.gi
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct
fi;

# check that category_constructor supports `FinalizeCategory` and `enable_compilation`
cat := CallFuncList( category_constructor, given_arguments : FinalizeCategory := false, enable_compilation := true );
cat := CallFuncList( category_constructor, given_arguments : FinalizeCategory := false, enable_compilation := true, no_precompiled_code := true );

if HasIsFinalized( cat ) then

Expand Down Expand Up @@ -351,7 +351,7 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct
" \n",
" \n",
" \n",
" cat := category_constructor( ", parameters_string, " : FinalizeCategory := false );\n"
" cat := category_constructor( ", parameters_string, " : FinalizeCategory := false, no_precompiled_code := true );\n"
);
output_string := Concatenation( output_string, current_string );

Expand Down
43 changes: 42 additions & 1 deletion FreydCategoriesForCAP/gap/AdditiveClosure.gi
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,53 @@ InstallMethod( AdditiveClosure,
[ IsCapCategory ],

function( underlying_category )
local category, matrix_element_as_morphism, list_list_as_matrix, homalg_ring, to_be_finalized;
local precompiled_tower_constructors, constructors_in_tower, precompiled_category_getter, category, matrix_element_as_morphism, list_list_as_matrix, homalg_ring, to_be_finalized, info;

if not ( HasIsAbCategory( underlying_category ) and IsAbCategory( underlying_category ) ) then

Error( "The underlying category has to be an Ab-category" );

fi;

# EXPERIMENTAL
precompiled_tower_constructors := [ ];

if IsBound( underlying_category!.compiler_hints ) and IsBound( underlying_category!.compiler_hints.precompiled_tower_constructors ) then

for info in underlying_category!.compiler_hints.precompiled_tower_constructors do

constructors_in_tower := info.constructors_in_tower;
precompiled_category_getter := info.precompiled_category_getter;

if constructors_in_tower[1] = "AdditiveClosure" then

if Length( constructors_in_tower ) = 1 and ValueOption( "no_precompiled_code" ) <> true then

# try to get precompiled version
category := CallFuncList( precompiled_category_getter, [ underlying_category ] );

if category <> fail then

return category;

fi;

else

# pass information on to the next level
Add( precompiled_tower_constructors, rec(
constructors_in_tower := constructors_in_tower{[ 2 .. Length( constructors_in_tower ) ]},
precompiled_category_getter := precompiled_category_getter,
) );

fi;

fi;

od;

fi;

category := CreateCapCategory( Concatenation( "Additive closure( ", Name( underlying_category )," )" ) );

category!.category_as_first_argument := true;
Expand All @@ -31,6 +70,8 @@ InstallMethod( AdditiveClosure,
category_attribute_names := [
"UnderlyingCategory",
],
# EXPERIMENTAL
precompiled_tower_constructors := precompiled_tower_constructors,
);

matrix_element_as_morphism := ValueOption( "matrix_element_as_morphism" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end;



cat := category_constructor( field : FinalizeCategory := false );
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );

##
AddAdditionForMorphisms( cat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end;



cat := category_constructor( field : FinalizeCategory := false );
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );

##
AddAdditionForMorphisms( cat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end;



cat := category_constructor( field : FinalizeCategory := false );
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );

##
AddAdditionForMorphisms( cat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end;



cat := category_constructor( field : FinalizeCategory := false );
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );

##
AddAdditionForMorphisms( cat,
Expand Down

0 comments on commit 39e0986

Please sign in to comment.