Abstract
Parallelizing logic programming languages like Prolog often faces significant bottlenecks due to centralized memory management for variable bindings. This paper presents a non-shared binding scheme based on "Eager Instantiation." By substituting variables with their values at the point of binding and utilizing a dataflow-based virtual machine, the proposed method eliminates the need for a global stack, enabling efficient execution on distributed-memory multiprocessors.
Introduction
In traditional sequential Prolog implementations, variable bindings are typically managed using a "three-stack" architecture. While efficient on single-processor systems, this approach creates a "shared memory bottleneck" in parallel environments. When sub-goals are distributed across multiple processors, they frequently need to access and update a centralized binding environment to dereference variables. This leads to high communication overhead and contention.
To address this, researchers have explored various distributed binding schemes. However, many early attempts involved complex "back-unification" or expensive environment-closing operations. This paper, originally published in 1990 by Kang Zhang and Ray Thomas, proposes a streamlined "Eager Instantiation" scheme designed to make binding environments (BEs) entirely local to each process.
The Eager Instantiation Binding Scheme
The core of the proposed solution is the elimination of remote variable dereferencing through eager value substitution. Instead of maintaining pointers to ancestor processes, the system ensures that a process has all the data it needs before it begins execution or immediately upon a sibling's completion.
Face and Interface Instantiation
The scheme utilizes two primary mechanisms for managing data flow between goals:
- Face Instantiation: Before a parent process invokes a child process for a sub-goal, it substitutes all currently known variable bindings into the goal's arguments. This ensures the child receives a "clean" copy of the data, removing any dependency on the parent's memory space.
- Interface Instantiation: When a child process successfully completes, it "exports" its results back to the parent. Any variables bound during the child's execution are then eagerly pushed into any sibling processes that require those values.
By combining these two techniques, the system maintains local binding environments that are independent of other processors, significantly reducing inter-processor communication during the search process.
The DIALOG Virtual Machine
The authors implemented this scheme on a custom virtual machine called DIALOG, which uses a dataflow execution model. In DIALOG, logic programs are compiled into dataflow graphs where nodes represent instructions and edges represent the flow of data tokens.
A node in the DIALOG graph only fires when all its required input tokens are available. This naturally supports the eager instantiation model, as data is pushed through the graph as soon as it is produced. To manage memory efficiently, the system uses dynamic variable-instance pairs rather than fixed value cells, avoiding write-synchronization issues.
Experimental Evaluation
The scheme was evaluated using six classic Prolog benchmarks, ranging from determinate list concatenation (append1) to more complex tasks like Quicksort (qsort) and naive reverse (na_rev).
Key Results
- Minimal Environment Size: The "eager" management of bindings kept the memory footprint remarkably lean. The maximum number of variable-instance pairs in any environment was found to be less than 3, with an average of less than 2.
- Copying Overhead: The system performed an average of 1.3 structure copying operations per logic inference. While structure copying is generally more expensive than pointer sharing, the authors found the overhead to be manageable, even in recursion-heavy benchmarks like
na_rev. - Scalability: Simulations on up to 8 processing elements (PEs) indicated that the scheme is feasible for distributed architectures. The "lazy copying" policy for environments proved effective on a probabilistic basis.
Discussion and Conclusion
The "Eager Instantiation" scheme demonstrates that in distributed systems, locality is often more valuable than sharing. By trading some CPU and memory for reduced communication, the system achieves better parallel scalability. To further optimize performance, the authors introduced "tail sharing" for lists, which reduced copying costs by approximately 50%.
However, limitations remain. The "copy-everything" approach may still struggle with exceptionally large or complex data structures. Furthermore, the current implementation primarily targets OR-parallelism and independent AND-parallelism, leaving dependent AND-parallelism for future research. Despite these constraints, the work provides a robust foundation for implementing logic programming on non-shared memory parallel hardware.
Summary updated