source: project/mpi/trunk/tests/run.scm @ 7271

Last change on this file since 7271 was 7271, checked in by Ivan Raikov, 13 years ago

Better send/receive messages

File size: 18.7 KB
Line 
1;;
2;;
3;; Chicken MPI regression test
4;;
5;; Based on the Caml/MPI interface by Xavier Leroy.
6;;
7;; Copyright 2007 Ivan Raikov and the Okinawa Institute of Science and Technology
8;;
9;; This program is free software: you can redistribute it and/or
10;; modify it under the terms of the GNU General Public License as
11;; published by the Free Software Foundation, either version 3 of the
12;; License, or (at your option) any later version.
13;;
14;; This program is distributed in the hope that it will be useful, but
15;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17;; General Public License for more details.
18;;
19;; A full copy of the GPL license can be found at
20;; <http://www.gnu.org/licenses/>.
21;;
22
23(require-extension posix)
24(require-extension srfi-4)
25(require-extension mpi)
26
27(define (make-srfi4-vector-map vlen vset! vref)
28  (lambda (v f)
29    (let loop ((v v) (n (- (vlen v) 1)))
30      (if (>= n 0)
31          (let ((x (f (vref v n))))
32            (vset! v n x)
33            (loop v (- n 1)))))))
34         
35(define-macro (define-srfi4-map type)
36  (let ((vlen    (string->symbol (string-append (symbol->string type) "vector-length")))
37        (vref    (string->symbol (string-append (symbol->string type) "vector-ref")))
38        (vset!   (string->symbol (string-append (symbol->string type) "vector-set!")))
39        (name    (string->symbol (string-append (symbol->string type) "vector-map"))))
40  `(define ,name (make-srfi4-vector-map ,vlen ,vset! ,vref))))
41
42(define-srfi4-map u8)
43(define-srfi4-map s8)
44(define-srfi4-map u16)
45(define-srfi4-map s16)
46(define-srfi4-map u32)
47(define-srfi4-map s32)
48(define-srfi4-map f32)
49(define-srfi4-map f64)
50
51(MPI:init)
52
53(define comm-world  (MPI:get-comm-world))
54(define size        (MPI:comm-size comm-world))
55(define myrank      (MPI:comm-rank comm-world))
56
57;; comm_size, comm_rank
58(define (mpi-test)
59
60  (print myrank ": comm_size = " size)
61
62  ;; Barrier
63  (MPI:barrier comm-world)
64
65  (print "***  Simple send/receive")
66  (if (zero? myrank)
67      (let ((data  "aa"))
68        (print myrank ": sending " data)
69        (MPI:send (string->blob data) 1 0 comm-world)
70        (let ((n (MPI:receive MPI:any-source MPI:any-tag comm-world)))
71          (print myrank ": received " (blob->string n))))
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)))
76  ;; Barrier
77
78  (MPI:barrier comm-world)
79 
80  (print "***  Send and receive with tags")
81  (if (zero? myrank)
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)
88        (let-values (((n src tag)  (MPI:receive-with-status MPI:any-source MPI:any-tag comm-world)))
89          (print myrank ": received " n " (tag " tag ")" " from " src))
90        (let-values (((n src tag)  (MPI:receive-with-status MPI:any-source MPI:any-tag comm-world)))
91          (print myrank ": received " n " (tag " tag ")" " from " src)))
92      (let-values (((n1 src tag1)  (MPI:receive-with-status MPI:any-source 0 comm-world)))
93        (let* ((n1   (blob->string n1))
94               (nn1  (string-append n1 "a")))
95          (print myrank ": received " n1 " (tag " tag1 ")" " from " src
96                 ", resending " nn1)
97          (let-values (((n2 src tag2)  (MPI:receive-with-status MPI:any-source MPI:any-tag comm-world)))
98            (let* ((n2   (blob->string n2))
99                   (nn2  (string-append n2 "b")))
100              (print myrank ": received " n2 " (tag " tag2 ")" " from " src
101                 ", resending " nn2)
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))))))
104  ;; Barrier
105  (MPI:barrier comm-world)
106
107;;   ;; Send and receive base types
108;;   (let ((test-send-recv
109;;       (lambda (sendfun recvfun transf data)
110;;         (if (zero? myrank)
111;;             (begin
112;;               (let loop ((lst data) (i 0))
113;;                 (if (and (not (null? data)) (< i size))
114;;                     (begin
115;;                       (print myrank ": sending " (car data) " to " i)
116;;                       (sendfun (car data) i 0 comm-world)
117;;                       (loop (cdr data) (+ 1 i)))))
118;;               (let loop ((i size))
119;;                 (if (positive? i)
120;;                     (let ((x (recvfun i 0 comm-world)))
121;;                       (print myrank ": received " x)
122;;                       (loop (- i 1))))))
123;;             (let* ((x (recvfun 0 0 comm-world))
124;;                    (y (transf x)))
125;;               (print myrank ": received " x ", sending " y)
126;;               (sendfun y 0 0 comm-world)))))
127;;      )
128;;     (test-send-recv MPI:send-int MPI:receive-int (lambda (x) (+ 1 x))
129;;                  (list 10 20 30 40 50 60 70 80 90))
130;;     (test-send-recv MPI:send-flonum MPI:receive-flonum (lambda (x) (* 2 x))
131;;                  (list 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9))
132;;     (let ((len 3)
133;;        (intdata (list (list 10 11 12) (list 20 21 22) (list 30 31 34) (list 40 41 42)))
134;;        (flodata (list (list 1.1 1.2)  (list 2.1 2.2) (list 3.1 3.2) (list 4.1 4.2)))
135;;        (srfi4-test-send-recv
136;;         (lambda (len vsend vreceive vmap list->vector)
137;;           (lambda (data)
138;;             (test_send_recv vsend (lambda (src tag comm) (vreceive len src tag comm))
139;;                             (lambda (v) (vmap (lambda (x) (+ 1 x)) v))
140;;                             (map list->vector data))))))
141;;       ((srfi4-test-send-recv len MPI:send-u8vector MPI:receive-u8vector u8vector-map list->u8vector)
142;;        intdata)
143;;       ((srfi4-test-send-recv len MPI:send-s8vector MPI:receive-s8vector s8vector-map list->s8vector)
144;;        intdata)
145;;       ((srfi4-test-send-recv len MPI:send-u16vector MPI:receive-u16vector u16vector-map list->u16vector)
146;;        intdata)
147;;       ((srfi4-test-send-recv len MPI:send-s16vector MPI:receive-s16vector s16vector-map list->s16vector)
148;;        intdata)
149;;       ((srfi4-test-send-recv len MPI:send-u32vector MPI:receive-u32vector u32vector-map list->u32vector)
150;;        intdata)
151;;       ((srfi4-test-send-recv len MPI:send-s32vector MPI:receive-s32vector s32vector-map list->s32vector)
152;;        intdata)
153;;       ((srfi4-test-send-recv len MPI:send-f32vector MPI:receive-f32vector f32vector-map list->f32vector)
154;;        flodata)
155;;       ((srfi4-test-send-recv len MPI:send-f64vector MPI:receive-f64vector f64vector-map list->f64vector)
156;;        flodata)))
157
158;;   ;; Barrier
159;;   (MPI:barrier comm-world)
160
161;;   (if (positive? myrank)
162;;       (sleep myrank))
163;;   (print myrank ": hitting barrier")
164;;   (MPI:barrier comm-world)
165;;   (if (zero? myrank)
166;;       (print "jumped barrier"))
167
168;;   ;;  Broadcast
169;;   (let* ((test-broadcast
170;;       (lambda (bcast data)
171;;         (if (zero? myrank)
172;;             (print myrank ": broadcasting " data))
173;;         (let ((res (bcast data 0 comm-world)))
174;;           (print myrank ": received " res)))))
175;;     (test-broadcast MPI:broadcast-bytevector (string->blob "Hello!"))
176;;     (test-broadcast MPI:broadcast-int 123456)
177;;     (test-broadcast MPI:broadcast-flonum 3.141592654)
178;;     (let ((intdata  (list 12 45 78))
179;;        (flodata  (list 3.14 2.718 0.578))
180;;        (srfi4-test-broadcast
181;;         (lambda (bcast list->vector data)
182;;           (test-broadcast bcast (list->vector data)))))
183;;       (test-broadcast MPI:broadcast-s8vector list->s8vector intdata)
184;;       (test-broadcast MPI:broadcast-u8vector list->u8vector intdata)
185;;       (test-broadcast MPI:broadcast-s16vector list->s16vector intdata)
186;;       (test-broadcast MPI:broadcast-u16vector list->u16vector intdata)
187;;       (test-broadcast MPI:broadcast-s32vector list->s32vector intdata)
188;;       (test-broadcast MPI:broadcast-u32vector list->u32vector intdata)
189;;       (test-broadcast MPI:broadcast-f32vector list->f32vector flodata)
190;;       (test-broadcast MPI:broadcast-f64vector list->f64vector flodata)))
191
192;;   ;; Barrier
193;;   (MPI:barrier comm-world)
194
195;;   ;; Scatter
196;;   (let* ((test-scatter
197;;       (lambda (scatter data)
198;;         (if (zero? myrank)
199;;             (print myrank ": scattering " data))
200;;         (let ((res (scatter data 3 0 comm-world)))
201;;           (print myrank ": received " res))
202;;         (MPI:barrier comm-world))))
203;;     (test-scatter MPI:scatter-bytevector (string->blob "aaabbbcccdddeee"))
204;;     (test-scatter MPI:scatter-int (s32vector 12 34 56 78 90))
205;;     (test-scatter MPI:scatter-flonum (s32vector 1.2 3.4 5.6 7.8 9.1))
206;;     (let ((intdata  (list 10 10 10 20 20 20 30 30 30 40 40 40 50 50 50))
207;;        (flodata  (list 1.2 1.2 1.2 3.4 3.4 3.4 3.4 4.5 4.5 4.5 6.7 6.7 6.7))
208;;        (srfi4-test-scatter
209;;         (lambda (scatter list->vector data)
210;;           (test-scatter scatter (list->vector data)))))
211;;       (test-scatter MPI:scatter-s8vector list->s8vector intdata)
212;;       (test-scatter MPI:scatter-u8vector list->u8vector intdata)
213;;       (test-scatter MPI:scatter-s16vector list->s16vector intdata)
214;;       (test-scatter MPI:scatter-u16vector list->u16vector intdata)
215;;       (test-scatter MPI:scatter-s32vector list->s32vector intdata)
216;;       (test-scatter MPI:scatter-u32vector list->u32vector intdata)
217;;       (test-scatter MPI:scatter-f32vector list->f32vector flodata)
218;;       (test-scatter MPI:scatter-f64vector list->f64vector flodata)))
219     
220;;   ;; Gather
221;;   (let* ((test-gather
222;;       (lambda (gather data)
223;;         (print myrank ": sending " data)
224;;         (let ((res (gather data 3 0 comm-world)))
225;;           (if (zero? myrank)
226;;               (print myrank ": gathered " res))
227;;           (MPI:barrier comm-world)))))
228;;     (test-gather MPI:gather-bytevector
229;;               (list-ref (map string->blob (list "aaa" "bbb" "ccc" "ddd" "eee")) myrank))
230;;     (test-gather MPI:gather-int
231;;               (list-ref (list 12 34 56 78 90) myrank))
232;;     (test-gather MPI:gather-flonum
233;;               (list-ref (list 1.2 3.4 5.6 7.8 9.0) myrank))
234;;     (test-gather MPI:gather-s8vector
235;;               (s8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
236;;     (test-gather MPI:gather-u8vector
237;;               (u8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
238;;     (test-gather MPI:gather-s16vector
239;;               (s16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
240;;     (test-gather MPI:gather-u16vector
241;;               (u16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
242;;     (test-gather MPI:gather-s32vector
243;;               (s32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
244;;     (test-gather MPI:gather-u32vector
245;;               (u32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
246;;     (test-gather MPI:gather-f32vector
247;;               (f32vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank))))
248;;     (test-gather MPI:gather-f64vector
249;;               (f64vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank)))))
250
251
252;;   ;; Gather to all
253;;   (let* ((test-allgather
254;;       (lambda (allgather data)
255;;         (print myrank ": sending " data)
256;;         (let ((res (allgather data 0 comm-world)))
257;;           (print myrank ": gathered " res)
258;;           (MPI:barrier comm-world)))))
259;;     (test-allgather MPI:allgather-bytevector
260;;                  (list-ref (map string->blob (list "aaa" "bbb" "ccc" "ddd" "eee")) myrank))
261;;     (test-allgather MPI:allgather-int
262;;                  (list-ref (list 12 34 56 78 90) myrank))
263;;     (test-allgather MPI:allgather-flonum
264;;                  (list-ref (list 1.2 3.4 5.6 7.8 9.0) myrank))
265;;     (test-allgather MPI:allgather-s8vector
266;;                  (s8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
267;;     (test-allgather MPI:allgather-u8vector
268;;                  (u8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
269;;     (test-allgather MPI:allgather-s16vector
270;;                  (s16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
271;;     (test-allgather MPI:allgather-u16vector
272;;                  (u16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
273;;     (test-allgather MPI:allgather-s32vector
274;;                  (s32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
275;;     (test-allgather MPI:allgather-u32vector
276;;                  (u32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
277;;     (test-allgather MPI:allgather-f32vector
278;;                  (f32vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank))))
279;;     (test-allgather MPI:allgather-f64vector
280;;                  (f64vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank)))))
281
282
283;;   ;; Reduce
284
285;;   (let* ((test-reduce
286;;        (lambda (reducefun reduceops data)
287;;          (for-each (lambda (op)
288;;                      (let ((res (reducefun data op 0 comm-world)))
289;;                        (if (zero? myrank)
290;;                            (print myrank ": the result of reduction " op " is " res))))
291;;                    reduceops)
292;;          (MPI:barrier comm-world))))
293;;     (test-reduce MPI:reduce-int
294;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
295;;                     MPI:i_land MPI:i_lor MPI:i_xor)
296;;               (+ 1 myrank))
297;;     (test-reduce MPI:reduce-flonum
298;;               (list MPI:f_max MPI:f_min MPI:f_sum MPI:f_prod )
299;;               (+ 0.1 myrank))
300;;     (test-reduce MPI:reduce-s8vector
301;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
302;;                     MPI:i_land MPI:i_lor MPI:i_xor)
303;;               (s8vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
304;;     (test-reduce MPI:reduce-u8vector
305;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
306;;                     MPI:i_land MPI:i_lor MPI:i_xor)
307;;               (u8vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
308;;     (test-reduce MPI:reduce-s16vector
309;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
310;;                     MPI:i_land MPI:i_lor MPI:i_xor)
311;;               (s16vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
312;;     (test-reduce MPI:reduce-u16vector
313;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
314;;                     MPI:i_land MPI:i_lor MPI:i_xor)
315;;               (u16vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
316;;     (test-reduce MPI:reduce-s32vector
317;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
318;;                     MPI:i_land MPI:i_lor MPI:i_xor)
319;;               (s32vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
320;;     (test-reduce MPI:reduce-u32vector
321;;               (list MPI:i_max MPI:i_min MPI:i_sum MPI:i_prod
322;;                     MPI:i_land MPI:i_lor MPI:i_xor)
323;;               (u32vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
324;;     (test-reduce MPI:reduce-f32vector
325;;               (list MPI:f_max MPI:f_min MPI:f_sum MPI:f_prod )
326;;               (f32vector (* 2 myrank) (+ 0.1 (* 2 myrank)) (+ 0.2 (* 2 myrank))))
327;;     (test-reduce MPI:reduce-f64vector
328;;               (list MPI:f_max MPI:f_min MPI:f_sum MPI:f_prod )
329;;               (f64vector (* 2 myrank) (+ 0.1 (* 2 myrank)) (+ 0.2 (* 2 myrank)))))
330
331;;   ;; Reduce all
332;;   (let* ((test-allreduce
333;;        (lambda (allreducefun reduceop data)
334;;          (print myrank ": data is " data)
335;;          (let ((res (allreducefun data reduceop comm-world)))
336;;            (MPI:barrier comm-world)
337;;            (print myrank ": the result of reduction " op " is " res)
338;;            (MPI:barrier comm-world)))))
339;;     (test-allreduce MPI:allreduce-int MPI:i_sum (+ 1 myrank))
340;;     (test-allreduce MPI:allreduce-flonum MPI:f_prod (+ 1.0 myrank))
341;;     (test-reduce MPI:allreduce-s8vector MPI:i_sum
342;;               (s8vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
343;;     (test-allreduce MPI:allreduce-u8vector MPI:i_sum
344;;                  (u8vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
345;;     (test-allreduce MPI:allreduce-s16vector MPI:i_sum
346;;                  (s16vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
347;;     (test-allreduce MPI:allreduce-u16vector MPI:i_sum
348;;                  (u16vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
349;;     (test-allreduce MPI:allreduce-s32vector MPI:i_sum
350;;                  (s32vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
351;;     (test-allreduce MPI:allreduce-u32vector MPI:i_sum
352;;                  (u32vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
353;;     (test-allreduce MPI:allreduce-f32vector MPI:f_sum 
354;;                  (f32vector (* 2 myrank) (+ 0.1 (* 2 myrank)) (+ 0.2 (* 2 myrank))))
355;;     (test-allreduce MPI:allreduce-f64vector MPI:f_sum 
356;;                  (f64vector (* 2 myrank) (+ 0.1 (* 2 myrank)) (+ 0.2 (* 2 myrank)))))
357   
358;;   ;; Scan
359;;   (let* ((test-scan
360;;        (lambda (scanfun reduceop data)
361;;          (print myrank ": data is " data)
362;;          (let ((res (scanfun data reduceop comm-world)))
363;;            (MPI:barrier comm-world)
364;;            (print myrank ": the result of scan " op " is " res)
365;;            (MPI:barrier comm-world)))))
366;;     (test-scan MPI:scan-int MPI:i_sum (+ 1 myrank))
367;;     (test-scan MPI:scan-flonum MPI:f_prod (+ 1.0 myrank))
368;;     (test-reduce MPI:scan-s8vector MPI:i_sum
369;;               (s8vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
370;;     (test-scan MPI:scan-u8vector MPI:i_sum
371;;             (u8vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
372;;     (test-scan MPI:scan-s16vector MPI:i_sum
373;;             (s16vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
374;;     (test-scan MPI:scan-u16vector MPI:i_sum
375;;             (u16vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
376;;     (test-scan MPI:scan-s32vector MPI:i_sum
377;;             (s32vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
378;;     (test-scan MPI:scan-u32vector MPI:i_sum
379;;             (u32vector (* 2 myrank) (+ 1 (* 2 myrank)) (+ 2 (* 2 myrank))))
380;;     (test-scan MPI:scan-f32vector MPI:f_sum 
381;;             (f32vector (* 2 myrank) (+ 0.1 (* 2 myrank)) (+ 0.2 (* 2 myrank))))
382;;     (test-scan MPI:scan-f64vector MPI:f_sum 
383;;             (f64vector (* 2 myrank) (+ 0.1 (* 2 myrank)) (+ 0.2 (* 2 myrank)))))
384
385;;   ;; Comm split
386;;   (let ((send-in-comm
387;;       (lambda (c init incr)
388;;         (let ((rank-in-c (MPI:comm-rank c))
389;;               (size-of-c (MPI:comm-size c)))
390;;           (if (zero? rank-in-c)
391;;               (begin
392;;                 (print rank-in-c "[" myrank "]: sending " init)
393;;                 (MPI:send init 1 0 c)
394;;                 (let ((n (MPI:receive-bytevector MPI:any-source MPI:any-tag c)))
395;;                   (print rank-in-c "[" myrank "]: received " n)))
396;;               (let ((n (MPI:receive-bytevector MPI:any-source MPI:any-tag c)))
397;;                 (let ((n1 (string->blob (string-append (blob->string n) incr))))
398;;                   (print rank-in-c "[" myrank "]: received " n ", resending " n1)
399;;                   (MPI:send n1 (modulo (+ 1 rank-in-c) size-of-c) 0 c))))))))
400;;     (let ((c (MPI:comm-split comm-world (modulo myrank 2) 0)))
401;;       (if (zero? (modulo myrank 2))
402;;        (send-in-comm c (string->blob "aa") "a")
403;;        (send-in-comm c (string->blob "bb") "b"))
404;;       (MPI:barrier comm-world)))
405
406;;   ;; Cartesian topology
407;;   (let ((cart (MPI:make-cart comm-world (u32vector 2 2) (u32vector 0 0) #t))
408;;      (test-dims-create
409;;       (lambda (n hints)
410;;         (print "make-dims " n " " hints " = " (MPI:make-dims n hints)))))
411;;     (if (zero? myrank)
412;;      (begin
413;;        (print "ranks = " (map (lambda (x) (cons x (MPI:cart-rank cart x)))
414;;                               (u32vector 0 0) (u32vector 1 0)
415;;                               (u32vector 1 0) (u32vector 1 1)))
416;;        (print "coords = " (list-tabulate (MPI:comm-size cart)
417;;                               (lambda (n) (cons n (MPI:cart-coords cart n)))))
418;;        (test-dims-create 60 (u32vector 0 0 0))
419;;        (test-dims-create 60 (u32vector 3 0 0))
420;;        (test-dims-create 60 (u32vector 0 4 0))
421;;        (test-dims-create 60 (u32vector 3 0 5))
422;;        (MPI:barrier comm-world))))
423
424;;   ;; Wtime
425;;   (print myrank ": wtime is "  (MPI:wtime))
426;;   )
427         
428  )
429                                 
430
431
432(mpi-test)
433
Note: See TracBrowser for help on using the repository browser.