[PPL-devel] [GIT] ppl/ppl(termination): Added the new termination functions to Prolog interface and
Patricia Hill
p.m.hill at leeds.ac.uk
Mon Mar 8 13:49:15 CET 2010
Module: ppl/ppl
Branch: termination
Commit: 07ba164136b4181c4e51b1994eb2b858c692814f
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=07ba164136b4181c4e51b1994eb2b858c692814f
Author: Patricia Hill <p.m.hill at 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_ at CLASS@_termination_test_MS_code',
+`dnl
+int
+ppl_ at CLASS@_termination_test_MS
+(ppl_const_ at CLASS@_t x) try {
+ const @CPP_CLASS@& xx = *to_const(x);
+ return termination_test_MS(xx);
+}
+CATCH_ALL
+
+')
+
m4_define(`ppl_ at CLASS@_wrap_assign_code',
`int
ppl_ at 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_ at CLASS@_termination_test_MS_code',
+`dnl
+/*! \relates ppl_ at CLASS@_tag */
+int
+ppl_ at CLASS@_termination_test_MS
+PPL_PROTO((ppl_const_ at CLASS@_t x));
+
+')
+
m4_define(`ppl_ at CLASS@_linear_ at PARTITION@_code',
`dnl
/*! \relates ppl_ at 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_ at TOPOLOGY@@CLASS at _recycle_@BUILD_REPRESENT at s +simple,
ppl_assign_ at TOPOLOGY@@CLASS at _from_@TOPOLOGY@@CLASS@ +simple,
ppl_ at CLASS@_add_recycled_ at CLASS_REPRESENT@s +simple,
ppl_ at CLASS@_wrap_assign +simple,
+ppl_ at 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_ at CLASS@_bounded_ at AFFIMAGE@_code',
')
+m4_define(`ppl_ at CLASS@_termination_test_ at TERMINATION_ID@_code',
+ `extern "C" Prolog_foreign_return_type
+ ppl_ at CLASS@_termination_test_ at TERMINATION_ID@
+ (Prolog_term_ref t_ph) {
+ static const char* where = "ppl_ at CLASS@_termination_test_ at TERMINATION_ID@/1";
+ try {
+ @CPP_CLASS@* ph = term_to_handle<@CPP_CLASS@ >(t_ph, where);
+ PPL_CHECK(ph);
+ if (Parma_Polyhedra_Library::termination_test_ at TERMINATION_ID@(*ph))
+ return PROLOG_SUCCESS;
+ }
+ CATCH_ALL;
+}
+
+')
+
+m4_define(`ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@_code',
+ `extern "C" Prolog_foreign_return_type
+ ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@
+ (Prolog_term_ref t_x,
+ Prolog_term_ref t_g) {
+ static const char* where = "ppl_ at CLASS@_one_affine_ranking_function_ at 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_ at TERMINATION_ID@(*x, gg)
+ && Prolog_unify(t_g, generator_term(gg)))
+ return PROLOG_SUCCESS;
+ }
+ CATCH_ALL;
+}
+
+')
+
+m4_define(`ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@_code',
+ `extern "C" Prolog_foreign_return_type
+ ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@
+ (Prolog_term_ref t_x,
+ Prolog_term_ref t_ph) {
+ static const char* where =
+ "ppl_ at CLASS@_all_affine_ranking_functions_ at 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_ at TERMINATION_ID@(*x,
+ *ph);
+ return PROLOG_SUCCESS;
+ }
+ CATCH_ALL;
+}
+
+')
+
m4_define(`ppl_ at CLASS@_ at WIDEN@_widening_assign_with_tokens_code',
`extern "C" Prolog_foreign_return_type
ppl_ at CLASS@_ at 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_ at CLASS@_ at MEMBYTES@_code',
Prolog_term_ref t_m);
')
+
+m4_define(`ppl_ at CLASS@_termination_test_MS_code',
+ `extern "C" Prolog_foreign_return_type
+ ppl_ at CLASS@_termination_test_MS(Prolog_term_ref t_x);
+
+')
+
+m4_define(`ppl_ at CLASS@_one_affine_ranking_function_MS_code',
+ `extern "C" Prolog_foreign_return_type
+ ppl_ at CLASS@_one_affine_ranking_function_MS(Prolog_term_ref t_x,
+ Prolog_term_ref t_g);
+
+')
+
+m4_define(`ppl_ at CLASS@_all_affine_ranking_functions_MS_code',
+ `extern "C" Prolog_foreign_return_type
+ ppl_ at 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_ at CLASS@_termination_test_MS/1 +simple,
+ppl_ at CLASS@_one_affine_ranking_function_MS/2 +simple,
+ppl_ at 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')
More information about the PPL-devel
mailing list