Changeset 4311

Show
Ignore:
Timestamp:
06/13/08 04:04:50 (4 months ago)
Author:
pmoura
Message:

Updated the "mtbatch" example to include a benchmark test for competitive or-parallelism applied to state-space search (using the resources from the "searching" example). Improved the example documentation.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/threads/mtbatch/loader.lgt

    r4138 r4311  
    1010    logtalk_load(fft(loader)), 
    1111    logtalk_load(integration(loader)), 
     12    logtalk_load(roots(loader), [reload(skip)]), 
     13    logtalk_load([ 
     14        searching(state_space), 
     15        searching(heuristic_state_space), 
     16        searching(salt3), 
     17        searching(search_strategy), 
     18        searching(blind_search1), 
     19        searching(breadth_first1), 
     20        searching(depth_first1), 
     21        searching(heuristic_search1), 
     22        searching(best_first1), 
     23        searching(hill_climbing1)], [reload(skip)]), 
    1224    logtalk_load(mtbatch, [misspelt(silent)]) 
    1325    )).  
  • trunk/examples/threads/mtbatch/mtbatch.lgt

    r4182 r4311  
    88        comment is 'Multi-threading benchmarks.', 
    99        parameters is ['Prolog'- 'Prolog backend compiler. Supported compilers are SWI-Prolog (swi), YAP (yap), and XSB (xsb).']]). 
     10 
     11    :- threaded. 
    1012 
    1113    :- uses(integer, [between/3]). 
     
    173175                    )), nl 
    174176            )), nl. 
    175  
    176177 
    177178    % integration benchmarks: 
     
    236237            )), nl. 
    237238 
     239    % state-space search benchmarks: 
     240    run(search, N) :- 
     241        write('State-space search benchmarks (average of '), write(N), write(' runs)'), nl, 
     242        loop::forto(Liters, 1, 14, 
     243            (   put_char('\t'), write(Liters) 
     244            )), nl, 
     245        write('DF'), put_char('\t'), 
     246        loop::forto(Liters, 1, 14, 
     247            (   catch(run(depth_first(Liters, 5, 9, 14), N, Average), Error, write_error) -> 
     248                (   var(Error) -> 
     249                    write_average(Average) 
     250                ;   true 
     251                ) 
     252            )), nl, 
     253        write('HF'), put_char('\t'), 
     254        loop::forto(Liters, 1, 14, 
     255            (   catch(run(hill_climbing(Liters, 5, 9, 14), N, Average), Error, write_error) -> 
     256                (   var(Error) -> 
     257                    write_average(Average) 
     258                ;   true 
     259                ) 
     260            )), nl, 
     261        write('BF'), put_char('\t'), 
     262        loop::forto(Liters, 1, 14, 
     263            (   catch(run(breadth_first(Liters, 5, 9, 14), N, Average), Error, write_error) -> 
     264                (   var(Error) -> 
     265                    write_average(Average) 
     266                ;   true 
     267                ) 
     268            )), nl, 
     269        write('COP'), put_char('\t'), 
     270        loop::forto(Liters, 1, 14, 
     271            (   catch(run(competitive(Liters, 5, 9, 14), N, Average), Error, write_error) -> 
     272                (   var(Error) -> 
     273                    write_average(Average) 
     274                ;   true 
     275                ) 
     276            )), nl. 
     277 
    238278    run(Id, N, Average) :- 
    239279        walltime_begin(Walltime1), 
     
    309349    do_benchmark(quadsplit(_, _, _, _, _), _). 
    310350 
     351    do_benchmark(depth_first(Liters, Jug1, Jug2, MaxDepth), N) :- 
     352        Obj = salt(Liters, Jug1, Jug2), 
     353        Obj::initial_state(Initial), 
     354        repeat(N), 
     355            once(depth_first(MaxDepth)::solve(Obj, Initial, _)), 
     356        fail. 
     357    do_benchmark(depth_first(_, _, _, _), _). 
     358 
     359    do_benchmark(hill_climbing(Liters, Jug1, Jug2, MaxDepth), N) :- 
     360        Obj = salt(Liters, Jug1, Jug2), 
     361        Obj::initial_state(Initial), 
     362        repeat(N), 
     363            once(hill_climbing(MaxDepth)::solve(Obj, Initial, _, _)), 
     364        fail. 
     365    do_benchmark(hill_climbing(_, _, _, _), _). 
     366 
     367    do_benchmark(breadth_first(Liters, Jug1, Jug2, MaxDepth), N) :- 
     368        Obj = salt(Liters, Jug1, Jug2), 
     369        Obj::initial_state(Initial), 
     370        repeat(N), 
     371            once(breadth_first(MaxDepth)::solve(Obj, Initial, _)), 
     372        fail. 
     373    do_benchmark(breadth_first(_, _, _, _), _). 
     374 
     375    do_benchmark(competitive(Liters, Jug1, Jug2, MaxDepth), N) :- 
     376        Obj = salt(Liters, Jug1, Jug2), 
     377        Obj::initial_state(Initial), 
     378        repeat(N), 
     379            threaded(( 
     380                    depth_first(MaxDepth)::solve(Obj, Initial, _) 
     381                ;   hill_climbing(MaxDepth)::solve(Obj, Initial, _, _) 
     382                ;   breadth_first(MaxDepth)::solve(Obj, Initial, _) 
     383            )), 
     384        fail. 
     385    do_benchmark(competitive(_, _, _, _), _). 
     386 
    311387    walltime_begin(Walltime) :- 
    312388        parameter(1, Prolog), 
  • trunk/examples/threads/mtbatch/NOTES.txt

    r4297 r4311  
    99To load this example and for sample queries, please see the SCRIPT file. 
    1010 
    11 This folder provides an object for running multi-threading benchmarks. 
     11This folder provides a parametric object for running multi-threading  
     12benchmarks. The object parameter must be instantiated with an atom  
     13representing the back-end Prolog compiler being used: 
     14 
     15    SWI-Prolog: swi 
     16    YAP:        yap 
     17    XSB:        xsb 
     18 
     19This is necessary due to the different built-in predicates used by each  
     20Prolog compiler for timing statistics. 
     21 
     22For example, the following goal will run all benchmark tests (assuming  
     23we're using SWI-Prolog as the back-end compiler): 
     24 
     25    | ?- mtbatch(swi)::run. 
     26 
     27You may also run just a single benchmark test a given number of times. 
     28For example: 
     29 
     30    | ?- mtbatch(swi)::run(primes, 10). 
     31 
     32The following tests are available: 
     33 
     34    primes 
     35    msort 
     36    qsort 
     37    fib 
     38    hanoi 
     39    tak 
     40    fft 
     41    integration 
     42    search 
  • trunk/RELEASE_NOTES.txt

    r4308 r4311  
    4949    taken into account when comparing states). Updated the "salt" example  
    5050    to support heuristics. 
     51 
     52    Updated the "mtbatch" example to include a benchmark test for competitive  
     53    or-parallelism applied to state-space search (using the resources from the 
     54    "searching" example). Improved the example documentation. 
    5155 
    5256    Updated the syntax coloring support for the Vim text editor to properly