lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::Gpu::FileWriterAsync Class Reference

FileWriter that splits its GPU buffer into two halves: a filled half is written with cuFileWriteAsync on the registered stream while events are copied into the other half. More...

#include <FileWriter.hh>

Inherits Drp::Gpu::FileWriter.

Public Member Functions

 FileWriterAsync (size_t bufferSize, bool dio)
 Allocate a GPU buffer of twice bufferSize, used as two halves of bufferSize bytes.
 
void writeEvent (const void *devPtr, size_t size, const XtcData::TimeStamp) override
 Like FileWriter::writeEvent but with two buffer halves: when the event does not fit in the current half or the batch is more than 2 seconds old, wait for the previous write, start a cuFileWriteAsync of the current half and switch halves.
 
- Public Member Functions inherited from Drp::Gpu::FileWriter
 FileWriter (size_t bufferSize, bool dio)
 Open the cuFile driver and allocate a GPU buffer of bufferSize bytes, reduced to the driver's maximum pinned memory size if larger.
 
 ~FileWriter () override
 Close the file, free the GPU buffer and close the cuFile driver, exiting if that fails.
 
int registerStream (cudaStream_t)
 Use stream for the buffer copies and register it with cuFile (flags 0x7).
 
int deregisterStream (cudaStream_t)
 Deregister the stream set by registerStream(), if any, and forget it; the argument is not used.
 
int open (const std::string &fileName) override
 Close any open file, log the cuFile properties, create or truncate fileName (with O_DIRECT if dio was set), take a write lock and register the file and the GPU buffer with cuFile, then reset the buffer count and file offset.
 
int close () override
 If a file is open, write out the buffered data, deregister the file and the GPU buffer from cuFile and close the descriptor.
 
- Public Member Functions inherited from Drp::FileWriterBase
 FileWriterBase ()
 Start with the writing counter at 0.
 
virtual ~FileWriterBase ()
 Does nothing; empty body.
 
virtual uint64_t writing () const
 Return the writing counter (non-zero while an implementation is inside a write).
 

Protected Member Functions

void _reset () override
 
void _flush () override
 

Additional Inherited Members

- Static Public Member Functions inherited from Drp::Gpu::FileWriter
static void dumpProperties ()
 Log the cuFile driver properties: versions, supported file systems, control and feature flags and size limits.
 
- Protected Attributes inherited from Drp::Gpu::FileWriter
cudaStream_t m_stream
 
CUfileHandle_t m_handle
 
XtcData::TimeStamp m_batch_starttime
 
uint8_t * m_buffer_d
 
off_t m_fileOffset
 
size_t m_bufferSize
 
int m_fd
 
bool m_dio
 
- Protected Attributes inherited from Drp::FileWriterBase
volatile uint64_t m_writing
 

Detailed Description

FileWriter that splits its GPU buffer into two halves: a filled half is written with cuFileWriteAsync on the registered stream while events are copied into the other half.

Constructor & Destructor Documentation

◆ FileWriterAsync()

Drp::Gpu::FileWriterAsync::FileWriterAsync ( size_t  bufferSize,
bool  dio 
)

Allocate a GPU buffer of twice bufferSize, used as two halves of bufferSize bytes.

Member Function Documentation

◆ _flush()

void Drp::Gpu::FileWriterAsync::_flush ( )
overrideprotectedvirtual

Reimplemented from Drp::Gpu::FileWriter.

◆ _reset()

void Drp::Gpu::FileWriterAsync::_reset ( )
overrideprotectedvirtual

Reimplemented from Drp::Gpu::FileWriter.

◆ writeEvent()

void Drp::Gpu::FileWriterAsync::writeEvent ( const void *  devPtr,
size_t  size,
const XtcData::TimeStamp   
)
overridevirtual

Like FileWriter::writeEvent but with two buffer halves: when the event does not fit in the current half or the batch is more than 2 seconds old, wait for the previous write, start a cuFileWriteAsync of the current half and switch halves.

Then copy the event device to device into the current half; exits if it does not fit or if an asynchronous write failed.

Reimplemented from Drp::Gpu::FileWriter.


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