Changeset 7283 in project


Ignore:
Timestamp:
01/06/08 07:15:27 (12 years ago)
Author:
Ivan Raikov
Message:

Fixes to scatter/scatterv/gather/gatherv.

Location:
mpi/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mpi/trunk/collcomm.scm

    r7272 r7283  
    4343
    4444
     45(define MPI:broadcast-fixnum
     46    (foreign-primitive scheme-object ((integer data)
     47                                      (integer root)
     48                                      (scheme-object comm))
     49#<<END
     50  C_word result; int n;
     51
     52  MPI_check_comm(comm);
     53
     54  n = data;
     55
     56  printf ("MPI_broadcast_fixnum: before MPI_Bcast: n = %d\n", n);
     57  printf ("MPI_broadcast_fixnum: comm = %p\n", comm);
     58
     59  MPI_Bcast(&n, 1, MPI_INT, root, Comm_val(comm));
     60
     61  printf ("MPI_broadcast_fixnum: after MPI_Bcast: n = %d\n", n);
     62
     63  result = C_fix(n);
     64
     65  C_return(result);
     66END
     67))
     68
     69
    4570(define MPI:broadcast-int
    4671    (foreign-primitive scheme-object ((integer data)
     
    88113#>
    89114
    90 
    91 C_word MPI_broadcast_fixnum (C_word data, C_word root, C_word comm)
    92 {
    93   int n, vroot;
    94 
    95   MPI_check_comm(comm);
    96 
    97   n = C_unfix(data);
     115C_word MPI_broadcast_bytevector(C_word data, C_word root, C_word comm)
     116{
     117  int vroot, len; char *vect;
     118
     119  MPI_check_comm (comm);
     120  C_i_check_bytevector (data);
     121
    98122  vroot = (int)C_num_to_int (root);
    99 
    100   MPI_Bcast(&n, 1, MPI_INT, vroot, Comm_val(comm));
    101 
    102   C_return(C_fix(n));
    103 }
    104 
    105 
    106 C_word MPI_broadcast_bytevector(C_word buffer, C_word root, C_word comm)
    107 {
    108   int vroot;
    109 
    110   MPI_Comm_check (comm);
    111   C_i_check_bytevector (buffer);
    112 
    113   vroot = (int)C_num_to_int (root);
    114 
    115   MPI_Bcast(C_c_bytevector(buffer), C_bytevector_length(buffer), MPI_BYTE,
    116             vroot, Comm_val(comm));
    117 
    118   C_return (buffer);
     123  len   = C_bytevector_length(data);
     124  vect  = C_c_bytevector (data);
     125
     126  MPI_Bcast(vect, len, MPI_BYTE, vroot, Comm_val(comm));
     127
     128  C_return (data);
    119129}
    120130
     
    246256}
    247257<#
    248 
    249 (define MPI:broadcast-fixnum (foreign-lambda scheme-object "MPI_broadcast_fixnum"
    250                                              scheme-object scheme-object scheme-object ))
    251258
    252259(define MPI_broadcast_u8vector (foreign-lambda scheme-object "MPI_broadcast_u8vector"
     
    419426  else
    420427  {
    421     C_i_check_vector (data);
    422428    vdata  = C_c_s32vector(data);
    423429
    424     MPI_Scatter(vdata, 1, MPI_INT, &n, 1, MPI_LONG, root, Comm_val(comm));
     430    MPI_Scatter(vdata, 1, MPI_LONG, &n, 1, MPI_LONG, root, Comm_val(comm));
    425431  }
    426432
     
    449455  else
    450456  {
    451     C_i_check_vector (data);
    452457    vdata  = C_c_f64vector(data);
    453458
     
    471476
    472477  MPI_check_comm(comm);
    473   C_i_check_vector (recv);
     478  C_i_check_bytevector (recv);
    474479
    475480  vroot  = (int)C_num_to_int (root);
     
    500505
    501506  MPI_check_comm(comm);
    502   C_i_check_vector (recv);
    503507
    504508  vroot  = (int)C_num_to_int (root);
     
    527531
    528532  MPI_check_comm(comm);
    529   C_i_check_vector (recv);
    530533
    531534  vroot  = (int)C_num_to_int (root);
     
    555558
    556559  MPI_check_comm(comm);
    557   C_i_check_vector (recv);
    558560
    559561  vroot  = (int)C_num_to_int (root);
     
    582584
    583585  MPI_check_comm(comm);
    584   C_i_check_vector (recv);
    585586
    586587  vroot  = (int)C_num_to_int (root);
     
    610611
    611612  MPI_check_comm(comm);
    612   C_i_check_vector (recv);
    613613
    614614  vroot  = (int)C_num_to_int (root);
     
    637637
    638638  MPI_check_comm(comm);
    639   C_i_check_vector (recv);
    640639
    641640  vroot  = (int)C_num_to_int (root);
     
    665664
    666665  MPI_check_comm(comm);
    667   C_i_check_vector (recv);
    668666
    669667  vroot  = (int)C_num_to_int (root);
     
    693691
    694692  MPI_check_comm(comm);
    695   C_i_check_vector (recv);
    696693
    697694  vroot  = (int)C_num_to_int (root);
     
    720717  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    721718
    722   MPI_Comm_check (comm);
     719  MPI_check_comm (comm);
    723720
    724721  C_i_check_bytevector (recvbuf);
     
    742739
    743740     MPI_counts_displs(len, vsendlengths, vsendcounts, vdispls);
    744  
     741
     742     printf ("scatterv_bytevector: vsendlengths [0] = %d\n", vsendlengths [0]);
     743     printf ("scatterv_bytevector: vsendlengths [1] = %d\n", vsendlengths [1]);
     744     printf ("scatterv_bytevector: vsendcounts [0] = %d\n", vsendcounts [0]);
     745     printf ("scatterv_bytevector: vsendcounts [1] = %d\n", vsendcounts [1]);
     746     printf ("scatterv_bytevector: vdispls [0] = %d\n", vdispls [0]);
     747     printf ("scatterv_bytevector: vdispls [1] = %d\n", vdispls [1]);
     748
    745749     MPI_Scatterv(C_c_bytevector(sendbuf), vsendcounts, vdispls, MPI_BYTE,
    746750                  C_c_bytevector(recvbuf), C_bytevector_length(recvbuf), MPI_BYTE,
     
    759763  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    760764
    761   MPI_Comm_check (comm);
    762 
    763   C_i_check_vector (recvbuf);
     765  MPI_check_comm (comm);
    764766
    765767  vroot = (int)C_num_to_int (root);
     
    794796  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    795797
    796   MPI_Comm_check (comm);
    797 
    798   C_i_check_vector (recvbuf);
     798  MPI_check_comm (comm);
    799799
    800800  vroot = (int)C_num_to_int (root);
     
    831831  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    832832
    833   MPI_Comm_check (comm);
    834 
    835   C_i_check_vector (recvbuf);
     833  MPI_check_comm (comm);
    836834
    837835  vroot = (int)C_num_to_int (root);
     
    866864  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    867865
    868   MPI_Comm_check (comm);
    869 
    870   C_i_check_vector (recvbuf);
     866  MPI_check_comm (comm);
    871867
    872868  vroot = (int)C_num_to_int (root);
     
    903899  int len, vroot; int  *vsendlengths, *vsendcounts, *vdispls;
    904900
    905   MPI_Comm_check (comm);
    906 
    907   C_i_check_vector (recvbuf);
     901  MPI_check_comm (comm);
    908902
    909903  vroot = (int)C_num_to_int (root);
     
    938932  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    939933
    940   MPI_Comm_check (comm);
    941 
    942   C_i_check_vector (recvbuf);
     934  MPI_check_comm (comm);
    943935
    944936  vroot = (int)C_num_to_int (root);
     
    974966  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    975967
    976   MPI_Comm_check (comm);
    977 
    978   C_i_check_vector (recvbuf);
     968  MPI_check_comm (comm);
    979969
    980970  vroot = (int)C_num_to_int (root);
     
    1009999  int len, vroot; int *vsendlengths, *vsendcounts, *vdispls;
    10101000
    1011   MPI_Comm_check (comm);
    1012 
    1013   C_i_check_vector (recvbuf);
     1001  MPI_check_comm (comm);
    10141002
    10151003  vroot = (int)C_num_to_int (root);
     
    11681156                       " data length = " data-len))
    11691157            (let ((sendlengths (map vlen data)))
     1158              (print "scatterv: sendlengths = " sendlengths)
    11701159              ;; Scatter the lengths of the buffers to all the processes
    11711160              (let ((mylen (MPI_scatter_int (list->s32vector sendlengths) root comm)))
     
    11771166                            (dimemcpy sendbuf x len offset)
    11781167                            (+ offset len)))
    1179                         data)
     1168                        0 data)
    11801169                  ;; Allocate receive buffer & compute sendcounts and displs
    11811170                  (let ((myrecv (makev mylen)))
    11821171                    ;; Do the scatter & return received value
    1183                     (scatterv sendbuf sendlengths myrecv root comm
     1172                    (scatterv sendbuf (list->s32vector sendlengths) myrecv root comm
    11841173                              (make-s32vector (length data))
    11851174                              (make-s32vector (length data)))
     
    12341223  else
    12351224  {
    1236     C_i_check_vector (recv);
    12371225    vrecv  = C_c_s32vector(recv);
    1238     rlen   = C_32vector_length (recv);
    1239 
    1240     MPI_Gather(&send, 1, MPI_INT, vrecv, rlen, MPI_INT, root, Comm_val(comm));
     1226
     1227    MPI_Gather(&send, 1, MPI_INT, vrecv, 1, MPI_INT, root, Comm_val(comm));
    12411228    result = recv;
    12421229  }
     
    12651252  else
    12661253  {
    1267     C_i_check_vector (recv);
    12681254    vrecv  = C_c_f64vector(recv);
    12691255    rlen   = C_64vector_length (recv);
     
    13021288    vrecv  = C_c_bytevector(recv);
    13031289    rlen   = C_bytevector_length (recv);
    1304     MPI_Gather(vsend, slen, MPI_BYTE, vrecv, rlen, MPI_BYTE, vroot, Comm_val(comm));
     1290   
     1291    printf ("MPI_gather_bytevector: slen = %d\n", slen);
     1292    printf ("MPI_gather_bytevector: rlen = %d\n", rlen);
     1293
     1294    MPI_Gather(vsend, slen, MPI_BYTE, vrecv, slen, MPI_BYTE, vroot, Comm_val(comm));
     1295
     1296    printf ("MPI_gather_bytevector: vrecv = %s\n", vrecv);
     1297
    13051298    result = recv;
    13061299  }
     
    13171310
    13181311  MPI_check_comm(comm);
    1319   C_i_check_vector (send);
    13201312
    13211313  vroot  = (int)C_num_to_int (root);
     
    13321324    vrecv  = C_c_u8vector(recv);
    13331325    rlen   = C_8vector_length(recv);
    1334     MPI_Gather(vsend, slen, MPI_UNSIGNED_CHAR, vrecv, rlen, MPI_UNSIGNED_CHAR, vroot, Comm_val(comm));
     1326    MPI_Gather(vsend, slen, MPI_UNSIGNED_CHAR, vrecv, slen, MPI_UNSIGNED_CHAR, vroot, Comm_val(comm));
    13351327    result = recv;
    13361328  }
     
    13471339
    13481340  MPI_check_comm(comm);
    1349   C_i_check_vector (send);
    13501341
    13511342  vroot  = (int)C_num_to_int (root);
     
    13621353    vrecv  = C_c_s8vector(recv);
    13631354    rlen   = C_8vector_length(recv);
    1364     MPI_Gather(vsend, slen, MPI_SIGNED_CHAR, vrecv, rlen, MPI_SIGNED_CHAR, vroot, Comm_val(comm));
     1355    MPI_Gather(vsend, slen, MPI_SIGNED_CHAR, vrecv, slen, MPI_SIGNED_CHAR, vroot, Comm_val(comm));
    13651356    result = recv;
    13661357  }
     
    13771368
    13781369  MPI_check_comm(comm);
    1379   C_i_check_vector (send);
    13801370
    13811371  vroot  = (int)C_num_to_int (root);
     
    13921382    vrecv  = C_c_u16vector(recv);
    13931383    rlen   = C_16vector_length(recv);
    1394     MPI_Gather(vsend, slen, MPI_UNSIGNED_SHORT, vrecv, rlen, MPI_UNSIGNED_SHORT, vroot, Comm_val(comm));
     1384    MPI_Gather(vsend, slen, MPI_UNSIGNED_SHORT, vrecv, slen, MPI_UNSIGNED_SHORT, vroot, Comm_val(comm));
    13951385    result = recv; 
    13961386  }
     
    14061396
    14071397  MPI_check_comm(comm);
    1408   C_i_check_vector (send);
    14091398
    14101399  vroot  = (int)C_num_to_int (root);
     
    14211410    vrecv  = C_c_s16vector(recv);
    14221411    rlen   = C_16vector_length(recv);
    1423     MPI_Gather(vsend, slen, MPI_SHORT, vrecv, rlen, MPI_SHORT, vroot, Comm_val(comm));
     1412    MPI_Gather(vsend, slen, MPI_SHORT, vrecv, slen, MPI_SHORT, vroot, Comm_val(comm));
    14241413    result = recv; 
    14251414  }
     
    14361425
    14371426  MPI_check_comm(comm);
    1438   C_i_check_vector (send);
    14391427
    14401428  vroot  = (int)C_num_to_int (root);
     
    14511439    vrecv  = C_c_u32vector(recv);
    14521440    rlen   = C_32vector_length(recv);
    1453     MPI_Gather(vsend, slen, MPI_UNSIGNED, vrecv, rlen, MPI_UNSIGNED, vroot, Comm_val(comm));
     1441    MPI_Gather(vsend, slen, MPI_UNSIGNED, vrecv, slen, MPI_UNSIGNED, vroot, Comm_val(comm));
    14541442    result = recv; 
    14551443  }
     
    14661454
    14671455  MPI_check_comm(comm);
    1468   C_i_check_vector (send);
    14691456
    14701457  vroot  = (int)C_num_to_int (root);
     
    14811468    vrecv  = C_c_s32vector(recv);
    14821469    rlen   = C_32vector_length(recv);
    1483     MPI_Gather(vsend, slen, MPI_INT, vrecv, rlen, MPI_INT, vroot, Comm_val(comm));
     1470    MPI_Gather(vsend, slen, MPI_INT, vrecv, slen, MPI_INT, vroot, Comm_val(comm));
    14841471    result = recv; 
    14851472  }
     
    14961483
    14971484  MPI_check_comm(comm);
    1498   C_i_check_vector (send);
    14991485
    15001486  vroot  = (int)C_num_to_int (root);
     
    15111497    vrecv  = C_c_f32vector(recv);
    15121498    rlen   = C_32vector_length(recv);
    1513     MPI_Gather(vsend, slen, MPI_FLOAT, vrecv, rlen, MPI_FLOAT, vroot, Comm_val(comm));
     1499    MPI_Gather(vsend, slen, MPI_FLOAT, vrecv, slen, MPI_FLOAT, vroot, Comm_val(comm));
    15141500    result = recv; 
    15151501  }
     
    15261512
    15271513  MPI_check_comm(comm);
    1528   C_i_check_vector (send);
    15291514
    15301515  vroot  = (int)C_num_to_int (root);
     
    15411526    vrecv  = C_c_f64vector(recv);
    15421527    rlen   = C_64vector_length(recv);
    1543     MPI_Gather(vsend, slen, MPI_DOUBLE, vrecv, rlen, MPI_DOUBLE, vroot, Comm_val(comm));
     1528    MPI_Gather(vsend, slen, MPI_DOUBLE, vrecv, slen, MPI_DOUBLE, vroot, Comm_val(comm));
    15441529    result = recv; 
    15451530  }
     
    15551540  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    15561541
    1557   MPI_Comm_check (comm);
     1542  MPI_check_comm (comm);
    15581543
    15591544  C_i_check_bytevector (sendbuf);
     
    15931578  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    15941579
    1595   MPI_Comm_check (comm);
    1596 
    1597   C_i_check_vector (sendbuf);
     1580  MPI_check_comm (comm);
    15981581
    15991582  vroot = (int)C_num_to_int (root);
     
    16281611  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    16291612
    1630   MPI_Comm_check (comm);
    1631 
    1632   C_i_check_vector (sendbuf);
     1613  MPI_check_comm (comm);
    16331614
    16341615  vroot = (int)C_num_to_int (root);
     
    16631644  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    16641645
    1665   MPI_Comm_check (comm);
    1666 
    1667   C_i_check_vector (sendbuf);
     1646  MPI_check_comm (comm);
    16681647
    16691648  vroot = (int)C_num_to_int (root);
     
    16981677  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    16991678
    1700   MPI_Comm_check (comm);
    1701 
    1702   C_i_check_vector (sendbuf);
     1679  MPI_check_comm (comm);
    17031680
    17041681  vroot = (int)C_num_to_int (root);
     
    17341711  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    17351712
    1736   MPI_Comm_check (comm);
    1737 
    1738   C_i_check_vector (sendbuf);
     1713  MPI_check_comm (comm);
    17391714
    17401715  vroot = (int)C_num_to_int (root);
     
    17691744  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    17701745
    1771   MPI_Comm_check (comm);
    1772 
    1773   C_i_check_vector (sendbuf);
     1746  MPI_check_comm (comm);
    17741747
    17751748  vroot = (int)C_num_to_int (root);
     
    18051778  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    18061779
    1807   MPI_Comm_check (comm);
    1808 
    1809   C_i_check_vector (sendbuf);
     1780  MPI_check_comm (comm);
    18101781
    18111782  vroot = (int)C_num_to_int (root);
     
    18411812  int len, vroot; int *vrecvlengths, *vrecvcounts, *vdispls;
    18421813
    1843   MPI_Comm_check (comm);
    1844 
    1845   C_i_check_vector (sendbuf);
     1814  MPI_check_comm (comm);
    18461815
    18471816  vroot = (int)C_num_to_int (root);
     
    19111880          ;; receives the data
    19121881          (let ((recv  (make-obj (* nprocs sendcount))))
     1882            (print "gather: recv = " (if (blob? recv) (blob->string recv) recv))
    19131883            (gather v sendcount recv root comm))))))
    19141884
     
    19991969    (let ((myself (MPI:comm-rank comm))
    20001970          (nprocs (MPI:comm-size comm))
    2001           (mylen (length data)))
     1971          (mylen (vlen data)))
     1972      (print "gatherv: data = " data)
     1973      (print "gatherv: mylen = " mylen)
    20021974      (if (= root myself)
    20031975          ;; Gather the lengths of the data from all processes
    20041976          (let ((recvlengths (MPI_gather_int mylen (make-s32vector nprocs) root comm)))
     1977            (print "gatherv: recvlengths = " recvlengths)
    20051978            ;; Allocate receive buffer
    20061979            (let* ((total    (apply + (s32vector->list recvlengths)))
     
    20121985              ;; Build a list of results & return
    20131986              (let loop ((i 0) (offset 0) (lst (list)))
    2014                 (if (<= i nprocs)
     1987                (if (< i nprocs)
    20151988                    (let* ((len   (s32vector-ref recvlengths i))
    20161989                           (vect  (makev len)))
     
    20221995          (let ((ignore (MPI_gather_int mylen (void) root comm)))
    20231996            ;; Send our data
    2024             (gatherv data mylen (void) root comm (void) (void))
     1997            (gatherv data (void) (void) root comm (void) (void))
    20251998            (void))))))
    20261999
     
    20582031  MPI_check_comm(comm);
    20592032
    2060   C_i_check_vector (recv);
    20612033  vrecv  = C_c_s32vector(recv);
    20622034
     
    20782050  MPI_check_comm(comm);
    20792051
    2080   C_i_check_vector (recv);
    20812052  vrecv  = C_c_f64vector(recv);
    20822053
     
    20952066  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    20962067
    2097   MPI_Comm_check (comm);
     2068  MPI_check_comm (comm);
    20982069
    20992070  C_i_check_bytevector (sendbuf);
     
    21202091  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    21212092  char *vsend, *vrecv;
    2122   MPI_Comm_check (comm);
    2123 
    2124   C_i_check_vector (sendbuf);
    2125   C_i_check_vector (recvbuf);
     2093  MPI_check_comm (comm);
    21262094
    21272095  vsend  = C_c_s8vector(sendbuf);
     
    21472115  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    21482116  char *vsend, *vrecv;
    2149   MPI_Comm_check (comm);
    2150 
    2151   C_i_check_vector (sendbuf);
    2152   C_i_check_vector (recvbuf);
     2117  MPI_check_comm (comm);
    21532118
    21542119  vsend  = C_c_u8vector(sendbuf);
     
    21752140  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    21762141  short *vsend, *vrecv;
    2177   MPI_Comm_check (comm);
    2178 
    2179   C_i_check_vector (sendbuf);
    2180   C_i_check_vector (recvbuf);
     2142  MPI_check_comm (comm);
    21812143
    21822144  vsend  = C_c_s16vector(sendbuf);
     
    22032165  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    22042166  unsigned short *vsend, *vrecv;
    2205   MPI_Comm_check (comm);
    2206 
    2207   C_i_check_vector (sendbuf);
    2208   C_i_check_vector (recvbuf);
     2167  MPI_check_comm (comm);
    22092168
    22102169  vsend  = C_c_u16vector(sendbuf);
     
    22322191  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    22332192  int *vsend, *vrecv;
    2234   MPI_Comm_check (comm);
    2235 
    2236   C_i_check_vector (sendbuf);
    2237   C_i_check_vector (recvbuf);
     2193  MPI_check_comm (comm);
    22382194
    22392195  vsend  = C_c_s32vector(sendbuf);
     
    22602216  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    22612217  unsigned int *vsend, *vrecv;
    2262   MPI_Comm_check (comm);
    2263 
    2264   C_i_check_vector (sendbuf);
    2265   C_i_check_vector (recvbuf);
     2218  MPI_check_comm (comm);
    22662219
    22672220  vsend  = C_c_u32vector(sendbuf);
     
    22882241  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    22892242  float *vsend, *vrecv;
    2290   MPI_Comm_check (comm);
    2291 
    2292   C_i_check_vector (sendbuf);
    2293   C_i_check_vector (recvbuf);
     2243  MPI_check_comm (comm);
    22942244
    22952245  vsend  = C_c_f32vector(sendbuf);
     
    23172267  int len; int *vrecvlengths, *vrecvcounts, *vdispls;
    23182268  double *vsend, *vrecv;
    2319   MPI_Comm_check (comm);
    2320 
    2321   C_i_check_vector (sendbuf);
    2322   C_i_check_vector (recvbuf);
     2269  MPI_check_comm (comm);
    23232270
    23242271  vsend  = C_c_f64vector(sendbuf);
     
    25282475  C_word result;
    25292476
    2530   MPI_Comm_check (comm);
    2531 
    2532   C_i_check_vector (data);
     2477  MPI_check_comm (comm);
    25332478
    25342479  vdata  = C_c_s8vector(data);
     
    25602505  C_word result;
    25612506
    2562   MPI_Comm_check (comm);
    2563 
    2564   C_i_check_vector (data);
     2507  MPI_check_comm (comm);
    25652508
    25662509  vdata  = C_c_u8vector(data);
     
    25922535  C_word result;
    25932536
    2594   MPI_Comm_check (comm);
    2595 
    2596   C_i_check_vector (data);
     2537  MPI_check_comm (comm);
    25972538
    25982539  vdata  = C_c_s16vector(data);
     
    26242565  C_word result;
    26252566
    2626   MPI_Comm_check (comm);
    2627 
    2628   C_i_check_vector (data);
     2567  MPI_check_comm (comm);
    26292568
    26302569  vdata  = C_c_u16vector(data);
     
    26562595  C_word result;
    26572596
    2658   MPI_Comm_check (comm);
    2659 
    2660   C_i_check_vector (data);
     2597  MPI_check_comm (comm);
    26612598
    26622599  vdata  = C_c_s32vector(data);
     
    26882625  C_word result;
    26892626
    2690   MPI_Comm_check (comm);
    2691 
    2692   C_i_check_vector (data);
     2627  MPI_check_comm (comm);
    26932628
    26942629  vdata  = C_c_u32vector(data);
     
    27202655  C_word result;
    27212656
    2722   MPI_Comm_check (comm);
    2723 
    2724   C_i_check_vector (data);
     2657  MPI_check_comm (comm);
    27252658
    27262659  vdata  = C_c_f32vector(data);
     
    27522685  C_word result;
    27532686
    2754   MPI_Comm_check (comm);
    2755 
    2756   C_i_check_vector (data);
     2687  MPI_check_comm (comm);
    27572688
    27582689  vdata  = C_c_f64vector(data);
     
    28942825  C_word result;
    28952826
    2896   MPI_Comm_check (comm);
    2897 
    2898   C_i_check_vector (data);
    2899   C_i_check_vector (recv);
     2827  MPI_check_comm (comm);
    29002828
    29012829  vdata  = C_c_s8vector(data);
     
    29172845  C_word result;
    29182846
    2919   MPI_Comm_check (comm);
    2920 
    2921   C_i_check_vector (data);
    2922   C_i_check_vector (recv);
     2847  MPI_check_comm (comm);
    29232848
    29242849  vdata  = C_c_u8vector(data);
     
    29402865  C_word result;
    29412866
    2942   MPI_Comm_check (comm);
    2943 
    2944   C_i_check_vector (data);
    2945   C_i_check_vector (recv);
     2867  MPI_check_comm (comm);
    29462868
    29472869  vdata  = C_c_s16vector(data);
     
    29632885  C_word result;
    29642886
    2965   MPI_Comm_check (comm);
    2966 
    2967   C_i_check_vector (data);
    2968   C_i_check_vector (recv);
     2887  MPI_check_comm (comm);
    29692888
    29702889  vdata  = C_c_u16vector(data);
     
    29862905  C_word result;
    29872906
    2988   MPI_Comm_check (comm);
    2989 
    2990   C_i_check_vector (data);
    2991   C_i_check_vector (recv);
     2907  MPI_check_comm (comm);
    29922908
    29932909  vdata  = C_c_s32vector(data);
     
    30092925  C_word result;
    30102926
    3011   MPI_Comm_check (comm);
    3012 
    3013   C_i_check_vector (data);
    3014   C_i_check_vector (recv);
     2927  MPI_check_comm (comm);
    30152928
    30162929  vdata  = C_c_u32vector(data);
     
    30322945  C_word result;
    30332946
    3034   MPI_Comm_check (comm);
    3035 
    3036   C_i_check_vector (data);
    3037   C_i_check_vector (recv);
     2947  MPI_check_comm (comm);
    30382948
    30392949  vdata  = C_c_f32vector(data);
     
    30552965  C_word result;
    30562966
    3057   MPI_Comm_check (comm);
    3058 
    3059   C_i_check_vector (data);
    3060   C_i_check_vector (recv);
     2967  MPI_check_comm (comm);
    30612968
    30622969  vdata  = C_c_f64vector(data);
     
    31823089  C_word result;
    31833090
    3184   MPI_Comm_check (comm);
    3185 
    3186   C_i_check_vector (data);
    3187   C_i_check_vector (recv);
     3091  MPI_check_comm (comm);
    31883092
    31893093  vdata  = C_c_s8vector(data);
     
    32053109  C_word result;
    32063110
    3207   MPI_Comm_check (comm);
    3208 
    3209   C_i_check_vector (data);
    3210   C_i_check_vector (recv);
     3111  MPI_check_comm (comm);
    32113112
    32123113  vdata  = C_c_u8vector(data);
     
    32283129  C_word result;
    32293130
    3230   MPI_Comm_check (comm);
    3231 
    3232   C_i_check_vector (data);
    3233   C_i_check_vector (recv);
     3131  MPI_check_comm (comm);
    32343132
    32353133  vdata  = C_c_s16vector(data);
     
    32513149  C_word result;
    32523150
    3253   MPI_Comm_check (comm);
    3254 
    3255   C_i_check_vector (data);
    3256   C_i_check_vector (recv);
     3151  MPI_check_comm (comm);
    32573152
    32583153  vdata  = C_c_u16vector(data);
     
    32743169  C_word result;
    32753170
    3276   MPI_Comm_check (comm);
    3277 
    3278   C_i_check_vector (data);
    3279   C_i_check_vector (recv);
     3171  MPI_check_comm (comm);
    32803172
    32813173  vdata  = C_c_s32vector(data);
     
    32973189  C_word result;
    32983190
    3299   MPI_Comm_check (comm);
    3300 
    3301   C_i_check_vector (data);
    3302   C_i_check_vector (recv);
     3191  MPI_check_comm (comm);
    33033192
    33043193  vdata  = C_c_u32vector(data);
     
    33203209  C_word result;
    33213210
    3322   MPI_Comm_check (comm);
    3323 
    3324   C_i_check_vector (data);
    3325   C_i_check_vector (recv);
     3211  MPI_check_comm (comm);
    33263212
    33273213  vdata  = C_c_f32vector(data);
     
    33433229  C_word result;
    33443230
    3345   MPI_Comm_check (comm);
    3346 
    3347   C_i_check_vector (data);
    3348   C_i_check_vector (recv);
     3231  MPI_check_comm (comm);
    33493232
    33503233  vdata  = C_c_f64vector(data);
  • mpi/trunk/comm.scm

    r7267 r7283  
    4242static C_word MPI_check_comm (C_word obj)
    4343{
     44  printf ("MPI_check_comm: obj = %p\n", obj);
    4445  if (C_immediatep(obj))
    4546  {
  • mpi/trunk/mpi.scm

    r7272 r7283  
    2626(declare (export MPI:barrier
    2727                 MPI:broadcast-int
     28                 MPI:scatter-int
     29                 MPI:gather-int
    2830                 MPI:broadcast-flonum
     31                 MPI:scatter-flonum
     32                 MPI:gather-flonum
    2933                 MPI:broadcast-fixnum
    3034
  • mpi/trunk/msgs.scm

    r7272 r7283  
    447447  printf ("MPI_receive_u8vector: vect[2] = %d\n", vect[2]);
    448448
    449   MPI_Recv(vect, len, MPI_BYTE, vsource, vtag, Comm_val(comm), MPI_STATUS_IGNORE);
     449  MPI_Recv(vect, len, MPI_UNSIGNED_CHAR, vsource, vtag, Comm_val(comm), MPI_STATUS_IGNORE);
    450450
    451451  printf ("MPI:receive_u8vector: after MPI_Recv\n");
  • mpi/trunk/tests/run.scm

    r7272 r7283  
    168168      ))
    169169
    170 ;;   (if (positive? myrank)
    171 ;;       (sleep myrank))
    172 ;;   (print myrank ": hitting barrier")
    173 ;;   (MPI:barrier comm-world)
    174 ;;   (if (zero? myrank)
    175 ;;       (print "jumped barrier"))
    176 
    177 ;;   ;;  Broadcast
    178 ;;   (let* ((test-broadcast
    179 ;;       (lambda (bcast data)
    180 ;;         (if (zero? myrank)
    181 ;;             (print myrank ": broadcasting " data))
    182 ;;         (let ((res (bcast data 0 comm-world)))
    183 ;;           (print myrank ": received " res)))))
    184 ;;     (test-broadcast MPI:broadcast-bytevector (string->blob "Hello!"))
    185 ;;     (test-broadcast MPI:broadcast-int 123456)
    186 ;;     (test-broadcast MPI:broadcast-flonum 3.141592654)
    187 ;;     (let ((intdata  (list 12 45 78))
    188 ;;        (flodata  (list 3.14 2.718 0.578))
    189 ;;        (srfi4-test-broadcast
    190 ;;         (lambda (bcast list->vector data)
    191 ;;           (test-broadcast bcast (list->vector data)))))
    192 ;;       (test-broadcast MPI:broadcast-s8vector list->s8vector intdata)
    193 ;;       (test-broadcast MPI:broadcast-u8vector list->u8vector intdata)
    194 ;;       (test-broadcast MPI:broadcast-s16vector list->s16vector intdata)
    195 ;;       (test-broadcast MPI:broadcast-u16vector list->u16vector intdata)
    196 ;;       (test-broadcast MPI:broadcast-s32vector list->s32vector intdata)
    197 ;;       (test-broadcast MPI:broadcast-u32vector list->u32vector intdata)
    198 ;;       (test-broadcast MPI:broadcast-f32vector list->f32vector flodata)
    199 ;;       (test-broadcast MPI:broadcast-f64vector list->f64vector flodata)))
    200 
    201 ;;   ;; Barrier
    202 ;;   (MPI:barrier comm-world)
    203 
    204 ;;   ;; Scatter
    205 ;;   (let* ((test-scatter
    206 ;;       (lambda (scatter data)
    207 ;;         (if (zero? myrank)
    208 ;;             (print myrank ": scattering " data))
    209 ;;         (let ((res (scatter data 3 0 comm-world)))
    210 ;;           (print myrank ": received " res))
    211 ;;         (MPI:barrier comm-world))))
    212 ;;     (test-scatter MPI:scatter-bytevector (string->blob "aaabbbcccdddeee"))
    213 ;;     (test-scatter MPI:scatter-int (s32vector 12 34 56 78 90))
    214 ;;     (test-scatter MPI:scatter-flonum (s32vector 1.2 3.4 5.6 7.8 9.1))
    215 ;;     (let ((intdata  (list 10 10 10 20 20 20 30 30 30 40 40 40 50 50 50))
    216 ;;        (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))
    217 ;;        (srfi4-test-scatter
    218 ;;         (lambda (scatter list->vector data)
    219 ;;           (test-scatter scatter (list->vector data)))))
    220 ;;       (test-scatter MPI:scatter-s8vector list->s8vector intdata)
    221 ;;       (test-scatter MPI:scatter-u8vector list->u8vector intdata)
    222 ;;       (test-scatter MPI:scatter-s16vector list->s16vector intdata)
    223 ;;       (test-scatter MPI:scatter-u16vector list->u16vector intdata)
    224 ;;       (test-scatter MPI:scatter-s32vector list->s32vector intdata)
    225 ;;       (test-scatter MPI:scatter-u32vector list->u32vector intdata)
    226 ;;       (test-scatter MPI:scatter-f32vector list->f32vector flodata)
    227 ;;       (test-scatter MPI:scatter-f64vector list->f64vector flodata)))
     170  (if (positive? myrank)
     171      (sleep myrank))
     172  (print myrank ": hitting barrier")
     173  (MPI:barrier comm-world)
     174  (if (zero? myrank)
     175      (print "jumped barrier"))
     176
     177  ;;  Broadcast
     178  (let* ((test-broadcast
     179          (lambda (bcast data)
     180           (if (zero? myrank)
     181               (print myrank ": broadcasting " data))
     182           (let ((res (bcast data 0 comm-world)))
     183             (print myrank ": received " (if (blob? res) (blob->string res) res)))
     184           (MPI:barrier comm-world))))
     185    (test-broadcast MPI:broadcast-bytevector (string->blob "Hello!"))
     186    (test-broadcast MPI:broadcast-int 123456)
     187    (test-broadcast MPI:broadcast-flonum 3.141592654)
     188    (let ((intdata  (list 12 45 78))
     189          (flodata  (list 3.14 2.718 0.578))
     190          (srfi4-test-broadcast
     191           (lambda (bcast list->vector data)
     192             (test-broadcast bcast (list->vector data)))))
     193      (srfi4-test-broadcast MPI:broadcast-s8vector list->s8vector intdata)
     194      (srfi4-test-broadcast MPI:broadcast-u8vector list->u8vector intdata)
     195      (srfi4-test-broadcast MPI:broadcast-s16vector list->s16vector intdata)
     196      (srfi4-test-broadcast MPI:broadcast-u16vector list->u16vector intdata)
     197      (srfi4-test-broadcast MPI:broadcast-s32vector list->s32vector intdata)
     198      (srfi4-test-broadcast MPI:broadcast-u32vector list->u32vector intdata)
     199      (srfi4-test-broadcast MPI:broadcast-f32vector list->f32vector flodata)
     200      (srfi4-test-broadcast MPI:broadcast-f64vector list->f64vector flodata)))
     201
     202  ;; Scatter
     203  (let* ((test-scatter
     204         (lambda (scatter data)
     205           (if (zero? myrank)
     206               (print myrank ": scatter " data))
     207           (let ((res (scatter data 3 0 comm-world)))
     208             (print myrank ": received (scatter) " (if (blob? res) (blob->string res) res)))
     209           (MPI:barrier comm-world))))
     210    (test-scatter MPI:scatter-bytevector (string->blob "aaabbbcccdddeeefffggghhh"))
     211    (let ((intdata  (list 10 10 10 20 20 20 30 30 30 40 40 40 50 50 50 60 60 60 70 70 70 80 80 80))
     212          (flodata  (list 1.2 1.2 1.2 2.3 2.3 2.3 3.4 3.4 3.4 4.5 4.5 4.5 5.6 5.6 5.6 6.7 6.7 6.7
     213                          7.8 7.8 7.8 8.9 8.9 8.9 ))
     214          (srfi4-test-scatter
     215           (lambda (scatter list->vector data)
     216             (test-scatter scatter (list->vector data)))))
     217      (srfi4-test-scatter MPI:scatter-s8vector list->s8vector intdata)
     218      (srfi4-test-scatter MPI:scatter-u8vector list->u8vector intdata)
     219      (srfi4-test-scatter MPI:scatter-s16vector list->s16vector intdata)
     220      (srfi4-test-scatter MPI:scatter-u16vector list->u16vector intdata)
     221      (srfi4-test-scatter MPI:scatter-s32vector list->s32vector intdata)
     222      (srfi4-test-scatter MPI:scatter-u32vector list->u32vector intdata)
     223      (srfi4-test-scatter MPI:scatter-f32vector list->f32vector flodata)
     224      (srfi4-test-scatter MPI:scatter-f64vector list->f64vector flodata)))
    228225     
    229 ;;   ;; Gather
    230 ;;   (let* ((test-gather
    231 ;;       (lambda (gather data)
    232 ;;         (print myrank ": sending " data)
    233 ;;         (let ((res (gather data 3 0 comm-world)))
    234 ;;           (if (zero? myrank)
    235 ;;               (print myrank ": gathered " res))
    236 ;;           (MPI:barrier comm-world)))))
    237 ;;     (test-gather MPI:gather-bytevector
    238 ;;               (list-ref (map string->blob (list "aaa" "bbb" "ccc" "ddd" "eee")) myrank))
    239 ;;     (test-gather MPI:gather-int
    240 ;;               (list-ref (list 12 34 56 78 90) myrank))
    241 ;;     (test-gather MPI:gather-flonum
    242 ;;               (list-ref (list 1.2 3.4 5.6 7.8 9.0) myrank))
    243 ;;     (test-gather MPI:gather-s8vector
    244 ;;               (s8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
    245 ;;     (test-gather MPI:gather-u8vector
    246 ;;               (u8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
    247 ;;     (test-gather MPI:gather-s16vector
    248 ;;               (s16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
    249 ;;     (test-gather MPI:gather-u16vector
    250 ;;               (u16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
    251 ;;     (test-gather MPI:gather-s32vector
    252 ;;               (s32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
    253 ;;     (test-gather MPI:gather-u32vector
    254 ;;               (u32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
    255 ;;     (test-gather MPI:gather-f32vector
    256 ;;               (f32vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank))))
    257 ;;     (test-gather MPI:gather-f64vector
    258 ;;               (f64vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank)))))
    259 
     226  ;; Scatterv
     227  (let* ((test-scatterv
     228         (lambda (scatterv data)
     229           (if (zero? myrank)
     230               (print myrank ": scatterv " data))
     231           (let ((res (scatterv data 0 comm-world)))
     232             (print myrank ": received (scatterv) " (if (blob? res) (blob->string res) res)))
     233           (MPI:barrier comm-world))))
     234    (test-scatterv MPI:scatterv-bytevector
     235                   (map string->blob (take (list "a" "bb" "ccc" "dddd" "eeeee"
     236                                                 "ffffff" "ggggggg" "hhhhhhhh")
     237                                           size)))
     238     (let ((intdata  (take (list (list 10) (list 20 20) (list 30 30 30) (list 40 40 40 40) (list 50 50 50 50 50)
     239                                 (list 60 60 60 60 60 60) (list 70 70 70 70 70 70 70)
     240                                 (list 80 80 80 80 80 80 80))
     241                           size))
     242          (flodata  (take (list (list 1.2) (list 2.3 2.3) (list 3.4 3.4 3.4) (list 4.5 4.5 4.5 4.5)
     243                                (list 5.6 5.6 5.6 5.6 5.6) (list 6.7 6.7 6.7 6.7 6.7 6.7)
     244                                (list 7.8 7.8 7.8 7.8 7.8 7.8 7.8) (list 8.9 8.9 8.9 8.9 8.9 8.9 8.9 8.9))
     245                          size))
     246          (srfi4-test-scatterv
     247           (lambda (scatterv list->vector data)
     248             (test-scatterv scatterv (map list->vector data)))))
     249       (srfi4-test-scatterv MPI:scatterv-s8vector list->s8vector intdata)
     250       (srfi4-test-scatterv MPI:scatterv-u8vector list->u8vector intdata)
     251       (srfi4-test-scatterv MPI:scatterv-s16vector list->s16vector intdata)
     252       (srfi4-test-scatterv MPI:scatterv-u16vector list->u16vector intdata)
     253       (srfi4-test-scatterv MPI:scatterv-s32vector list->s32vector intdata)
     254       (srfi4-test-scatterv MPI:scatterv-u32vector list->u32vector intdata)
     255       (srfi4-test-scatterv MPI:scatterv-f32vector list->f32vector flodata)
     256       (srfi4-test-scatterv MPI:scatterv-f64vector list->f64vector flodata)))
     257
     258  ;; Gather
     259   (let* ((test-gather    (lambda (gather data)
     260            (print myrank ": gather " (if (blob? data) (blob->string data) data))
     261            (let ((res (gather data 3 0 comm-world)))
     262              (if (zero? myrank)
     263                  (print myrank ": gathered " (if (blob? res) (blob->string res) res)))
     264              (MPI:barrier comm-world)))))
     265     (test-gather MPI:gather-bytevector
     266                 (list-ref (map string->blob (list "aaa" "bbb" "ccc" "ddd" "eee" "fff" "ggg" "hhh")) myrank))
     267     (test-gather MPI:gather-s8vector
     268                 (s8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
     269     (test-gather MPI:gather-u8vector
     270                 (u8vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
     271     (test-gather MPI:gather-s16vector
     272                 (s16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
     273     (test-gather MPI:gather-u16vector
     274                 (u16vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
     275     (test-gather MPI:gather-s32vector
     276                 (s32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
     277     (test-gather MPI:gather-u32vector
     278                 (u32vector (* 10 myrank) (+ 1 (* 10 myrank)) (+ 2 (* 10 myrank))))
     279     (test-gather MPI:gather-f32vector
     280                 (f32vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank))))
     281     (test-gather MPI:gather-f64vector
     282                 (f64vector (* 10 myrank) (+ 0.1 (* 10 myrank)) (+ 0.2 (* 10 myrank)))))
     283
     284  ;; Gatherv
     285   (let* ((test-gatherv
     286           (lambda (gatherv data)
     287             (print myrank ": gatherv " (if (blob? data) (blob->string data) data))
     288             (let ((res (gatherv data 0 comm-world)))
     289               (if (zero? myrank)
     290                   (print myrank ": gathered (from gatherv) "
     291                          (map (lambda (x) (if (blob? x) (blob->string x) x)) res)))
     292               (MPI:barrier comm-world)))))
     293     (test-gatherv MPI:gatherv-bytevector
     294                   (list-ref (map string->blob (list "a" "bb" "ccc" "dddd" "eeeee" "ffffff" "ggggggg" "hhhhhhhh"))
     295                             myrank))
     296     (test-gatherv MPI:gatherv-s8vector   
     297                   (list->s8vector  (list-tabulate (+ 1 myrank)  (lambda (i) (+ i (* 10 myrank))))))
     298     (test-gatherv MPI:gatherv-u8vector   
     299                   (list->u8vector  (list-tabulate (+ 1 myrank)  (lambda (i) (+ i (* 10 myrank))))))
     300     (test-gatherv MPI:gatherv-s16vector 
     301                   (list->s16vector (list-tabulate (+ 1 myrank)  (lambda (i) (+ i (* 10 myrank))))))
     302     (test-gatherv MPI:gatherv-u16vector 
     303                   (list->u16vector (list-tabulate (+ 1 myrank)  (lambda (i) (+ i (* 10 myrank))))))
     304     (test-gatherv MPI:gatherv-s32vector 
     305                   (list->s32vector (list-tabulate (+ 1 myrank)  (lambda (i) (+ i (* 10 myrank))))))
     306     (test-gatherv MPI:gatherv-u32vector 
     307                   (list->u32vector (list-tabulate (+ 1 myrank)  (lambda (i) (+ i (* 10 myrank))))))
     308     (test-gatherv MPI:gatherv-f32vector 
     309                   (list->f32vector (list-tabulate (+ 1 myrank)  (lambda (i) (+ (* 0.1 i) (* 10 myrank))))))
     310     (test-gatherv MPI:gatherv-f64vector 
     311                   (list->f64vector (list-tabulate (+ 1 myrank)  (lambda (i) (+ (* 0.1 i) (* 10 myrank)))))))
    260312
    261313;;   ;; Gather to all
Note: See TracChangeset for help on using the changeset viewer.