16#include <EcrFicPartage.h>
18#include <Comm_Group.h>
19#include <communications.h>
20#include <Perf_counters.h>
39 obuffer_ptr_->set_64b(this->
is_64b());
44inline OBuffer& EcrFicPartage::get_obuffer()
61#ifdef FILESYSTEM_NON_GLOBAL
75 get_obuffer().new_buffer();
94 const int buflen = get_obuffer().len();
97 Cerr <<
"***** WARNING : EcrFicPartage::close() ******* "<<
nom_fic_
98 <<
"\non PE " <<
me() <<
" the buffer is not empty\n"
99 <<
" (Missing syncfile) : one makes a last syncfile" << finl;
100 Cerr<<get_obuffer().str()<<finl;
104 const trustIdType maxbuflen =
mp_sum(buflen);
113 Cerr<<
"It missed a syncfile somewhere"<<finl;
114 Cerr<<
"Indeed, maxbuflen =" << maxbuflen << finl;
115 Cerr<<
"GF prefers to stop the calculation to correct "<<finl;
188 get_obuffer().put_null_char();
195 const int nb_proc =
nproc();
196 for(p=0; p<nb_proc; p++)
198 const char * buffer_data = 0;
199 char * allocated_buffer = 0;
208 buffer_data = get_obuffer().str();
209 buf_size = get_obuffer().len();
215 envoyer(dummy, p, 100);
216 recevoir(buf_size, p, 100);
219 buffer_data = allocated_buffer =
new char[buf_size];
220 group.
recv(p, allocated_buffer, buf_size, 100);
231 statistics().begin_count(STD_COUNTERS::IO_EcrireFicPartageBin,statistics().get_last_opened_counter_level()+1);
232 os.write(buffer_data, buf_size);
233 statistics().end_count(STD_COUNTERS::IO_EcrireFicPartageBin,1,buf_size);
238 assert(buffer_data[buf_size-1] == 0);
244 if (allocated_buffer)
245 delete[] allocated_buffer;
257 recevoir(dummy, 0, 100);
258 int buf_size = get_obuffer().len();
259 envoyer(buf_size, 0, 100);
263 const char * buffer_data = get_obuffer().str();
264 group.
send(0, buffer_data, buf_size, 100);
269 get_obuffer().new_buffer();
295int EcrFicPartage::put(
const unsigned* ob, std::streamsize n, std::streamsize pas) {
return put_template<unsigned>(ob,n,pas); }
296int EcrFicPartage::put(
const int* ob, std::streamsize n, std::streamsize pas) {
return put_template<int>(ob,n,pas); }
297int EcrFicPartage::put(
const long* ob, std::streamsize n, std::streamsize pas) {
return put_template<long>(ob,n,pas); }
298int EcrFicPartage::put(
const long long* ob, std::streamsize n, std::streamsize pas) {
return put_template<long long>(ob,n,pas); }
299int EcrFicPartage::put(
const float* ob, std::streamsize n, std::streamsize pas) {
return put_template<float>(ob,n,pas); }
300int EcrFicPartage::put(
const double* ob, std::streamsize n, std::streamsize pas) {
return put_template<double>(ob,n,pas); }
306 get_obuffer().set_bin(
bin_);
312 get_obuffer().set_64b(is64);
virtual void set_bin(bool bin)
bool bin_
Is this a binary flux?
virtual void set_64b(bool is_64b)
: This class describes a group of processors on which
virtual void send(int pe, const void *buffer, int size, int tag) const =0
virtual void recv(int pe, void *buffer, int size, int tag) const =0
int put(const unsigned *ob, std::streamsize n, std::streamsize pas) override
int get_precision() override
~EcrFicPartage() override
Closes the file.
Sortie & unlockfile() override
Releases the critical resource for the next process.
Sortie & lockfile() override
Allows the calling process to block waiting for the common resource shared by all processes,...
Sortie & flush() override
void set_bin(bool bin) override
Sortie & operator<<(const char *ob) override
Writes a character string.
int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out) override
Opens the file with the given mode and prot parameters. These parameters are the parameters of the st...
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
void precision(int) override
void set_64b(bool is64) override
Class defining operators and methods for all reading operation in an input flow (file,...
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
static const Comm_Group & current_group()
Returns a reference to the current active processor group.
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
SFichier(const char *name, IOS_OPEN_MODE mode=ios::out)
Separator for output streams.
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
Base class for output streams.