Our HelloWorld
sample generates C++ code under dist
folder. First have a look at the header file:
class TableMaker{ private: std::vectorom_s0_table; private: int om_s1_total; private: std::vector om_m0_5; public: TableMaker () : om_s0_table(om_memory_size()), om_m0_5(om_memory_size()) { }
Here we declare and allocate the memory for the static variables. Next comes the accessors for the OM size:
public: int om_size () { return 200; } public: int om_size_0 () { return 10; } public: int om_size_1 () { return 20; }
Note that all the auxiliary functions that Paraiso generates have name prefix om_
. Users should give their variables and kernels unique names not prefixed with om_
to avoid name collisions.
The next series of size functions, om_memory_size()
, returns the actual size of memory allocated. If the translated OM contains shift
instructions, Paraiso allocates margin region for communications, and om_memory_size()
will be greater than om_size()
.
public: int om_memory_size () { return 200; } public: int om_memory_size_0 () { return 10; } public: int om_memory_size_1 () { return 20; }
And here's the margin functions.
public: int om_lower_margin_0 () { return 0; } public: int om_lower_margin_1 () { return 0; } public: int om_upper_margin_0 () { return 0; } public: int om_upper_margin_1 () { return 0; }
You get a nice element-wise accessor for each static array variable of the OM. There are accessors for scalar variables, too.
public: int & table (int i0, int i1) { return (om_s0_table)[((om_lower_margin_0()) + (i0)) + ((om_memory_size_0()) * ((om_lower_margin_1()) + (i1)))]; } public: int & total () { return om_s1_total; }
You also get a direct access to the raw data structure of each Array although, what the term "raw" means depends on the implementation detail.
public: std::vector& table () { return om_s0_table; }
Finally, there are class methods that correspond to OM kernels.
public: void create () ; };
No comments:
Post a Comment