First page Back Continue Last page Summary Graphics
BProc Program Example 1
/* Skip node to node */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/bproc.h>
#define LEN 256
int main(int argc,char* argv[])
{
int i;
char *ch,host[LEN];
/* Where do we start? */
assert(gethostname(host,LEN)==0);
printf("Started on %s id %d\n",host,bproc_currnode());
/* Now cycle through the nodes */
for (i=1;i<argc;i++)
{
int node = strtol(argv[i],&ch,0);
if (*ch)
printf("Invalid node number %s\n",argv[i]);
else if (node==bproc_currnode() || bproc_move(node))
fprintf(stderr,"Move to %d failed\n",node);
else
{
assert(gethostname(host,LEN)==0);
printf("Moved to %s id %d\n",host,bproc_currnode());
}
}
return 0;
}
Notes: