As Robby said, the time should only include both place-channel-get and -put calls to make it comparable. But this is not enough, because the (place ...)-creation seems to be non-blocking, i.e they might not be started up yet when the codes reached the first -put.

This can be solved by explicitly synchronizing the places with the main program:

(define (places-main)
    (define place1
       (place ch
              (begin
                (place-channel-put ch #t)
(place-channel-put ch (test-function (place-channel-get ch))))))

    (define place2
        (place ch
               (begin
                 (place-channel-put ch #t)
(place-channel-put ch (test-function (place-channel-get ch))))))

    (place-channel-get place1)
    (place-channel-get place2)

    (display "With places ")
    (time
     (place-channel-put place1 test-vector)
     (place-channel-put place2 test-vector)
     (place-channel-get place1)
     (place-channel-get place2))
    (place-wait place1)
    (place-wait place2)
    (void))


With this i get the following times

With places cpu time: 5600 real time: 3199 gc time: 404
Without places cpu time: 3700 real time: 3678 gc time: 2208

Now its at least faster than the sequential version. But the overhead seems to be still a lot more than i had expected.

Tobias



On Thu, 14 Mar 2013 02:23:22 +0100, Harry Spier <vasishtha.sp...@gmail.com> wrote:

Dear members,

I've run the following racket program  (as an executable) to test the
performance of places on a windows dual core pentium machine under Vista.
I've run this with various sizes for test-vector. Even when the amount of computation is large (test-vector-size = 5000000) the performance with the
computation split over two places takes more than double the time to
complete as when no places are used.

I'm not clear why on a dual core machine the performance wasn't better with
 the computation split over two places than with no places. In fact the
results are the opposite with the performance for no places always double
that for two places.

--------------------------------------
place-timing-test-executable.rkt
---------------------------------------
#lang racket
(require "place-timing-test.rkt")
(printf "test-vector-size ~a" test-vector-size)
(newline)
(display "With places ")
(time (places-main))
(display "Without places ")
(time (noplaces-main))

(system "PAUSE")


-----------------------
place-timing-test.rkt
-----------------------
#lang racket
(provide places-main noplaces-main test-vector-size)
(define test-vector (build-vector 5000000 +))
(define test-vector-size (vector-length test-vector))
(define (test-function vectr) (apply + (vector->list (vector-map sqrt
vectr))))

(define (places-main)
    (define place1
       (place ch (place-channel-put ch (test-function (place-channel-get
ch)))))

    (define place2
        (place ch (place-channel-put ch (test-function (place-channel-get
ch)))))

    (place-channel-put place1 test-vector)
    (place-channel-put place2 test-vector)
    (place-channel-get place1)
    (place-channel-get place2)
    (place-wait place1)
    (place-wait place2)
    (void))

(define (noplaces-main)
    (test-function test-vector)
    (test-function test-vector)
    (void)
-------------------------------

These are the results for different sizes of test-vector.  The amount of
computation is linear to the size of test-vector.

test-vector-size 100000
With places cpu time: 1685 real time: 856 gc time: 0
Without places cpu time: 187 real time: 170 gc time: 94
Press any key to continue . . .
-----
test-vector-size 1000000
With places cpu time: 3822 real time: 2637 gc time: 265
Without places cpu time: 1201 real time: 1191 gc time: 452
Press any key to continue . . .
-------
test-vector-size 5000000
With places cpu time: 15787 real time: 23318 gc time: 1373
Without places cpu time: 7769 real time: 9456 gc time: 4461
Press any key to continue . . .
------

Thanks,
Harry Spier


--
---------------------------------------------------------
Tobias Hammer
DLR / Institute of Robotics and Mechatronics
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.ham...@dlr.de
____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to