MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
mxl::lib::fabrics::ofi::SliceRange Class Reference

A SliceRange represents a range of slices within a grain. More...

#include <SliceRange.hpp>

Public Member Functions

std::uint16_t end () const noexcept
 Get the exclusive end of the range.
std::uint16_t start () const noexcept
 Get the inclusive start of the range.
std::uint32_t transferOffset (std::uint32_t payloadOffset, std::uint32_t sliceSize) const noexcept
 Get the offset within the payload for the start of the range.
std::uint32_t transferSize (std::uint32_t sliceSize) const noexcept
 Get the size of the range (end - start).

Static Public Member Functions

static SliceRange make (std::uint16_t start, std::uint16_t end)
 Create a SliceRange representing the range [start, end).

Private Member Functions

 SliceRange (std::uint16_t start, std::uint16_t end) noexcept

Private Attributes

std::uint16_t _end
std::uint16_t _start

Detailed Description

A SliceRange represents a range of slices within a grain.

The range is represented as [start, end), where start is inclusive and end is exclusive.

Definition at line 15 of file SliceRange.hpp.

Constructor & Destructor Documentation

◆ SliceRange()

mxl::lib::fabrics::ofi::SliceRange::SliceRange ( std::uint16_t start,
std::uint16_t end )
inlineprivatenoexcept

Definition at line 52 of file SliceRange.hpp.

53 : _start(start)
54 , _end(end)
55 {}
std::uint16_t end() const noexcept
Get the exclusive end of the range.
std::uint16_t start() const noexcept
Get the inclusive start of the range.

Member Function Documentation

◆ end()

std::uint16_t mxl::lib::fabrics::ofi::SliceRange::end ( ) const
nodiscardnoexcept

Get the exclusive end of the range.

Definition at line 35 of file SliceRange.cpp.

36 {
37 return _end;
38 }

◆ make()

SliceRange mxl::lib::fabrics::ofi::SliceRange::make ( std::uint16_t start,
std::uint16_t end )
staticnodiscard

Create a SliceRange representing the range [start, end).

Parameters
startThe inclusive start of the range.
endThe exclusive end of the range.
Returns
A SliceRange representing the specified range.
Exceptions
Exception::invalidArgumentif start is not less than end.

Definition at line 10 of file SliceRange.cpp.

11 {
12 if (start > end)
13 {
14 throw Exception::invalidArgument("Invalid SliceRange: start must be less or equal to end");
15 }
16
17 return SliceRange{start, end};
18 }
static Exception invalidArgument(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_ARG exception.
Definition Exception.hpp:43
SliceRange(std::uint16_t start, std::uint16_t end) noexcept

◆ start()

std::uint16_t mxl::lib::fabrics::ofi::SliceRange::start ( ) const
nodiscardnoexcept

Get the inclusive start of the range.

Definition at line 30 of file SliceRange.cpp.

31 {
32 return _start;
33 }

◆ transferOffset()

std::uint32_t mxl::lib::fabrics::ofi::SliceRange::transferOffset ( std::uint32_t payloadOffset,
std::uint32_t sliceSize ) const
nodiscardnoexcept

Get the offset within the payload for the start of the range.

Note
When start is 0, the offset is 0, because we include the header in the transfer.

Definition at line 25 of file SliceRange.cpp.

26 {
27 return payloadOffset + (_start * sliceSize);
28 }

◆ transferSize()

std::uint32_t mxl::lib::fabrics::ofi::SliceRange::transferSize ( std::uint32_t sliceSize) const
nodiscardnoexcept

Get the size of the range (end - start).

Note
When start is 0, the size includes the header, it adds the payload offset.

Definition at line 20 of file SliceRange.cpp.

21 {
22 return ((_end - _start) * sliceSize);
23 }

Member Data Documentation

◆ _end

std::uint16_t mxl::lib::fabrics::ofi::SliceRange::_end
private

Exclusive end of the range

Definition at line 59 of file SliceRange.hpp.

◆ _start

std::uint16_t mxl::lib::fabrics::ofi::SliceRange::_start
private

Inclusive start of the range

Definition at line 58 of file SliceRange.hpp.


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