Struct-Fields Partitioning
(Ask a Question)Struct-fields partitioning partitions a (array of) struct argument / variable into its individual fields such that each field is a partition. Unlike complete partitioning, if a field in the partitioned struct is an aggregate type (struct or array), the field is not further partitioned to its elements. Note that applying Struct-fields partitioning to an array-of-struct creates an array for each field in the struct. Unaccessed partitions (fields) are discarded, but the unaccessed elements in an aggreagte partition (field) are not discarded.
Example
struct Ty {
struct SubTy {
int a;
int b;
};
char x;
short y[2];
SubTy z;
};
int sum(Ty array[8]) { #pragma HLS function top #pragma HLS memory partition argument(array) type(struct_fields) int result = 0; for (int i = 0; i < 8; i++) { result += array[i].x + array[i].y[0] + array[i].z.a; } return result; }
The example above shows array
, an array of struct of type Ty, is partitioned using Struct-fields partitioning. With the user-specified partitioning, SmartHLS™ outputs messages to the console stating that the argument set to be partitioned and how many partitions are created. The three partitions are array.x[8]
, array.y[8][2]
, and array.z[8]
, where the 8-element dimensions are inherited from the original array size.
Info: Found user specified memory: "array" on line 15 of struct_sum.cpp, with partition type: Fields, partition dimension: 0.
Info: Partitioning memory: array into 3 partitions.
The summary report from SmartHLS lists the 3 partitions created from the fields of the struct. Note that the array field Ty.y has one partition, and similarly the struct field Ty.z