[GIT] ppl/ppl(termination): Added the new termination functions to Prolog interface and

Module: ppl/ppl Branch: termination Commit: 07ba164136b4181c4e51b1994eb2b858c692814f URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=07ba164136b41...
Author: Patricia Hill p.m.hill@leeds.ac.uk Date: Mon Mar 8 12:39:37 2010 +0000
Added the new termination functions to Prolog interface and the termination_test_MS only to the C interface.
---
interfaces/C/ppl_interface_generator_c_cc_code.m4 | 12 ++++ interfaces/C/ppl_interface_generator_c_h_code.m4 | 9 +++ ...l_interface_generator_c_procedure_generators.m4 | 1 + .../ppl_interface_generator_prolog_cc_code.m4 | 55 ++++++++++++++++++++ .../ppl_interface_generator_prolog_hh_code.m4 | 20 +++++++ ...erface_generator_prolog_procedure_generators.m4 | 8 +++- interfaces/ppl_interface_generator_common_dat.m4 | 6 ++- 7 files changed, 109 insertions(+), 2 deletions(-)
diff --git a/interfaces/C/ppl_interface_generator_c_cc_code.m4 b/interfaces/C/ppl_interface_generator_c_cc_code.m4 index 6f5b80d..22ddd23 100644 --- a/interfaces/C/ppl_interface_generator_c_cc_code.m4 +++ b/interfaces/C/ppl_interface_generator_c_cc_code.m4 @@ -1156,6 +1156,18 @@ CATCH_ALL
')
+m4_define(`ppl_@CLASS@_termination_test_MS_code', +`dnl +int +ppl_@CLASS@_termination_test_MS +(ppl_const_@CLASS@_t x) try { + const @CPP_CLASS@& xx = *to_const(x); + return termination_test_MS(xx); +} +CATCH_ALL + +') + m4_define(`ppl_@CLASS@_wrap_assign_code', `int ppl_@CLASS@_wrap_assign diff --git a/interfaces/C/ppl_interface_generator_c_h_code.m4 b/interfaces/C/ppl_interface_generator_c_h_code.m4 index 861af48..39f717e 100644 --- a/interfaces/C/ppl_interface_generator_c_h_code.m4 +++ b/interfaces/C/ppl_interface_generator_c_h_code.m4 @@ -34,6 +34,15 @@ dnl There is no code at present for these procedures in the C interface. dnl Remove the macro if its definition is added. dnl
+m4_define(`ppl_@CLASS@_termination_test_MS_code', +`dnl +/*! \relates ppl_@CLASS@_tag */ +int +ppl_@CLASS@_termination_test_MS +PPL_PROTO((ppl_const_@CLASS@_t x)); + +') + m4_define(`ppl_@CLASS@_linear_@PARTITION@_code', `dnl /*! \relates ppl_@CLASS@_tag */ diff --git a/interfaces/C/ppl_interface_generator_c_procedure_generators.m4 b/interfaces/C/ppl_interface_generator_c_procedure_generators.m4 index 9aa2a19..7f590d7 100644 --- a/interfaces/C/ppl_interface_generator_c_procedure_generators.m4 +++ b/interfaces/C/ppl_interface_generator_c_procedure_generators.m4 @@ -44,5 +44,6 @@ ppl_new_@TOPOLOGY@@CLASS@_recycle_@BUILD_REPRESENT@s +simple, ppl_assign_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@ +simple, ppl_@CLASS@_add_recycled_@CLASS_REPRESENT@s +simple, ppl_@CLASS@_wrap_assign +simple, +ppl_@CLASS@_termination_test_MS +simple, ) ') diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 index cd1f2f7..0fd0510 100644 --- a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 +++ b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 @@ -1228,6 +1228,61 @@ m4_define(`ppl_@CLASS@_bounded_@AFFIMAGE@_code',
')
+m4_define(`ppl_@CLASS@_termination_test_@TERMINATION_ID@_code', + `extern "C" Prolog_foreign_return_type + ppl_@CLASS@_termination_test_@TERMINATION_ID@ + (Prolog_term_ref t_ph) { + static const char* where = "ppl_@CLASS@_termination_test_@TERMINATION_ID@/1"; + try { + @CPP_CLASS@* ph = term_to_handle<@CPP_CLASS@ >(t_ph, where); + PPL_CHECK(ph); + if (Parma_Polyhedra_Library::termination_test_@TERMINATION_ID@(*ph)) + return PROLOG_SUCCESS; + } + CATCH_ALL; +} + +') + +m4_define(`ppl_@CLASS@_one_affine_ranking_function_@TERMINATION_ID@_code', + `extern "C" Prolog_foreign_return_type + ppl_@CLASS@_one_affine_ranking_function_@TERMINATION_ID@ + (Prolog_term_ref t_x, + Prolog_term_ref t_g) { + static const char* where = "ppl_@CLASS@_one_affine_ranking_function_@TERMINATION_ID@/2"; + try { + @CPP_CLASS@* x = term_to_handle<@CPP_CLASS@ >(t_x, where); + Generator gg(point()); + PPL_CHECK(x); + if (Parma_Polyhedra_Library::one_affine_ranking_function_@TERMINATION_ID@(*x, gg) + && Prolog_unify(t_g, generator_term(gg))) + return PROLOG_SUCCESS; + } + CATCH_ALL; +} + +') + +m4_define(`ppl_@CLASS@_all_affine_ranking_functions_@TERMINATION_ID@_code', + `extern "C" Prolog_foreign_return_type + ppl_@CLASS@_all_affine_ranking_functions_@TERMINATION_ID@ + (Prolog_term_ref t_x, + Prolog_term_ref t_ph) { + static const char* where = + "ppl_@CLASS@_all_affine_ranking_functions_@TERMINATION_ID@/2"; + try { + @CPP_CLASS@* x = term_to_handle<@CPP_CLASS@ >(t_x, where); + C_Polyhedron* ph = term_to_handle<C_Polyhedron >(t_ph, where); + PPL_CHECK(x); + Parma_Polyhedra_Library::all_affine_ranking_functions_@TERMINATION_ID@(*x, + *ph); + return PROLOG_SUCCESS; + } + CATCH_ALL; +} + +') + m4_define(`ppl_@CLASS@_@WIDEN@_widening_assign_with_tokens_code', `extern "C" Prolog_foreign_return_type ppl_@CLASS@_@WIDEN@_widening_assign_with_tokens diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4 index f1667b9..bc50e6b 100644 --- a/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4 +++ b/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4 @@ -510,3 +510,23 @@ m4_define(`ppl_@CLASS@_@MEMBYTES@_code', Prolog_term_ref t_m);
') + +m4_define(`ppl_@CLASS@_termination_test_MS_code', + `extern "C" Prolog_foreign_return_type + ppl_@CLASS@_termination_test_MS(Prolog_term_ref t_x); + +') + +m4_define(`ppl_@CLASS@_one_affine_ranking_function_MS_code', + `extern "C" Prolog_foreign_return_type + ppl_@CLASS@_one_affine_ranking_function_MS(Prolog_term_ref t_x, + Prolog_term_ref t_g); + +') + +m4_define(`ppl_@CLASS@_all_affine_ranking_functions_MS_code', + `extern "C" Prolog_foreign_return_type + ppl_@CLASS@_all_affine_ranking_functions_MS(Prolog_term_ref t_x, + Prolog_term_ref t_g); + +') diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_procedure_generators.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_procedure_generators.m4 index 3105be7..08798d0 100644 --- a/interfaces/Prolog/ppl_interface_generator_prolog_procedure_generators.m4 +++ b/interfaces/Prolog/ppl_interface_generator_prolog_procedure_generators.m4 @@ -85,4 +85,10 @@ ppl_MIP_Problem_OK/1 ppl_MIP_Problem_ascii_dump/1`'dnl ')
-m4_define(`m4_procedure_list', `m4_common_procedure_list') +m4_define(`m4_procedure_list', + `m4_echo_unquoted(`m4_common_procedure_list', +ppl_@CLASS@_termination_test_MS/1 +simple, +ppl_@CLASS@_one_affine_ranking_function_MS/2 +simple, +ppl_@CLASS@_all_affine_ranking_functions_MS/2 +simple, +) +') diff --git a/interfaces/ppl_interface_generator_common_dat.m4 b/interfaces/ppl_interface_generator_common_dat.m4 index ca20896..64ae91f 100644 --- a/interfaces/ppl_interface_generator_common_dat.m4 +++ b/interfaces/ppl_interface_generator_common_dat.m4 @@ -530,7 +530,8 @@ point, constrainer, disjunct, disjunct_topology, -disjunct_extrapolation') +disjunct_extrapolation, +termination_id')
dnl --------------------------------------------------------------------- dnl Define the replacement macros for all patterns @@ -984,3 +985,6 @@ m4_define(`m4_membytes_replacements', `external_memory_in_bytes, total_memory_in_bytes') m4_define(`m4_Pointset_Powerset_membytes_replacements', `m4_membytes_replacements, size') + +dnl The termination algorithms are either sourced from MS or PR. +m4_define(`m4_termination_id_replacements', `MS, PR')
participants (1)
-
Patricia Hill