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