Changeset 5275

Show
Ignore:
Timestamp:
02/03/10 03:10:54 (7 months ago)
Author:
pmoura
Message:

Simplified usage of the "mtbatch" multi-threading benchmarks example by using conditional compilation directives for the Prolog-specific predicates instead of a parametric object.

Location:
trunk
Files:
4 modified

Legend:

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

    r5222 r5275  
    11 
    2 :- object(mtbatch(_Prolog)). 
     2:- object(mtbatch). 
    33 
    44    :- info([ 
    5         version is 1.2, 
     5        version is 1.3, 
    66        author is 'Paulo Moura', 
    7         date is 2008/08/30, 
    8         comment is 'Multi-threading benchmarks.', 
    9         parameters is ['Prolog'- 'Prolog backend compiler. Supported compilers are SWI-Prolog (swi), YAP (yap), and XSB (xsb).']]). 
     7        date is 2010/02/01, 
     8        comment is 'Multi-threading benchmarks. Supports SWI-Prolog, XSB, and YAP.']). 
    109 
    1110    :- threaded. 
     
    490489    do_benchmark(cop_overhead(_, _, _, _), _). 
    491490 
    492     walltime_begin(Walltime) :- 
    493         parameter(1, Prolog), 
    494         walltime_begin(Prolog, Walltime). 
    495  
    496     walltime_begin(swi, Walltime) :- 
    497         get_time(Walltime). 
    498     walltime_begin(yap, 0.0) :- 
    499         statistics(walltime, _). 
    500     walltime_begin(xsb, Walltime) :- 
    501         walltime(Walltime). 
    502  
    503     walltime_end(Walltime) :- 
    504         parameter(1, Prolog), 
    505         walltime_end(Prolog, Walltime). 
    506  
    507     walltime_end(swi, Walltime) :- 
    508         get_time(Walltime). 
    509     walltime_end(yap, Walltime) :- 
    510         statistics(walltime, [_, Time]), 
    511         Walltime is Time / 1000. 
    512     walltime_end(xsb, Walltime) :- 
    513         walltime(Walltime). 
     491    :- if(current_logtalk_flag(prolog_dialect, swi)). 
     492 
     493        walltime_begin(Walltime) :- 
     494            get_time(Walltime). 
     495 
     496        walltime_end(Walltime) :- 
     497            get_time(Walltime). 
     498 
     499        write_average(Average) :- 
     500            put_char('\t'), 
     501            format('~4f', [Average]), 
     502            flush_output. 
     503 
     504    :- elif(current_logtalk_flag(prolog_dialect, yap)). 
     505 
     506        walltime_begin(0.0) :- 
     507            statistics(walltime, _). 
     508 
     509        walltime_end(Walltime) :- 
     510            statistics(walltime, [_, Time]), 
     511            Walltime is Time / 1000. 
     512 
     513        write_average(Average) :- 
     514            put_char('\t'), 
     515            format('~4f', [Average]), 
     516            flush_output. 
     517 
     518    :- elif(current_logtalk_flag(prolog_dialect, xsb)). 
     519 
     520        walltime_begin(Walltime) :- 
     521            walltime(Walltime). 
     522 
     523        walltime_end(xsb, Walltime) :- 
     524            walltime(Walltime). 
     525 
     526        write_average(Average) :- 
     527            put_char('\t'), 
     528            fmt_write("%4f", Average), 
     529            flush_output. 
     530 
     531    :- else. 
     532 
     533        :- initialization(( 
     534            write('Unsupported Prolog compiler for running Logtalk multi-threading features.'), 
     535            halt 
     536        )). 
     537 
     538    :- endif. 
    514539 
    515540    repeat(_). 
     
    519544        repeat(N2). 
    520545 
    521     write_average(Average) :- 
    522         put_char('\t'), 
    523         parameter(1, Prolog), 
    524         write_average(Prolog, Average), 
    525         flush_output. 
    526  
    527     write_average(swi, Average) :- 
    528         format('~6f', [Average]). 
    529     write_average(yap, Average) :- 
    530         format('~6f', [Average]). 
    531     write_average(xsb, Average) :- 
    532         fmt_write("%6f", Average). 
    533  
    534546    write_error :- 
    535547        put_char('\t'), 
    536         write('*error!*'), 
     548        write('error!'), 
    537549        flush_output. 
    538550 
  • trunk/examples/threads/mtbatch/NOTES.txt

    r5274 r5275  
    1212To load this example and for sample queries, please see the SCRIPT.txt file. 
    1313 
    14 This folder provides a parametric object for running multi-threading  
    15 benchmarks. The object parameter must be instantiated with an atom  
    16 representing the back-end Prolog compiler being used: 
     14This folder provides an object for running multi-threading benchmarks. The 
     15supported back-end Prolog compilers are SWI-Prolog, YAP, and XSB. 
    1716 
    18     SWI-Prolog: swi 
    19     YAP:        yap 
    20     XSB:        xsb 
     17For example, the following goal will run all benchmark tests: 
    2118 
    22 This is necessary due to the different built-in predicates used by each  
    23 Prolog compiler for timing statistics. 
    24  
    25 For example, the following goal will run all benchmark tests (assuming  
    26 we're using SWI-Prolog as the back-end compiler): 
    27  
    28     | ?- mtbatch(swi)::run. 
     19    | ?- mtbatch::run. 
    2920 
    3021You may also run just a single benchmark test a given number of times. 
    3122For example: 
    3223 
    33     | ?- mtbatch(swi)::run(primes, 10). 
     24    | ?- mtbatch::run(primes, 10). 
    3425 
    3526The following tests are available: 
  • trunk/examples/threads/mtbatch/SCRIPT.txt

    r5274 r5275  
    1616 
    1717 
    18 % run all tests using SWI-Prolog as the backend compiler: 
     18% run all tests: 
    1919 
    20 ?- mtbatch(swi)::run. 
     20?- mtbatch::run. 
    2121... 
    2222 
    2323 
    24 % run all tests using YAP as the backend compiler: 
     24% run all tests (average of 20 times for each test): 
    2525 
    26 ?- mtbatch(yap)::run(20). 
     26?- mtbatch::run(20). 
    2727... 
    2828 
    2929 
    30 % run the primes benchmark test using XSB as the backend compiler: 
     30% run the primes benchmark test (average of 10 times): 
    3131 
    32 ?- mtbatch(xsb)::run(primes, 10). 
    33 ... 
     32?- mtbatch::run(primes, 10). 
  • trunk/RELEASE_NOTES.txt

    r5273 r5275  
    1515 
    16162.38.3 - February ??, 2010 
     17 
     18    Simplified usage of the "mtbatch" multi-threading benchmarks example 
     19    by using conditional compilation directives for the Prolog-specific 
     20    predicates instead of a parametric object. 
    1721 
    1822    Update the Windows installer script in order to check for the new