ug4
pcl::ParallelArchive Class Reference

#include <parallel_archive.h>

Classes

struct  Buffer_stringstream
 
struct  BufferBinaryBuffer
 
struct  BufferBinaryStream
 
struct  BufferInterface
 internal virtual buffer interface to support different buffers More...
 
struct  ConstCharBuffer
 

Public Member Functions

void add_raw (FileBufferDescriptor f)
 
ug::BinaryBuffercreate_BinaryBuffer_file (std::string name)
 
ug::BinaryStreamcreate_BinaryStream_file (std::string name)
 
void create_new_archive (std::string filename)
 
std::stringstream & create_stringstream_file (std::string name)
 
 ParallelArchive (std::string filename, pcl::ProcessCommunicator pc=pcl::ProcessCommunicator(pcl::PCD_WORLD))
 
void write ()
 
 ~ParallelArchive ()
 

Private Types

typedef std::map< std::string, SmartPtr< BufferInterface > >::iterator map_iterator
 

Private Attributes

std::map< std::string, SmartPtr< BufferInterface > > files
 
bool m_bUnsafe
 
bool m_bWritten
 
std::string m_filename
 
pcl::ProcessCommunicator m_pc
 

Detailed Description

This class creates one .a archive out of several parallel file writes This has two advantages

  1. Instead of writing 1024 files for 1024 cores, this writes 1 file
  2. It uses MPI I/O, which will be a LOT faster when number of cores are high

For extracting the archive use ar x thefile.a

Example usage:

std::stringstream &b = pa.create_stringstream_file(std::string("bla") + ToString(pcl::ProcRank()));
b << "Hello World!";
pa.write();
ParallelArchive(std::string filename, pcl::ProcessCommunicator pc=pcl::ProcessCommunicator(pcl::PCD_WORLD))
Definition: parallel_archive.h:156
Definition: pcl_process_communicator.h:70
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
std::string ToString(const ProcessCommunicator &pc)
Definition: pcl_tostring.h:45
@ PCD_WORLD
Definition: pcl_process_communicator.h:55

Member Typedef Documentation

◆ map_iterator

typedef std::map<std::string, SmartPtr<BufferInterface> >::iterator pcl::ParallelArchive::map_iterator
private

Constructor & Destructor Documentation

◆ ParallelArchive()

pcl::ParallelArchive::ParallelArchive ( std::string  filename,
pcl::ProcessCommunicator  pc = pcl::ProcessCommunicator(pcl::PCD_WORLD) 
)
inline

Create a parallel archive. Note that the file is written on descruction or when you call write() explicitely

Parameters
filenamethe name of the archive. add .a for clearness
pcthe process communicator used for MPI purposes. default WORLD

References m_bUnsafe, and m_bWritten.

◆ ~ParallelArchive()

pcl::ParallelArchive::~ParallelArchive ( )
inline

if the file(s) were not written already, this will write the file NOTE: Don't do this when using add_raw (unsafe!) NOTE: Communication happens here.

References m_bUnsafe, m_bWritten, UG_LOGN, and write().

Member Function Documentation

◆ add_raw()

void pcl::ParallelArchive::add_raw ( FileBufferDescriptor  f)
inline

add raw buffer descriptors (see FileBufferDescriptor) NOTE: be sure all data/pointers are valid until write is called NOTE: You HAVE to use ParallelArchive::write explicitely using deconstructors is UNSAFE since data can be deconstructed before ParallelArchive.

Parameters
f

References pcl::FileBufferDescriptor::buf, files, m_bUnsafe, make_sp(), pcl::FileBufferDescriptor::name, and pcl::FileBufferDescriptor::size.

◆ create_BinaryBuffer_file()

ug::BinaryBuffer& pcl::ParallelArchive::create_BinaryBuffer_file ( std::string  name)
inline

create a file inside the archive.

Parameters
namethe filename inside the archive. can be a path, but only filename is taken
Returns
a BinaryBuffer to write data to

References files, name, and p.

◆ create_BinaryStream_file()

ug::BinaryStream& pcl::ParallelArchive::create_BinaryStream_file ( std::string  name)
inline

create a file inside the archive.

Parameters
namethe filename inside the archive. can be a path, but only filename is taken
Returns
a BinaryStream to write data to

References files, name, and p.

◆ create_new_archive()

void pcl::ParallelArchive::create_new_archive ( std::string  filename)
inline

References m_bWritten, m_filename, and write().

◆ create_stringstream_file()

std::stringstream& pcl::ParallelArchive::create_stringstream_file ( std::string  name)
inline

create a file inside the archive.

Parameters
namethe filename inside the archive. can be a path, but only filename is taken
Returns
a stringstream to write data to

References files, name, and p.

Referenced by ug::ConnectionViewer::WriteMatrixPar().

◆ write()

void pcl::ParallelArchive::write ( )
inline

explicitely writes the data NOTE: Communication happens here.

References ug::FilenameWithoutPath(), files, m_bWritten, m_filename, m_pc, and pcl::WriteParallelArchive().

Referenced by create_new_archive(), and ~ParallelArchive().

Member Data Documentation

◆ files

std::map<std::string, SmartPtr<BufferInterface> > pcl::ParallelArchive::files
private

◆ m_bUnsafe

bool pcl::ParallelArchive::m_bUnsafe
private

◆ m_bWritten

bool pcl::ParallelArchive::m_bWritten
private

◆ m_filename

std::string pcl::ParallelArchive::m_filename
private

Referenced by create_new_archive(), and write().

◆ m_pc

pcl::ProcessCommunicator pcl::ParallelArchive::m_pc
private

Referenced by write().


The documentation for this class was generated from the following file: