Re: [問題] linux指令下操控雲端運算
※ 引述《ntwu (CEO)》之銘言:
: 假設今天我要將兩台以上雲端一起跑一個code
: 這個做法聽說要做到跨節點運算,好像程式碼也要改成mpi架構
: 我現在已經將code加上Mpi架構,實際mpicc可以執行
: 但我要怎麼用指令 來做跨節點運算阿????
: 請雲端大大們,為小弟指點
#include <stdio.h>
#include <time.h>
main(){
int max = 100000;
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));
}
上面原code
下面改過的code
#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 = 100000;
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;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.96.170.167
→
10/19 20:39, , 1F
10/19 20:39, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章