作者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