StagingBuff: Unify constraints into IOEngineConstraints
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
#include "stagingBuffer.h"
|
||||
#include <unistd.h>
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
|
||||
// Static defaults for io_uring
|
||||
const StagingBuffer::InputEngineConstraints
|
||||
StagingBuffer::InputEngineConstraints::ioUringConstraints(
|
||||
4096, // slotStartAlignmentByteVal (page alignment for DMA)
|
||||
const StagingBuffer::IOEngineConstraints
|
||||
StagingBuffer::IOEngineConstraints::ioUringConstraints(
|
||||
static_cast<size_t>(sysconf(_SC_PAGE_SIZE)), // slotStartAlignmentByteVal (page alignment for DMA)
|
||||
1472 // slotPadToNBytes (MTU 1500 - UDP/IP header 28)
|
||||
);
|
||||
|
||||
// Static defaults for OpenCL input
|
||||
const StagingBuffer::IOEngineConstraints
|
||||
StagingBuffer::IOEngineConstraints::openClInputConstraints(
|
||||
static_cast<size_t>(sysconf(_SC_PAGE_SIZE)), // slotStartAlignmentByteVal (page alignment)
|
||||
sizeof(void *) // slotPadToNBytes (pointer size)
|
||||
);
|
||||
|
||||
} // namespace stim_buff
|
||||
} // namespace smo
|
||||
|
||||
|
||||
|
||||
@@ -31,29 +31,29 @@ namespace stim_buff {
|
||||
class StagingBuffer
|
||||
{
|
||||
public:
|
||||
class InputEngineConstraints
|
||||
class IOEngineConstraints
|
||||
{
|
||||
public:
|
||||
InputEngineConstraints(
|
||||
IOEngineConstraints(
|
||||
size_t slotStartAlignmentByteVal_,
|
||||
size_t slotPadToNBytes_)
|
||||
: slotStartAlignmentByteVal(slotStartAlignmentByteVal_),
|
||||
slotPadToNBytes(slotPadToNBytes_)
|
||||
{}
|
||||
|
||||
~InputEngineConstraints() = default;
|
||||
~IOEngineConstraints() = default;
|
||||
|
||||
// Input-engine layout/constraints
|
||||
size_t slotStartAlignmentByteVal; // power-of-2 alignment (e.g., 4096)
|
||||
size_t slotPadToNBytes; // minimum size per datagram slot
|
||||
|
||||
// Static defaults for io_uring
|
||||
static const InputEngineConstraints ioUringConstraints;
|
||||
// Static defaults for io_uring and OpenCL
|
||||
static const IOEngineConstraints ioUringConstraints;
|
||||
static const IOEngineConstraints openClInputConstraints;
|
||||
|
||||
inline std::string stringify() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "InputEngineConstraints{"
|
||||
oss << "IOEngineConstraints{"
|
||||
<< "slotStartAlignmentByteVal=" << slotStartAlignmentByteVal
|
||||
<< ", slotPadToNBytes=" << slotPadToNBytes
|
||||
<< "}";
|
||||
@@ -61,13 +61,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class OutputEngineConstraints
|
||||
{
|
||||
public:
|
||||
OutputEngineConstraints() = default;
|
||||
~OutputEngineConstraints() = default;
|
||||
};
|
||||
|
||||
public:
|
||||
/** EXPLANATION:
|
||||
* We use the input and output engine constraints to determine the total
|
||||
@@ -75,8 +68,8 @@ public:
|
||||
* the given number of points per frame.
|
||||
*/
|
||||
explicit StagingBuffer(
|
||||
const InputEngineConstraints& inputEngineConstraints,
|
||||
const OutputEngineConstraints& outputEngineConstraints,
|
||||
const IOEngineConstraints& inputEngineConstraints,
|
||||
const IOEngineConstraints& outputEngineConstraints,
|
||||
size_t nDgramsPerFrame);
|
||||
~StagingBuffer() = default;
|
||||
|
||||
@@ -150,7 +143,7 @@ private:
|
||||
// Layout/invariants
|
||||
size_t nDgramsPerFrame;
|
||||
size_t slotStrideNBytes;
|
||||
InputEngineConstraints inputConstraints;
|
||||
IOEngineConstraints inputConstraints;
|
||||
|
||||
// Descriptor (computed once; reused across frames)
|
||||
mutable std::shared_ptr<FrameAssemblyDesc> frameDesc;
|
||||
@@ -164,8 +157,8 @@ private:
|
||||
******************************************************************************/
|
||||
|
||||
inline StagingBuffer::StagingBuffer(
|
||||
const InputEngineConstraints& inputEngineConstraints_,
|
||||
const OutputEngineConstraints& /*outputEngineConstraints*/,
|
||||
const IOEngineConstraints& inputEngineConstraints_,
|
||||
const IOEngineConstraints& /*outputEngineConstraints*/,
|
||||
size_t nDgramsPerFrame)
|
||||
: buffer(nullptr, MmapDeleter(0)), bufferNBytes(0),
|
||||
nDgramsPerFrame(nDgramsPerFrame), slotStrideNBytes(0),
|
||||
@@ -231,19 +224,6 @@ inline void StagingBuffer::computeSlotStrideAndBufferSize()
|
||||
* inputConstraints.slotStartAlignmentByteVal;
|
||||
}
|
||||
|
||||
/** Specific input/output engine constraints
|
||||
******************************************************************************/
|
||||
|
||||
class OpenClConstraints
|
||||
: public StagingBuffer::OutputEngineConstraints
|
||||
{
|
||||
public:
|
||||
OpenClConstraints()
|
||||
: StagingBuffer::OutputEngineConstraints()
|
||||
{}
|
||||
~OpenClConstraints() = default;
|
||||
};
|
||||
|
||||
} // namespace stim_buff
|
||||
} // namespace smo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user