[m-rev.] diff: mmos tabling optimization
Julien Fischer
juliensf at cs.mu.OZ.AU
Tue Jun 7 21:02:55 AEST 2005
On Tue, 7 Jun 2005, Zoltan Somogyi wrote:
> compiler/table_gen.m:
> Optimize the code we generate for mmos transformations by using a
> single foreign_proc instead of several calls.
>
> Zoltan.
>
> cvs diff: Diffing .
> Index: table_gen.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
> retrieving revision 1.83
> diff -u -b -r1.83 table_gen.m
> --- table_gen.m 7 Jun 2005 02:59:56 -0000 1.83
> +++ table_gen.m 7 Jun 2005 10:21:57 -0000
> @@ -1544,7 +1544,6 @@
> make_const_construction(GeneratorPredVar, GeneratorConsId,
> MakeGeneratorVarGoal),
>
> - % XXX use tabling via foreign_proc
> generate_call_table_lookup_goals(strict, NumberedInputVars, PredId, ProcId,
> Context, !VarTypes, !VarSet, !TableInfo, _TableTipVar, _LookupGoals,
> Steps, PredTableVar, LookupForeignArgs, LookupPrefixGoals,
> @@ -2459,43 +2458,50 @@
> generate_new_table_var("AnswerTableVar", trie_node_type,
> !VarTypes, !VarSet, AnswerTableVar),
> GeneratorName = generator_name,
> - AnswerTableName = answer_table_name,
> - GeneratorArg = foreign_arg(GeneratorVar,
> - yes(GeneratorName - in_mode), generator_type),
> - AnswerTableArg = foreign_arg(AnswerTableVar,
> - yes(AnswerTableName - in_mode), trie_node_type),
> - GetPredName = "table_mmos_get_answer_table",
> - GetPredCode = "\t" ++ AnswerTableName ++ " = " ++
> - "MR_" ++ GetPredName ++ "(" ++ GeneratorName ++ ");\n",
> - table_generate_foreign_proc(GetPredName, det, tabling_c_attributes,
> - [GeneratorArg, AnswerTableArg], [], "", GetPredCode, "",
> - semipure_code, ground_vars([AnswerTableVar]),
> - ModuleInfo, Context, GetAnswerTableGoal),
> -
> - % XXX use foreign_proc
> + GeneratorArg = foreign_arg(GeneratorVar, yes(GeneratorName - in_mode),
> + generator_type),
> generate_table_lookup_goals(NumberedOutputVars, strict, "AnswerTableNode",
> - Context, AnswerTableVar, AnswerTableTipVar, !VarTypes, !VarSet,
> - !TableInfo, LookupAnswerGoals, _, _LookupForeignArgs,
> - _LookupPrefixGoals, _LookupCodeStr),
> + Context, AnswerTableVar, _AnswerTableTipVar, !VarTypes, !VarSet,
> + !TableInfo, _LookupAnswerGoals, _Steps, LookupForeignArgs,
> + LookupPrefixGoals, LookupCodeStr),
>
> - generate_call("table_mmos_answer_is_not_duplicate", semidet,
> - [AnswerTableTipVar], impure_code,
> - [], ModuleInfo, Context, DuplicateCheckGoal),
> + CreatePredName = "table_mm_create_answer_block",
> generate_new_table_var("AnswerBlock", answer_block_type,
> !VarTypes, !VarSet, AnswerBlockVar),
> - gen_int_construction("BlockSize", BlockSize, !VarTypes, !VarSet,
> - BlockSizeVar, BlockSizeVarUnifyGoal),
> - generate_call("table_mmos_create_answer_block", det,
> - [GeneratorVar, BlockSizeVar, AnswerBlockVar], impure_code,
> - ground_vars([AnswerBlockVar]), ModuleInfo, Context,
> - CreateAnswerBlockGoal),
> - % use foreign_proc
> generate_save_goals(NumberedOutputVars, AnswerBlockVar, Context,
> - !VarTypes, !VarSet, !TableInfo, SaveGoals, _X, _XX, _XXX),
> - TailGoals = SaveGoals,
> - Goals = [GetAnswerTableGoal | LookupAnswerGoals] ++
> - [DuplicateCheckGoal, BlockSizeVarUnifyGoal,
> - CreateAnswerBlockGoal | TailGoals].
> + !VarTypes, !VarSet, !TableInfo, _SaveGoals,
> + _SaveArgs, SavePrefixGoals, SaveCodeStr),
> +
> + DuplCheckPredNameShortCut = DuplCheckPredName ++ "_shortcut",
This doesn't compile; DuplCheckPredName is free at this point.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list