[Beowulf] Stupid MPI programming question
Many of your questions may have already been answered in earlier discussions or in the FAQ. The search results page will indicate current discussions as well as past list serves, articles, and papers.
Mark Hahn hahn at physics.mcmaster.caWed Sep 27 21:14:05 PDT 2006
- Previous message: [Beowulf] Stupid MPI programming question
- Next message: [Beowulf] Stupid MPI programming question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Ok, here is the code I'm working with....mkdir keeps giving me a -1 failure...can anyone spot what I"m doing wrong?
why not simply look at errno when you receive the error?
> #define TRUE 1
> #define FALSE 0
> #define BOOLEAN int
> int main( argc, argv )
> int argc;
> char* argv [];
using K&R-style parameters is extremely bad practice.
> {
> int my_rank, i,pool_size;
> BOOLEAN i_am_the_master = FALSE;
personally, I find this bad practice, as well. the two assignments
to i_am_the_master are separated, and don't offer much, if any,
greater support to the reader of the code than just "rank==MASTER".
> // SLAVE CODE (THIS IS WHERE THE MAGIC HAPPENS
> if (!i_am_the_master)
> {
> char fullpath[10000];
technically, you should use PATH_MAX for this.
> sprintf(fullpath,"/tmp/oooo/RANK%d", my_rank);
snprintf is more robust.
> int mkdir_return;
> mkdir_return = mkdir(fullpath,0777);
> printf("mkdir results: %d\n", mkdir_return);
the idiom should be:
if (mkdir(fullpath,077) == -1)
fprintf(stderr,"mkdir failed: %d",errno);
but do you ensure that /tmp/oooo already exists before you try to make
the rank-specific subdirectory?
- Previous message: [Beowulf] Stupid MPI programming question
- Next message: [Beowulf] Stupid MPI programming question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Beowulf mailing list
