Class ov::MemorySolver#

class MemorySolver#

Helps to solve issue of optimal memory allocation only for particular execution order.

It works with abstract data description where

  • Node is index in execution order

  • Edge is Box object with size and start-finish indexes (live time)

Example:

Mem(offset) | |____| Box {4, 5} | |_____________| Box {2, 6} | |____| Box {3, 4} | |____| Box {2, 3} | |____| Box {6, 7} |_____________________________________ 1 2 3 4 5 6 7 8 9 ExecOrder

Boxes which has an ExecOrder-axis intersection should have no Mem-axis intersections. The goal is to define a minimal required memory blob to store all boxes with such constraints and specify all corresponding position on Mem axis(through offset field).

NOTE! Exec order is predefined.

Public Functions

inline int64_t solve()#

Solve memory location with maximal reuse.

Returns:

Size of common memory blob required for storing all

inline int64_t get_offset(int id) const#

Provides calculated offset for specified box id

inline int64_t max_depth()#

Additional info. Max sum of box sizes required for any time stamp.

inline int64_t max_top_depth()#

Additional info. Max num of boxes required for any time stamp.

Public Static Functions

static inline int normalize_boxes(std::vector<Box> &boxes)#

Performes inplace normalization of the input boxes.

Returns:

lifespan of all boxes

struct Box#

Representation of edge (size and live time)

Public Members

int start#

Execution order index of first use. The data will be produced here.

int finish#

The execution order index of last use. After that data will be released. -1 is a reserved value for “till to end”. The data will be alive to very end of execution.

int64_t size#

Size of data. In abstract unit of measure (byte, simd, cache line, …)

int64_t id#

Box identifier, unique for each box. Will be used to querying calculated offset.