Samik Banerjee
Samik Banerjee

Reputation: 5

Need help for MPI_File_open hangs on a particular file

inline MPI_File file_open(const std::string& filename, int access)
    { 
      int ret;
      // MPI_Barrier(MPI_COMM_WORLD);
      std::cout << "MPI filename: " << filename << std::endl;
      std::cout << "Rank: " << get_rank() << std::endl;
      MPI_File file;
      std::cout << "File: " << file << std::endl;
      char *filename1 = const_cast<char *>(filename.c_str());
      // char *filename2 = "scratch_1/39/filename1";
      // std::cout << "MPI filename new: " << filename1 << std::endl;
      // std::cout << "MPI filename type: " << typeid(filename1).name() << std::endl;
      // std::cout << "MPI filename type: " << typeid(filename2).name() << std::endl;
      ret = MPI_File_open(MPI_COMM_WORLD, filename1, access, MPI_INFO_NULL, &file);
      std::cout << "Return: " << ret << std::endl;
      if ( ret != 0)
      {
        std::cerr << "Entering IS_ROOT " << filename << std::endl;
        if (mpi_utils::is_root())
        {
          std::cerr << "Error while opening file " << filename << std::endl;
          MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
        }
      }
      return file;
    }

    inline MPI_File file_open_read_only(const std::string& filename) { return file_open(filename, MPI_MODE_RDONLY); }

    inline MPI_File file_open_write_only(const std::string& filename) { return file_open(filename, MPI_MODE_WRONLY | MPI_MODE_CREATE); }

    inline MPI_File file_open_read_write(const std::string& filename) { return file_open(filename, MPI_MODE_RDWR | MPI_MODE_CREATE); }

The result is hanging on:

MPI filename: scratch_1/39/dipha_edge_filename
Rank: 0
File: 0x63e600000000

The code used to run on:

['mpiexec', '-n', '1', 'DM_2D_code/DiMo2d/code/dipha-2d-thresh/build/dipha', '--upper_dim', '2', '--pixel_threshold', '255', 'scratch_1/39/dipha_inputfile', 'scratch_1/39/diagram_filename', 'scratch_1/39/dipha_edge_filename', '57', '336']

I am using

Debian 12.2.0, mpiexec (OpenRTE) 4.1.4

Really could not figure out what is happening here. I had a MPI_file_open_read_only previously which worked but not this one. The file does get created blank but the code does not come out of this line:

ret = MPI_File_open(MPI_COMM_WORLD, filename1, access, MPI_INFO_NULL, &file);

Need help to understand the error here.

Upvotes: 0

Views: 24

Answers (0)

Related Questions