<div dir="ltr"><div>Well, I discovered the problem. I need to compile the program with:<br><br>mmc --parallel -j4 --grade=asm_fast.par.gc fibgc.m -o fib.x<br><br></div>Now, Mercury goes faster than C, as before. Thank you, anyway.<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-28 18:03 GMT-02:00 Eduardo Costa <span dir="ltr"><<a href="mailto:edu500ac@gmail.com" target="_blank">edu500ac@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>A few years ago, I tested Mercury for parallel programming. It worked very well. In fact, with 8 CPUs, Mercury could beat a C program. Recently, I tested the very same programs again, but this time Mercury refused to parallelize the process. Gnome System Monitor shows a single CPU doing all the work. Here is the program I borrowed from Paul Bone's thesis:<br><br>:- module fibgc.<br>:- interface.<br>:- import_module io.<br>:- pred main(io::di, io::uo) is det.<br>:- implementation.<br><br>:- import_module float,integer.<br>:- import_module solutions, io, int.<br>:- import_module string, char, list.<br><br>:- func fib(int, int) = int.<br><br>fib(N, Depth)= F :-<br>    ( N<2 -> F=1<br>     ;<br>     (Depth > 0 -><br>          ( F1= fib(N-1, Depth - 1)<br>                   &<br>                   F2= fib(N-2, Depth-1) & F= F1+F2)<br>      ;<br>      F1= fib(N-1, 0), F2= fib(N-2,0), F= F1+F2)).<br><br>main(!S) :- command_line_arguments(Args, !S),<br>   ( to_int(head(Args), N),<br>     to_int(head(tail(Args)), D) -><br>    F= fib(N, D),<br>    print(F, !S)<br>   print("Usage: ./fibo.x 5", !S)),<br>  nl(!S).<br><br>%% ~/mercuryTutor/mybook$ mmc --parallel \<br>%%     --high-level-code -j8 \<br>%%     --grade=hlc.par.gc fibgc.m -o fib.x<br>   <br></div>I wonder whether somebody in this list could tell me what is going on. By the way, I tried the above program with NAIL Prolog, and it is able to perform the parallelization. I mean, NAIL Prolog does the parallelization, not Mercury. <br></div>
</blockquote></div><br></div>