uwyocs
10-24-2009, 07:01 PM
Our MPI program includes file operations. Without totalview, it can run normally.But when I debug it in totalview, it cannot open the file. Through the totalview, whenever I step to e.g. FILE * fp=fopen(…), the fp always is a null pointer. I have tried absolute/relative file path name, and I also tried to put the put input file into the same folder with the program. But it has the same problem. A more interesting thing is that, occasionally the program is executed successfully in totalview. How to fix this problem?
We installed TotalView Express Student 8.7.0-3 for Linux/x86-64.
In the totalview’s Parallet tag. We use Open MPI. Tasks and nodes are set to be 4, and the additional argument is set to be “--mca btl ^openib�(disable the infiniband)
We also try it in totalview trial with demo license. Still not work.
e.g. this program often cannot get file pointer.
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
int countData(const char * filename){
FILE * fp=fopen(filename, "r");
if(fp==NULL){
fprintf(stderr,"Cannot open the file: %s \n",filename);
exit(-1);
}
int counter=0;
while( feof(fp)==0){//if the file does not reach its end of file
char str[512];
fgets(str, sizeof(str), fp);
counter++;
}
fclose(fp);
return counter;
}
int main(int argc, char ** argv){
int procRank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &procRank);
//if (procRank ==0){
char filename[]="../data/DataStatistics.txt";
int count =countData(filename);
printf("count=%d\n", count);
//}
MPI_Finalize();
}
We installed TotalView Express Student 8.7.0-3 for Linux/x86-64.
In the totalview’s Parallet tag. We use Open MPI. Tasks and nodes are set to be 4, and the additional argument is set to be “--mca btl ^openib�(disable the infiniband)
We also try it in totalview trial with demo license. Still not work.
e.g. this program often cannot get file pointer.
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
int countData(const char * filename){
FILE * fp=fopen(filename, "r");
if(fp==NULL){
fprintf(stderr,"Cannot open the file: %s \n",filename);
exit(-1);
}
int counter=0;
while( feof(fp)==0){//if the file does not reach its end of file
char str[512];
fgets(str, sizeof(str), fp);
counter++;
}
fclose(fp);
return counter;
}
int main(int argc, char ** argv){
int procRank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &procRank);
//if (procRank ==0){
char filename[]="../data/DataStatistics.txt";
int count =countData(filename);
printf("count=%d\n", count);
//}
MPI_Finalize();
}