<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                http://www.mcs.anl.gov/research/projects/mpi/usingmpi2/examples/starting/main.htm 下面只是貼了一個基于MPI-1的靜態版本的文件的broadcast, 文章中還提供了基于MPI-2的動態版本。 另外還有很全面的MPI的文件處理樣式,比如多個node處理同一文件之類的。 master部分的代碼 ~~~ * pcp from SUT, in MPI */ #include "mpi.h" #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define BUFSIZE 256*1024 #define CMDSIZE 80 int main( int argc, char *argv[] ) { int mystatus, allstatus, done, numread; char outfilename[128], controlmsg[80]; int infd, outfd; char buf[BUFSIZE]; MPI_Init( &argc, &argv ); makehostlist( argv[1], "targets" ); strcpy( outfilename, argv[3] ); if ( (infd = open( argv[2], O_RDONLY ) ) == -1 ) { fprintf( stderr, "input file %s does not exist\n", argv[2] ); sprintf( controlmsg, "exit" ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); MPI_Finalize(); return( -1 ); } else { sprintf( controlmsg, "ready" ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); } sprintf( controlmsg, outfilename ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); if ( (outfd = open( outfilename, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU ) ) == -1 ) mystatus = -1; else mystatus = 0; MPI_Allreduce( &mystatus, &allstatus, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD ); if ( allstatus == -1 ) { fprintf( stderr, "output file %s could not be opened\n", outfilename ); MPI_Finalize(); return( -1 ); } /* at this point all files have been successfully opened */ done = 0; while ( !done ) { numread = read( infd, buf, BUFSIZE ); MPI_Bcast( &numread, 1, MPI_INT, 0, MPI_COMM_WORLD ); if ( numread > 0 ) { MPI_Bcast( buf, numread, MPI_BYTE, 0, MPI_COMM_WORLD ); write( outfd, buf, numread ); } else { close( outfd ); done = 1; } } MPI_Finalize(); } int makehostlist( char spec[80], char filename[80] ) { } ~~~ slaver部分的代碼 ~~~ /* pcp from the Scalable Unix Tools, in MPI */ #include "mpi.h" #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define BUFSIZE 256*1024 #define CMDSIZE 80 int main( int argc, char *argv[] ) { int mystatus, allstatus, done, numread; char outfilename[128], controlmsg[80]; int outfd; char buf[BUFSIZE]; MPI_Init( &argc, &argv ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); if ( strcmp( controlmsg, "exit" ) == 0 ) { MPI_Finalize(); return -1; } MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); if ( (outfd = open( controlmsg, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU ) ) == -1 ) mystatus = -1; else mystatus = 0; MPI_Allreduce( &mystatus, &allstatus, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD ); if ( allstatus == -1 ) { MPI_Finalize(); return( -1 ); } /* at this point all files have been successfully opened */ done = 0; while ( !done ) { MPI_Bcast( &numread, 1, MPI_INT, 0, MPI_COMM_WORLD ); if ( numread > 0 ) { MPI_Bcast( buf, numread, MPI_BYTE, 0, MPI_COMM_WORLD ); write( outfd, buf, numread ); } else { close( outfd ); done = 1; } } MPI_Finalize(); } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看