[問題] mpi c改成分散式運算架構
我要做多台雲端一起合作執行code,好像俗稱跨節點加分散式運算
以下是我原code
#include <stdio.h>
#include <time.h>
main(){
int max = 10000;
int i;
time_t now;
time(&now);
for(i = 1; i <= max;i++){
printf("%d\n",i);
}
time_t now2;
time(&now2);
printf("It's %s\n", ctime(&now));
printf("It's %s", ctime(&now2));
}
後來我加了mpi
#include <stdio.h>
#include <mpi.h>
#include <time.h>
int main (argc, argv)
int argc;
char *argv[];
{
int rank, size;
MPI_Init (&argc, &argv); /* starts MPI */
MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */
int max = 10000
int i;
time_t now;
time(&now);
for(i = 0; i <= max;i++){
printf("%d\n",i);
}
time_t now2;
time(&now2);
printf("It's %s\n", ctime(&now));
printf("It's %s", ctime(&now2));
printf( "Hello world from process %d of %d\n", rank, size );
MPI_Finalize();
return 0;
}
可是運算後好像不大對,變成每個節點都各算一遍,
而非我所要的各節點一起分工
請問有大大寫過mpi的嗎?
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.205.156
→
10/10 01:51, , 1F
10/10 01:51, 1F
→
10/10 01:52, , 2F
10/10 01:52, 2F
推
10/10 06:05, , 3F
10/10 06:05, 3F
→
10/10 06:07, , 4F
10/10 06:07, 4F
→
10/10 12:44, , 5F
10/10 12:44, 5F
→
10/10 12:49, , 6F
10/10 12:49, 6F
推
10/10 17:37, , 7F
10/10 17:37, 7F
→
10/10 17:38, , 8F
10/10 17:38, 8F
→
10/11 16:54, , 9F
10/11 16:54, 9F
→
10/11 16:56, , 10F
10/11 16:56, 10F
→
10/12 09:32, , 11F
10/12 09:32, 11F
→
10/14 15:35, , 12F
10/14 15:35, 12F
→
10/14 15:44, , 13F
10/14 15:44, 13F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章