Skip to content
Snippets Groups Projects
BPFileWriter.h 2.49 KiB
Newer Older
wfg's avatar
wfg committed
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * BPFileWriter.h
wfg's avatar
wfg committed
 *
 *  Created on: Dec 16, 2016
 *      Author: William F Godoy godoywf@ornl.gov
wfg's avatar
wfg committed
 */

#ifndef ADIOS2_ENGINE_BP_BPFILEWRITER_H_
#define ADIOS2_ENGINE_BP_BPFILEWRITER_H_
#include "adios2/ADIOSConfig.h"
#include "adios2/core/Engine.h"
#include "adios2/toolkit/format/bp1/BP1.h"            //format::BP1Writer
#include "adios2/toolkit/transportman/TransportMan.h" //transport::TransportsMan
wfg's avatar
wfg committed

namespace adios2
wfg's avatar
wfg committed
{

wfg's avatar
wfg committed
class BPFileWriter : public Engine
wfg's avatar
wfg committed
{

public:
     * Constructor for file Writer in BP format
     * @param name unique name given to the engine
     * @param openMode w (supported), r, a from OpenMode in ADIOSTypes.h
     * @param mpiComm MPI communicator
    BPFileWriter(IO &io, const std::string &name, const OpenMode openMode,
                 MPI_Comm mpiComm);

    void Advance(const float timeoutSeconds = 0.0) final;

    /**
     * Closes a single transport or all transports
     * @param transportIndex, if -1 (default) closes all transports, otherwise
     * it
     * closes a transport in m_Transport[transportIndex]. In debug mode the
     * latter
     * is bounds-checked.
     */
    void Close(const int transportIndex = -1) final;
    /** Single object controlling BP buffering */
    format::BP1Writer m_BP1Writer;

    /** single object controlling a vector of Transports from IO AddTransport */
    transportman::TransportMan m_TransportsManager;
    /** true: due to buffer overflow, move to transports manager */
William F Godoy's avatar
William F Godoy committed
    bool m_DoTransportFlush = false;
    void Init() final;

    /** Parses parameters from IO SetParameters */
    void InitParameters() final;
    /** Parses transports and parameters from IO AddTransport */
    void InitTransports() final;
    void InitBPBuffer();
#define declare_type(T)                                                        \
    void DoWrite(Variable<T> &variable, const T *values) final;
    ADIOS2_FOREACH_TYPE_1ARG(declare_type)
#undef declare_type

    /**
     * Common function for primitive (including std::complex) writes
     * @param variable
     * @param values
     */
    template <class T>
    void DoWriteCommon(Variable<T> &variable, const T *values);

    /** Write a profiling.json file from m_BP1Writer and m_TransportsManager
     * profilers*/
    void WriteProfilingJSONFile();
wfg's avatar
wfg committed

} // end namespace adios
wfg's avatar
wfg committed

#endif /* ADIOS2_ENGINE_BP_BPFILEWRITER_H_ */