swapping evaluation a memory scalable solution for answer
play

Swapping Evaluation: A Memory-Scalable Solution for Answer-On-Demand - PowerPoint PPT Presentation

Swapping Evaluation: A Memory-Scalable Solution for Answer-On-Demand Tabling an 1 Manuel Carro 1 David S. Warren 2 Pablo Chico de Guzm 1 School of Computer Science, Technical University of Madrid, Spain 2 State University of New York at Stony


  1. Swapping Evaluation: A Memory-Scalable Solution for Answer-On-Demand Tabling an 1 Manuel Carro 1 David S. Warren 2 Pablo Chico de Guzm´ 1 School of Computer Science, Technical University of Madrid, Spain 2 State University of New York at Stony Brook, USA ICLP 2010 — Edinburgh – July 16, 2010 Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 1 / 15

  2. Introduction Tabling Basics Tabling : resolution strategy (alternative to SLD) aimed at improving both efficiency and declarativeness in Prolog. ◮ ≈ memoing: answers for already executed calls retrieved from table. ◮ Infinite recursions automatically avoided. ?− p(A). Example code :- table p/1. q, p(B), A = 2. A = 1. p(A) :- p(B), A = 2. q, p(B), A = 2. Suspension p(1), A = 2. p(A) :- A = 1. A = 2. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 2 / 15

  3. Introduction External and Internal Consumers Internal: appears under its generator execution tree. External: appears out of the scope of its generator execution tree. Example code a b a ?- a, b, a. :- table a/0. a true EXTERNAL a :- a. a. b. INTERNAL Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 3 / 15

  4. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. comp1 t(X) :- computation2, X = 2. t(1) p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  5. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. comp1 t(X) :- computation2, X = 2. t(1) p :- large1. p :- large2. fail ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  6. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. comp2 t(X) :- computation2, X = 2. t(2) p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  7. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. comp2 t(X) :- computation2, X = 2. t(2) p :- large1. p :- large2. fail ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  8. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. t(X) :- computation1, X = 1. t(X) :- computation2, X = 2. p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  9. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. large1 t(X) :- computation2, t(1) X = 2. p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  10. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. large1 t(X) :- computation2, t(1) t(1) X = 2. p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  11. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. large1 t(X) :- computation2, t(2) t(1) X = 2. p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  12. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. large2 t(X) :- computation2, t(1) t(2) t(1) X = 2. p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  13. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. t(X) :- computation2, largeN X = 2. t(1) t(2) t(1) p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  14. Scheduling Strategy Tabling: Scheduling Strategy Local scheduling Computes all the answers before returning any of them. Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. t(X) :- computation2, large1 X = 2. t(2) t(1) t(2) p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 4 / 15

  15. Scheduling Strategy Tabling: Scheduling Strategy Batched scheduling Returns each of the answer as soon as they are computed. ◮ Cut-Once operators can prune when the desired answer is found. ◮ Bad memory behavior (live environments & external suspensions). Example code ?- t(X), p, t(Y), fail. p t(X) t(Y) fail :- table t/1. t(X) :- computation1, X = 1. comp1 t(X) :- computation2, X = 2. t(1) p :- large1. p :- large2. ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 5 / 15

  16. Scheduling Strategy Tabling: Scheduling Strategy Batched scheduling Returns each of the answer as soon as they are computed. ◮ Cut-Once operators can prune when the desired answer is found. ◮ Bad memory behavior (live environments & external suspensions). Example code ?- t(X), p, t(Y), fail. p t(X) t(Y) fail :- table t/1. t(X) :- computation1, X = 1. comp1 t(X) :- computation2, X = 2. t(1) p :- large1. p :- large2. large1 ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 5 / 15

  17. Scheduling Strategy Tabling: Scheduling Strategy Batched scheduling Returns each of the answer as soon as they are computed. ◮ Cut-Once operators can prune when the desired answer is found. ◮ Bad memory behavior (live environments & external suspensions). Example code ?- t(X), p, t(Y), fail. p t(X) t(Y) fail :- table t/1. t(X) :- computation1, t(1) X = 1. comp1 t(X) :- computation2, X = 2. t(1) p :- large1. p :- large2. large1 ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 5 / 15

  18. Scheduling Strategy Tabling: Scheduling Strategy Batched scheduling Returns each of the answer as soon as they are computed. ◮ Cut-Once operators can prune when the desired answer is found. ◮ Bad memory behavior (live environments & external suspensions). Example code ?- t(X), p, t(Y), fail. p t(X) t(Y) fail :- table t/1. t(X) :- computation1, t(1) X = 1. comp1 t(X) :- computation2, Susp. X = 2. t(1) p :- large1. p :- large2. large1 ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 5 / 15

  19. Scheduling Strategy Tabling: Scheduling Strategy Batched scheduling Returns each of the answer as soon as they are computed. ◮ Cut-Once operators can prune when the desired answer is found. ◮ Bad memory behavior (live environments & external suspensions). Example code ?- t(X), p, t(Y), fail. p t(X) t(Y) fail :- table t/1. t(X) :- computation1, t(1) X = 1. comp1 t(X) :- computation2, Susp. X = 2. t(1) p :- large1. p :- large2. large1 large2 ... p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 5 / 15

  20. Scheduling Strategy Tabling: Scheduling Strategy Batched scheduling Returns each of the answer as soon as they are computed. ◮ Cut-Once operators can prune when the desired answer is found. ◮ Bad memory behavior (live environments & external suspensions). Example code ?- t(X), p, t(Y), fail. :- table t/1. p t(X) t(Y) fail t(X) :- computation1, X = 1. t(1) comp1 t(X) :- computation2, X = 2. Susp. p :- large1. t(1) p :- large2. ... ... large1 large2 largeN p :- largeN. Pablo Chico de Guzm´ an et al (UPM) Swapping Evaluation. . . ICLP 2010, Edinburgh 5 / 15

Recommend


More recommend