Changeset 7271 in project


Ignore:
Timestamp:
01/05/08 13:23:01 (12 years ago)
Author:
iraikov
Message:

Better send/receive messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mpi/trunk/tests/run.scm

    r7270 r7271  
    6262  ;; Barrier
    6363  (MPI:barrier comm-world)
    64  
    65   ;; Simple send/receive
     64
     65  (print "***  Simple send/receive")
    6666  (if (zero? myrank)
    67       (let ((data  (string->blob "aa")))
    68         (print myrank ": sending " (blob->string data))
    69         (MPI:send data 1 0 comm-world)
     67      (let ((data  "aa"))
     68        (print myrank ": sending " data)
     69        (MPI:send (string->blob data) 1 0 comm-world)
    7070        (let ((n (MPI:receive MPI:any-source MPI:any-tag comm-world)))
    7171          (print myrank ": received " (blob->string n))))
    72       (let* ((n   (MPI:receive MPI:any-source MPI:any-tag comm-world))
    73              (n1  (string->blob (string-append (blob->string n) "a"))))
    74         (print myrank ": received " (blob->string n) ", resending " (blob->string n1))
    75         (MPI:send n1 (modulo (+ myrank 1) size) 0 comm-world)))
     72      (let* ((n   (blob->string (MPI:receive MPI:any-source MPI:any-tag comm-world)))
     73             (n1  (string-append n "a")))
     74        (print myrank ": received " n ", resending " n1)
     75        (MPI:send (string->blob n1) (modulo (+ myrank 1) size) 0 comm-world)))
    7676  ;; Barrier
     77
    7778  (MPI:barrier comm-world)
    7879 
    79   ;; Send and receive with tags
     80  (print "***  Send and receive with tags")
    8081  (if (zero? myrank)
    81       (let ((data1  (string->blob "aa"))
    82             (data2  (string->blob "bb")))
    83         (print myrank ": sending (tag 0) " data )
    84         (MPI:send data1 1 0 comm-world)
    85         (print myrank ": sending (tag 1) " data )
    86         (MPI:send data2 1 1 comm-world)
     82      (let ((data1  "aa")
     83            (data2  "bb"))
     84        (print myrank ": sending (tag 0) " data1)
     85        (MPI:send (string->blob data1) 1 0 comm-world)
     86        (print myrank ": sending (tag 1) " data2)
     87        (MPI:send (string->blob data2) 1 1 comm-world)
    8788        (let-values (((n src tag)  (MPI:receive-with-status MPI:any-source MPI:any-tag comm-world)))
    8889          (print myrank ": received " n " (tag " tag ")" " from " src))
     
    9091          (print myrank ": received " n " (tag " tag ")" " from " src)))
    9192      (let-values (((n1 src tag1)  (MPI:receive-with-status MPI:any-source 0 comm-world)))
    92         (let ((nn1  (string->blob (string-append (blob->string n1) "a"))))
     93        (let* ((n1   (blob->string n1))
     94               (nn1  (string-append n1 "a")))
    9395          (print myrank ": received " n1 " (tag " tag1 ")" " from " src
    9496                 ", resending " nn1)
    9597          (let-values (((n2 src tag2)  (MPI:receive-with-status MPI:any-source MPI:any-tag comm-world)))
    96             (let ((nn2  (string->blob (string-append (blob->string n2) "b"))))
     98            (let* ((n2   (blob->string n2))
     99                   (nn2  (string-append n2 "b")))
    97100              (print myrank ": received " n2 " (tag " tag2 ")" " from " src
    98101                 ", resending " nn2)
    99               (MPI:send nn1 (modulo (+ 1 myrank) size) 1 comm-world))
    100             (MPI:send nn2 (modulo (+ 1 myrank) size) 0 comm-world)))))
     102              (MPI:send (string->blob nn1) (modulo (+ 1 myrank) size) 1 comm-world)
     103              (MPI:send (string->blob nn2) (modulo (+ 1 myrank) size) 0 comm-world))))))
    101104  ;; Barrier
    102105  (MPI:barrier comm-world)
Note: See TracChangeset for help on using the changeset viewer.