Academia.eduAcademia.edu

Efficient Stream/Array Processing in Logic Programming Languages

Abstract

The Concurrent Prolog predicate for merging n input streams is investigated, and a compilation technique tor getting its efficient code is presented. Using the. technique, data are transferred with a .delay independent of n. Furthermore, it is shown that the addition and the removal of an input stream can be done within an average time of 0(1). The predicate for distributing data on an input stream to fa output streams can also be. realized as efficiently as n-ary merge. The compilation technique for the distributt predicate can further be applied to the implementation of mutable arrays thaf allow constant-time accessing and updating. Although the efficiency stated above could be achieved by a sOphisticated compiler, the codes should be provided directly by the system to get rid of the bulk ot source programs and the time required to compile them. 1 INTRODUCTION When we implement a large-scale distributed system in a parallel logic programming language such as Concurrent Prolog (Shapiro 1983) and PARLOG (Clark and Gregory 1984), the performance of the system will be influenced significantly by how efficiently streams as. interprocess communication channels can be merged and distributed. This paper deals with implementation techniques of the predicates that merge many input streams and those which distribute data on a single input stream into multiple output streams. The language we chose for the following discussions is Concurrent Prolog. However, the results obtained are applicable also to PARLOG. For readers unfamiliar with Concurrent Prolog, an outline of Concurrent Prolog is described in Appendix I. This paper focuses on implementation on conventional sequential computers. Of course, to demonstrate the viability of Concurrent Prolog on parallel computers, the scope of discussion cannot be limited to sequential computers. However, even on a parallel architecture, it would be very likely for each processor to deal with multiple processes for the following reasons. First, the number of processes a user can create should not be limited to the number of processors available. Second, even if a lot of processors are available, the best way to allocate two processes which communicate intensively with each other