作者ntwu (CEO)
看板LinuxDev
標題Re: [問題] linux指令下操控雲端運算
時間Mon Oct 8 19:01:48 2012
※ 引述《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
1F:→ cobrasgo:不是不想幫忙,只是年代久遠要pickup不知要花多少時間… 10/19 20:39