Wamcc: Compile the prolog into C (No.7-6)

Source: Internet
Author: User

6. Performance Evaluation

Now let's refine the wamcc system and compare other Prolog systems, either academic or commercial.

6.1 benchmarking procedure
Table 1 shows the performance of the traditional benchmark wamcc. Sparc2 (2.85 MIPS) in seconds uses the-O2 option of gcc2.5.8. For each program, we can find that the number of lines of the prolog source program has to compile time (prolog to C, GCC, connector), the size of the object code and the final executable file (bytes) and time.

Table 1: wamcc Performance

6.2 wamcc and academic Prolog System
Let's immediately compare wamcc with other systems in the same category: Academic Prolog systems, which are generally developed by one person for research purposes and released free of charge through FTP. Among these systems, we chose the most popular one. Therefore, we have:

Binprolog 3.0: this implementation is based on the "binarization" clause, which generally includes explicit continuation. Wam is a simulated professional and abstract code (a simulator written in C ). Recently, I have also investigated a translation of C [12].
Xsb-Prolog 1.4.0: This language is popular with Sb-Prolog followers. It also uses the C language to write a simulator, but integrates some of the evaluation techniques for specific partial instantiation calls. It can also detect certain conditions and effectively compile the control structure using the if-then-else of PROLOG. The compilation phase can be very long.
SWI-Prolog 1.8.11: This system features its compilation speed and provides multiple built-in predicates. This is the most common academic Prolog System so far.

Table 2 shows the execution time of these different systems and the average acceleration of wamcc. The entry in the overflow table indicates the maximum stack size of the plan completed before the memory is exhausted.

Table 2: wamcc compared with other academic PROLOG

On average, wamcc is twice that of binprolog. However, on the nrev benchmark, binprolog is faster than wamcc. This is because wamcc is very simple. wamcc does not contain any well-known optimizations (like to unify the stream separately, perform simple backtracking, and perform unified re-sorting ,...). We can also note that wamcc is 2.7 times faster than xsb-PROLOG and 5.6 times faster than SWI-Prolog (Tak benchmark is not considered ).

6.3 wamcc and commercial Prolog System
Now let's compare wamcc with commercial Prolog systems, usually developed by some people for years. Prolog systems compared with wamccb include:

Sicstus: this system is very popular because it has become one of the pioneers in providing an efficient system for collecting small fees. It has become a reference to the actual performance of a Prolog System. The current version can generate bytecode (analog) and local code (iSCSI ). Here we will compare the two versions of wamcc.
Quintus: it is the most effective system for a long time. It is written based on the assembly language of the optimization simulator. However, please note that we only have version 2.5.1, which is not the latest version.
AQUARIUS: this is currently the most efficient Prolog System. It is very complex and generates lower-level local code (BAM) than WAM through a primitive abstraction machine ). The compiler implements many optimizations (data stream analysis, abstract interpretation, deterministic detection,...). Translation of BAM to local code is also quite complex and integrates the Command Re-sorting instance of the machine on the machine.


Table 2: wamcc compared to commercial Prolog table 3 lists the execution time of these systems and the average speed of wamcc (or slowing down when the # symbol is currently marked ). Let us note that the initial goal was achieved, and wamcc was 1.6 times faster than the simulation sictus. It is 1.7 times slower than the local sicstus Code and is equivalent to Quintus. The average performance of wamcc is 3.5 times slower than that of Aquarius, but this is mainly because Aquarius performs well on the Tak benchmark (9 times faster than wamcc ), it can detect deterministic and optimized integer terminal calls. Let's note that the Aquarius program is twice as powerful as the C program! However, the real Prolog Program (using unification and backtracking) is slightly different. For example, the Aquarius of the zebra puzzle is only 1.3 times faster, and the Aquarius Of The Boyer program is less than twice faster. We can note that this system does not process modules, so that more information can be extracted during compilation to generate better Code (for example, the symbols can be pre-Hash encoded ). This is no longer possible when processing several modules.

It is observed that wamcc was developed by a person only within a few months, so it can be proud to be compared with teams of several implementers who have written complex systems for several years. Another important issue is that, in fact, wamcc is much simpler. Compared with the core code complexity (Local Code), sicstus (35000 lines of C) and wamcc (6000 lines), our performance advantage is far better than sicutus (coefficient 1.6 ). Similarly, the sicstus compiler contains 9000 lines of Prolog Code, while wamcc only contains 3000 lines. With regard to quintus, the extensive use of assembly languages makes it difficult to maintain and expand the given system, and its performance is not better than that of wamcc. Aquarius has notable performance, but the main certainty and computation program is not the most typical Prolog application expected. On the contrary, in fact, it seems unrealistic for Aquarius to compile 400-line long programs (reducers) in 38 minutes. Wamcc only takes 5 minutes to generate an executable program, while Aquarius may slow down 2.7 times, but in any case it takes less than one second. Another disadvantage of the Aquarius system is that the size of the generated code is about 4 times larger than that of wamcc.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.