| 67 | * 用 mpdringtest 做 mpd 訊息傳遞效能測試 |
| 68 | {{{ |
| 69 | ym24@bio002:~$ mpdringtest 1000 |
| 70 | time for 1000 loops = 1.07995414734 seconds |
| 71 | }}} |
| 72 | * 用 mpiexec 執行 cpi 範例程式 |
| 73 | {{{ |
| 74 | ym24@bio001:~$ mpiexec -n 3 /opt/mpich2/share/mpich2/examples/cpi |
| 75 | Process 0 of 1 is on bio001 |
| 76 | pi is approximately 3.1415926544231341, Error is 0.0000000008333410 |
| 77 | wall clock time = 0.000295 |
| 78 | Process 0 of 1 is on bio001 |
| 79 | pi is approximately 3.1415926544231341, Error is 0.0000000008333410 |
| 80 | wall clock time = 0.000287 |
| 81 | Process 0 of 1 is on bio001 |
| 82 | pi is approximately 3.1415926544231341, Error is 0.0000000008333410 |
| 83 | wall clock time = 0.000277 |
| 84 | }}} |
| 85 | * 貼上 test1.c |
| 86 | {{{ |
| 87 | ym24@bio001:~$ cat << EOF > test1.c |
| 88 | #include <stdio.h> |
| 89 | #include <mpi.h> |
| 90 | main (int argc, char **argv) |
| 91 | { |
| 92 | int rank, size, len; |
| 93 | char name[MPI_MAX_PROCESSOR_NAME]; |
| 94 | MPI_Init(&argc, &argv); |
| 95 | int myid, numprocs; |
| 96 | |
| 97 | /* 取得 node 總數 */ |
| 98 | MPI_Comm_size(MPI_COMM_WORLD,&numprocs); |
| 99 | /* 取得本身 node id / rank */ |
| 100 | MPI_Comm_rank(MPI_COMM_WORLD,&myid); |
| 101 | /* 取得本身 host name */ |
| 102 | MPI_Get_processor_name(name, &len); |
| 103 | printf("This is machine %d of %d name = %s\n", myid, numprocs, name); |
| 104 | |
| 105 | MPI_Finalize(); |
| 106 | } |
| 107 | EOF |
| 108 | }}} |