next_inactive up previous







Computational Logic
Distributed/Internet Programming

LP/CLP, the Internet, and the WWW

LP/CLP, the Internet, and the WWW

Outline

Distributed Teams of Workers (Ciao)

Some Concurrency & Parallelism Operators (Ciao)

Using Basic Concurrency & Parallelism Operators

Using Parallelism: Examples

main :-
        read_input_list(L),
        collect_unloaded_hosts(Hosts),
        add_workers(Hosts, _Ids),
        process_list(L),
        halt.

process_list([]).
process_list([H|T]) :-
        process(H) &
        process_list(T).

add_workers([Host|Hosts],[Id|Ids]) :-
        add_worker(Host,Id),
        add_workers(Hosts,Ids).
add_workers([],[]).

Using Parallelism: Examples

process_list([]).
process_list([H|T]) :-
    ( H < 5 -> 
        process_list(T), process(H) 
    ;   process(H) & process_list(T) ).

Implementation Issues

Communication: Using Blackboards

Producer-Consumer: Linda Version

(using Ciao / SICStus BB primitives)

?- create_bb(B,local), N=10, 
   lproducer(N,B) @ alba &, lconsumer(B).

lproducer(N,B) :-
        lproducer(N,1,B). 

% second argument is message order
lproducer(0,C,B) :- !,
   linda:out(message(end(C)),B).
lproducer(N,C,B) :-
   N>0,
   linda:out(message(C,N),B),
   N1 is N-1,
   C1 is C+1,
   lproducer(N1,C1,B).

Producer-Consumer: Linda Version

lconsumer(B) :- 
   lconsumer(1,B). 

lconsumer(C,B) :-
   linda:rd([message(end(C)),
             message(_,C)], T, B),
   lconsumer_data(T,B).

lconsumer_data(message(end(_)),B).
lconsumer_data(message(N,C),B) :-
   C1 is C+1,
   lconsumer(C1,B).

Implementation Issues

Other Forms of Communication: Shared Variables

A Simple Producer/Consumer Program (using Shared Vars)

go(L) :- 
        share(L),
        consumer(L) &,
        producer(3,L).

producer(0,T) :- !, T = [].
producer(N,T) :- N > 0,
        T = [N|Ns],
        N1 is N-1,
        report(N,produced),
        producer(N1,Ns).

consumer(L) :-
        ask(L=[]), !.
consumer(L) :-
        ask(L=[H|T]),
        report(H,consumed),
        consumer(T).

Implementation Issues

Other Issues

Other Conclusions/Issues

Appendix: The Ciao System and its Libraries

PiLLoW and Other Ciao Libraries

Ciao Compiler Transformations/Optimizations (Source to Source)

Ciao and Other CC Systems

Language Visions?


next_inactive up previous
Last modification: Thu Nov 23 00:04:38 CET 2006 <webmaster@clip.dia.fi.upm.es>[CLIP] [FIM] [UNM]