- 229 名前:225 mailto:sage [2007/12/29(土) 00:39:48 ]
- こんな感じ。
#include <mpi.h> #include <sched.h> #include <stdio.h> int main(int argc, char *argv[]) { int rank; cpu_set_t mask; double t; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); __CPU_ZERO(&mask); __CPU_SET(rank, &mask); if (sched_setaffinity(0, sizeof(mask), &mask) == -1) { perror("Failed to set CPU affinity"); goto error; } t = MPI_Wtime(); while (MPI_Wtime() - t < 10 + rank * 5) ; MPI_Finalize(); return 0; error: MPI_Finalize(); return -1; }
|

|