Changeset 9f1c84


Ignore:
Timestamp:
Sep 13, 2025, 2:44:01 PM (6 weeks ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
9259c3
Parents:
5d18f3
git-author:
Frederik Heber <frederik.heber@…> (09/01/25 20:22:38)
git-committer:
Frederik Heber <frederik.heber@…> (09/13/25 14:44:01)
Message:

VMG: OMPI 2.1.1 has issues on writing files in parallel.

  • for this reason, we deactivate the writing of the grid for open boundary conditions after computing boundary values via the greens function.
  • FIX: CreateSerialOutputFile() returned pointer to scope-internal MPI_File.
  • modified CreateParallelOutputFile() to use stringstreams for creating the filenames.
Location:
ThirdParty/vmg/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ThirdParty/vmg/src/comm/comm_mpi.cpp

    r5d18f3 r9f1c84  
    5353#include <cstring>
    5454#include <sstream>
     55#include <iomanip>
    5556
    5657#include "base/helper.hpp"
     
    736737  if (comm != MPI_COMM_NULL) {
    737738
    738     MPI_File file;
    739739    std::string conv_information = Helper::ReplaceWhitespaces(information, "_");
    740740
     
    742742        begin_global, end_global, begin_local, end_local);
    743743
    744     file = CreateSerialOutputFile(grid, comm, output_count, conv_information.c_str(),
     744    MPI_File *file = CreateSerialOutputFile(grid, comm, output_count, conv_information.c_str(),
    745745        begin_global, end_global, begin_local, end_local);
    746746
    747747    char *char_buf = Helper::GetCharArray(serial_data.str());
    748     MPI_File_write(file, char_buf, serial_data.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
     748    MPI_File_write(*file, char_buf, serial_data.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
    749749    delete [] char_buf;
    750750
    751     FinalizeSerialOutputFile(file);
     751    FinalizeSerialOutputFile(*file);
     752
     753    free(file);
    752754
    753755  }
     
    761763  int rank;
    762764  MPI_File file;
    763   char parallel_filename[513], serial_filename[513];
    764765  std::stringstream buf;
    765 
    766   MPI_Comm_rank(comm, &rank);
    767 
    768   sprintf(parallel_filename, "%s%04d.pvti", OutputPath().c_str(), output_count);
    769   sprintf(serial_filename, "%04d_%d.vti", output_count, rank);
    770 
    771   MPI_File_open(comm, parallel_filename, MPI_MODE_WRONLY|MPI_MODE_CREATE, MPI_INFO_NULL, &file);
     766  std::stringstream parallel_filename, serial_filename;
     767
     768  MPI_Comm_rank(comm_global, &rank);
     769
     770  parallel_filename << OutputPath() << std::setfill('0') << std::setw(4) << output_count << std::setw(0) <<  ".pvti";
     771  serial_filename << std::setfill('0') << std::setw(4) <<  output_count << "_" << rank << std::setw(0) <<  ".pvti";
     772  // sprintf(parallel_filename, "%s%04d.pvti", OutputPath().c_str(), output_count);
     773  // sprintf(serial_filename, "%04d_%d.vti", output_count, rank);
     774
     775  MPI_File_open(comm_global, parallel_filename.str().c_str(), MPI_MODE_WRONLY|MPI_MODE_CREATE|MPI_MODE_SEQUENTIAL, MPI_INFO_NULL, &file);
    772776  MPI_File_set_size(file, 0);
    773777
     
    807811      buf << begin_local[i] << " " << end_local[i]  << " ";
    808812
    809     buf << "\" Source=\"" << serial_filename << "\"/>" << std::endl;
     813    buf << "\" Source=\"" << serial_filename.str() << "\"/>" << std::endl;
    810814  }
    811815
     
    833837}
    834838
    835 MPI_File CommMPI::CreateSerialOutputFile(const Grid& grid, MPI_Comm& comm,
     839MPI_File* CommMPI::CreateSerialOutputFile(const Grid& grid, MPI_Comm& comm,
    836840    const int& output_count, const char* information,
    837841    const Index& begin_global, const Index& end_global,
     
    840844  char serial_filename[513];
    841845  int rank;
    842   MPI_File file;
     846  MPI_File *file = (MPI_File *)malloc(sizeof(MPI_File));
    843847  std::stringstream buf;
    844848
     
    847851  sprintf(serial_filename, "%s%04d_%d.vti", OutputPath().c_str(), output_count, rank);
    848852
    849   MPI_File_open(MPI_COMM_SELF, serial_filename, MPI_MODE_WRONLY|MPI_MODE_CREATE, MPI_INFO_NULL, &file);
     853  MPI_File_open(MPI_COMM_SELF, serial_filename, MPI_MODE_WRONLY|MPI_MODE_CREATE, MPI_INFO_NULL, file);
    850854
    851855  buf << "<?xml version=\"1.0\"?>" << std::endl
     
    874878
    875879  char* char_buf = Helper::GetCharArray(buf.str());
    876   MPI_File_write(file, char_buf, buf.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
     880  MPI_File_write(*file, char_buf, buf.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
    877881  delete [] char_buf;
    878882
  • ThirdParty/vmg/src/comm/comm_mpi.hpp

    r5d18f3 r9f1c84  
    159159                                const Index& begin_local, const Index& end_local);
    160160
    161   MPI_File CreateSerialOutputFile(const Grid& grid, MPI_Comm& comm,
     161  MPI_File* CreateSerialOutputFile(const Grid& grid, MPI_Comm& comm,
    162162                                  const int& output_count, const char* information,
    163163                                  const Index& begin_global, const Index& end_global,
  • ThirdParty/vmg/src/discretization/boundary_value_setter.cpp

    r5d18f3 r9f1c84  
    6262  }
    6363
    64   MG::GetComm()->PrintGrid(rhs_gml, "DEBUG GREEN BOUNDARY");
     64  // MG::GetComm()->PrintGrid(rhs_gml, "DEBUG GREEN BOUNDARY");
    6565}
    6666
Note: See TracChangeset for help on using the changeset viewer.