| CM_SURFACE_FORMAT_A8 | 2D | Unsigned planar |
4.10.5 Flood Fill¶
void cm_va_flood_fill(vector_ref<ushort, 8> v, bool is8Connect,
vector<ushort, 10> pxMaskHDir, ushort pxMaskVDirLeft,
ushort pxMaskVDirRight, uchar loopCount);
| Parameters | |
|---|---|
| v | the vector to store the return results. Output format is 1bpp.
|
| Is8Connect |
|
| pxMaskHDir | Pixel Mask of the bottom adjacent pixels in horizontal direction. Index [0,7] are for rows [0,7], Index 8 is for row: -1, Index 9 is for row 8. |
| pxMaskVDirLeft | Pixel mask of the adjacent pixels in vertical direction. The mask is 10 bits per entry. All MSB bits passed 10 bits must be 0. |
| pxMaskVDirRight | Pixel mask of the adjacent pixels in vertical direction. The mask is 10 bits per entry. All MSB bits passed 10 bits must be 0. |
| loopCount | Number of times FloodFill will be repeated on HW. Valid range is [1,16] |
4.10.6 Correlation Search¶
void cm_va_correlation_search(matrix_ref<T, N, M> m, SurfaceIndex surfIndex,
float u, float v, float vertOrigin, float horizOrigin,
uchar xDirectionSize, uchar yDirectionSize, uchar xDirSearchSize,
uchar yDirSearchSize);
| Parameters | |
|---|---|
| m | the matrix to store the return results. Output format is 32bit SINT.
|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16bit format. |
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| vertOrigin | Normalized vertical origin of the reference image. |
| horizOrigin | Normalized horizontal origin of the reference image. |
| xDirectionSize | X Direction size of the Source Correlation. Valid range [1,8] |
| yDirectionSize | Y direction size of the Source Correlation. Valid range [1,8] |
| xDirSearchSize | X direction Search Size. Valid range [3,16] |
| yDirSearchsize | Y direction Search Size. Valid range [3,16] |
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_V8U8 | 2D | Signed planar |
| CM_SURFACE_FORMAT_A8 | 2D | Unsigned planar |
4.11 Video Analytics Functions HDC Write {Gen9+}¶
These variants of VA functions write their output to another surface directly instead of GRF. The output surface must have the same dimension (width*height in pixels) as the input surface.
4.11.1 2d Convolve¶
void cm_va_2d_convolve_hdc(SurfaceIndex surfIndex, SamplerIndex sampIndex,
float u, float v, bool big_kernel, CM_FORMAT_SIZE size,
SurfaceIndex destIndex, ushort x_offset, ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16bit format. |
| sampIndex | the index into the sampler state table. |
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| big_kernel | Set to true when size of the kernel is larger then 15x15. |
| size | Specifies the format of the output surface. Two formats are supported:
|
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface |
16x4 pixels will be written to the output surface. Each pixel is clamped to unsigned char for 8-bit output surfaces.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_V8U8 | 2D | Signed planar |
| CM_SURFACE_FORMAT_A8 | 2D | Planar |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R16_SINT | 2D | Signed |
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.2 Min Max Filter¶
void cm_va_min_max_filter_hdc(SurfaceIndex surfIndex,
SamplerIndex sampIndex, float u, float v, MMFEnableMode mmfMode,
CM_FORMAT_SIZE size, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16 bit format. |
| sampIndex | the index into the sampler state table. |
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| mmfMode | Used to enable MinMax functionality.
|
| size | Specifies the format used for the output. Two formats are supported:
|
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface. |
16x4 pixels will be written to the output surface. Each pixel is clamped to unsigned char for 8-bit output surfaces.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_V8U8 | 2D | Signed planar |
| CM_SURFACE_FORMAT_A8 | 2D | Planar |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R16_SINT | 2D | Signed |
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.3 Erode¶
void cm_va_erode_hdc(SurfaceIndex surfIndex, SamplerIndex sampIndex,
float u, float v, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has 32-bit format. |
| sampIndex | the index into the sampler state table. |
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface |
64x4 pixels with one-bit per pixel will be written to the output surface.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_A8R8G8B8 | 2D | Planar 1 bit per pixel format |
| CM_SURFACE_FORMAT_X8R8G8B8 | 2D | Planar 1 bit per pixel format |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.4 Dilate¶
void cm_va_dilate_hdc(SurfaceIndex surfIndex, SamplerIndex sampIndex,
float u, float v, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has 32-bit format. |
| sampIndex | the index into the sampler state table. |
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface |
64x4 pixels with one-bit per pixel will be written to the output surface.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_A8R8G8B8 | 2D | Planar 1 bit per pixel format |
| CM_SURFACE_FORMAT_X8R8G8B8 | 2D | Planar 1 bit per pixel format |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.5 1d Convolve¶
void cm_va_1d_convolution_hdc(SurfaceIndex surfIndex,
SamplerIndex sampIndex, bool isHdirection, float u, float v,
CM_FORMAT_SIZE size, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16bit format. |
| sampIndex | the index into the sampler state table. |
| isHdirection |
|
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| size | Specifies the format used for the output. Two formats are supported:
|
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface. |
For vertical convolve, 16x4 pixels will be written to the output surface. For horizontal convolve, 4x16 pixels will be written to the output surface. Each pixel is clamped to unsigned char for 8-bit output surfaces.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_V8U8 | 2D | Signed planar |
| CM_SURFACE_FORMAT_A8 | 2D | Planar |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R16_SINT | 2D | Signed |
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.6 1Pixel Convolve¶
void cm_va_1pixel_convolve_hdc(SurfaceIndex surfIndex,
SamplerIndex sampIndex, float u, float v, matrix<short, 1, 32> offsets,
CM_FORMAT_SIZE size, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset );
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16bit format. |
| sampIndex | the index into the sampler state table. |
| u | the normalized x coordinat of pixel 0. |
| v | the normalized y coordinat of pixel 0. |
| offsets | offsets of pixels from U,V address. |
| size | Specifies the format used for the output. Two formats are supported:
|
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface |
16x1 pixels will be written to the output surface. Each pixel is clamped to unsigned char for 8-bit output surfaces.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_V8U8 | 2D | Signed planar |
| CM_SURFACE_FORMAT_A8 | 2D | Planar |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R16_SINT | 2D | Signed |
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.7 LBP Creation¶
void cm_va_lbp_creation_hdc(SurfaceIndex surfIndex, float u, float v,
LBPCreationExecMode execMode, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16bit format. |
| u | the normalized x coordinate of pixel 0. |
| v | the normalized y coordinate of pixel 0. |
| execMode | valid values are:
|
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface. |
16x4 pixels will be written to the output surface.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_V8U8 | 2D | Signed planar |
| CM_SURFACE_FORMAT_A8 | 2D | Planar |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R16_SINT | 2D | Signed |
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.11.8 LBP Correlation¶
void cm_va_lbp_correlation_hdc(SurfaceIndex surfIndex, float u, float v,
short xoff_disparity, SurfaceIndex destIndex, ushort x_offset,
ushort y_offset);
| Parameters | |
|---|---|
| surfIndex | surface index, which must correspond to a 2D type surface that has either 8-bit or 16bit format. |
| u | the normalized x coordinat of pixel 0. |
| v | the normalized y coordinat of pixel 0. |
| xoff_disparity | 16bit signed x-offset for right image with respect to left image |
| destIndex | surface index of the 2D surface where data will be written. |
| x_offset | A byte offset in to the output surface. |
| y_offset | A row offset in to the output surface |
16x4 pixels will be written to the output surface.
Supported Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_A8 | 2D | Planar |
Supported Output Surfaces:
| Format | Type | Notes |
|---|---|---|
| CM_SURFACE_FORMAT_R8_UINT | 2D | Unsigned |
4.12 VME Interface¶
4.12.1 Gen6 VME Interface¶
C for Metal provides the user with the following Video Motion Estimation (VME) function support for Gen6 architecture. More detailed information on the VME functionality is provided in reference [4].
The formal parameters for all three functions below are described here:
| Parameters | |
|---|---|
| mInput | the matrix that stores the VME payload data. For detailed description of the payload content, please refer to [4]. The input matrix type “vme_InputMrfType” is defined as matrix<unsigned char, 4, 32>. |
| surfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| SPIndex | search path LUT index. This is an abstract handle that represents the VME state created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| lutSubIndex | the index into the RDLUT state table, with a range of [0-3]. |
| srcMB | The position of the left-top integer corner of the source macroblock or block located in the surface (in unit of pixels, relative to the surface origin). |
| ref0 | The position of the left-top integer corner of the first reference window located in the first reference surface (in unit of pixels, relative to the surface origin). |
| ref1 | The position of the left-top integer corner of the second reference window located in the second reference surface (in unit of pixels, relative to the surface origin; ignored in single reference mode). |
| topMinus8Pels | The positions of the top neighborhood pixels. Please refer to reference [4] for more detailed description of the data members. |
| leftPels | The positions of the left neighborhood pixels. Please refer to [4] for more detailed description of the data members. |
| mOutput | the matrix that stores the VME output data. For detailed description of the output content, refer to [4]. For “run_vme_intra”, the output matrix type vme_OutputGrfShortType” is defined as matrix<unsigned char, 1, 32>. For “run_vme_inter” and “run_vme_all”, the output matrix type vme_OutputGrfType” is defined as matrix<unsigned char, 4, 32>. |
run_vme_intra¶
void run_vme_intra(vme_InputMrfType mInput, SurfaceIndex surfIndex, VmeIndex SPIndex,
uint lutSubIndex, vector<ushort, 2> srcMB, vector<ushort, 2> ref0, vector<ushort, 2> ref1,
vector<uchar, 32> topMinus8Pels, vector<uchar, 16> leftPels, vme_OutputGrfShortType mOutput);
The compiler generates code for GenX hardware to perform VME function in intra-search only mode.
run_vme_inter¶
void run_vme_inter(vme_InputMrfType mInput, SurfaceIndex surfIndex, VmeIndex SPIndex,
uint lutSubIndex, vector<ushort, 2> srcMB, vector<ushort, 2> ref0, vector<ushort, 2> ref1,
vector<uchar, 32> topMinus8Pels, vector<uchar, 16> leftPels, vme_OutputGrfType mOutput);
The compiler generates code for GenX hardware to perform VME function in inter-search only mode.
run_vme_all¶
void run_vme_all(vme_InputMrfType mInput, SurfaceIndex surfIndex, VmeIndex SPIndex,
uint lutSubIndex, vector<ushort, 2> srcMB, vector<ushort, 2> ref0, vector<ushort, 2> ref1,
vector<uchar, 32> topMinus8Pels, vector<uchar, 16> leftPels, vme_OutputGrfType mOutput);
The compiler generates code for GenX hardware to perform VME functions in both inter- and intra-search enabled mode.
4.12.2 Gen7 VME Interface¶
C for Metal provides the user with the following Video Motion Estimation (VME) function support for Gen7 architecture.
run_vme_intra¶
void run_vme_intra(matrix<uchar, 5, 32> mInput, VMEStreamMode streamMode,
VMESearchCtrl searchCtrl, SurfaceIndex surfIndex, VmeIndex SPIndex, uint lutSubIndex,
vector<ushort, 2> srcMB, vector<ushort, 2> ref0, vector<ushort, 2> ref1,
vector<uchar, 32> topMinus8Pels, vector<uchar, 16> leftPels, matrix_ref<uchar, 1, 32> mOutput);
The compiler generates code for GenX hardware to perform VME function in intra-search only mode.
| Parameters | |
|---|---|
| mInput | the matrix that stores the VME payload data. |
| streamMode | VME stream mode, which must be set to VME_STREAM_DISABLE for run_vme_intra function. |
| searchCtrl | VME search control, which must be set to VME_SEARCH_SINGLE_REF_SINGLE_REC_SINGLE_START for run_vme_intra function. |
| surfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| SPIndex | search path LUT index. This is an abstract handle that represents the VME state created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| lutSubIndex | the index into the RDLUT state table, with a range of [0-3]. |
| srcMB | The position of the left-top integer corner of the source macroblock or block located in the surface (in unit of pixels, relative to the picture origin). |
| ref0 | The position of the left-top integer corner of the first reference window located in the first reference surface (in unit of pixels, relative to source MB location). |
| ref1 | The position of the left-top integer corner of the second reference window located in the second reference surface (in unit of pixels, relative to source MB location; ignored in single reference mode). |
| topMinus8Pels | The positions of the top neighborhood pixels. |
| leftPels | The positions of the left neighborhood pixels. |
| mOutput | the matrix that stores the VME output data. |
run_vme_inter¶
void run_vme_inter(matrix<uchar, N1, 32> mInput, VMEStreamMode streamMode,
VMESearchCtrl searchCtrl, SurfaceIndex surfIndex, VmeIndex SPIndex, uint lutSubIndex,
vector<ushort, 2> srcMB, vector<ushort, 2> ref0, vector<ushort, 2> ref1,
vector<uchar, 32> topMinus8Pels, vector<uchar, 16> leftPels, matrix_ref<uchar, N2, 32> mOutput);
The compiler generates code for GenX hardware to perform VME function in inter-search only mode.
run_vme_all¶
void run_vme_all(matrix<uchar, N1, 32> mInput, VMEStreamMode streamMode,
VMESearchCtrl searchCtrl, SurfaceIndex surfIndex, VmeIndex SPIndex, uint lutSubIndex,
vector<ushort, 2> srcMB, vector<ushort, 2> ref0, vector<ushort, 2> ref1,
vector<uchar, 32> topMinus8Pels, vector<uchar, 16> leftPels, matrix_ref<uchar, N2, 32> mOutput);
The compiler generates code for GenX hardware to perform VME functions in both inter- and intra-search enabled mode.
| Parameters | |
|---|---|
| mInput | the matrix that stores the VME payload data, where N1 can be the following values:
|
| streamMode | VME stream mode, which is an enumeration type with 4 possible values, as listed below. It must be a compile time constant.
|
| searchCtrl | VME search control, which is an enumeration type with 4 possible values, as listed below. It must be a compile time constant.
|
| surfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| SPIndex | search path LUT index. This is an abstract handle that represents the VME state created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| lutSubIndex | the index into the RDLUT state table, with a range of [0-3]. |
| srcMB | The position of the left-top integer corner of the source macroblock or block located in the surface (in unit of pixels, relative to the picture origin). |
| ref0 | The position of the left-top integer corner of the first reference window located in the first reference surface (in unit of pixels, relative to source MB location). |
| ref1 | The position of the left-top integer corner of the second reference window located in the second reference surface (in unit of pixels, relative to source MB location; ignored in single reference mode). |
| topMinus8Pels | The positions of the top neighborhood pixels. |
| leftPels | The positions of the left neighborhood pixels. |
| mOutput | the matrix that stores the VME output data, where N2 can be the following values:
|
4.12.3 Gen7_5 VME Interface¶
C for Metal provides the following Video Motion Estimation (VME) APIs for Gen7_5 architecture.
run_vme_ime¶
void run_vme_ime(matrix<uchar, 3, 32> UNIInput, matrix<uchar, N1, 32> IMEInput,
VMEStreamMode streamMode, VMESearchCtrl searchCtrl, SurfaceIndex curSurfIndex,
vector<short, 2> ref0, vector<short, 2> ref1, vector<ushort, 4> costCenter,
matrix_ref<uchar, N2, 32> IMEOutput);
The compiler generates code for GenX hardware to perform Integer Motion Estimation (IME). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| IMEInput | the matrix that stores the IME specific payload data, where N1 can be the following values:
|
| streamMode | VME stream mode, which is an enumeration type with 4 possible values, as listed below. It must be a compile time constant.
|
| searchCtrl | VME search control, which is an enumeration type with 4 possible values, as listed below. It must be a compile time constant.
|
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| ref0 | The position of the left-top integer corner of the first reference window located in the first reference surface (in unit of pixels, relative to the source MB). |
| ref1 | The position of the left-top integer corner of the second reference window located in the second reference surface (in unit of pixels, relative to the source MB; ignored in single reference mode). |
| costCenter | The coordinates for the cost centers relative to the picture source MB. The coordinates are specified in the following order: {CostCenter0X, CostCenter0Y, CostCenter1X, CostCenter1Y}. |
| IMEOutput | the matrix that stores the IME output data, where N2 can be the following values:
|
run_vme_sic¶
void run_vme_sic(matrix<uchar, 3, 32> UNIInput, matrix<uchar, 4, 32> SICInput,
SurfaceIndex curSurfIndex, matrix_ref<uchar, 7, 32> UNIOutput);
The compiler generates code for GenX hardware to perform Skip and Intra Check (SIC). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| SICInput | the matrix that stores the SIC specific payload data. |
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| UNIOutput | the matrix that stores the SIC output data (same structure as universal VME output data). |
run_vme_fbr¶
void run_vme_fbr(matrix<uchar, 3, 32> UNIInput, matrix<uchar, 4, 32> FBRInput,
SurfaceIndex curSurfIndex, uchar FBRMbMode, uchar FBRSubMbShape, uchar FBRSubPredMode,
matrix_ref<uchar, 7, 32> UNIOutput);
The compiler generates code for GenX hardware to perform Fractional and Bidirectional Refinement (FBR). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| FBRInput | the matrix that stores the FBR specific payload data. |
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| FBRMbMode | the inter macroblock type, which can be the following 2-bit values:
|
| FBRSubMbShape | the subshape per block for fractional and bidirectional refinement, which can be the following combination of 8-bit values:
where each 2-bit correspond to the following shapes:
|
| FBRSubPredMode | the selection of shapes from the input message for performing FME, which can be the following combination of 8-bit values:
where each 2-bit correspond to the following selections:
|
| UNIOutput | the matrix that stores the FBR output data (same structure as universal VME output data). |
4.12.4 Gen8 VME Interface¶
C for Metal provides the following Video Motion Estimation (VME) APIs for Gen8 architecture.
run_vme_ime¶
void run_vme_ime(matrix<uchar, 4, 32> UNIInput, matrix<uchar, N1, 32> IMEInput,
VMEStreamMode streamMode, VMESearchCtrl searchCtrl, SurfaceIndex curSurfIndex,
vector<short, 2> ref0, vector<short, 2> ref1, vector<ushort, 16> costCenter,
matrix_ref<uchar, N2, 32> IMEOutput);
The compiler generates code for GenX hardware to perform Integer Motion Estimation (IME). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| IMEInput | the matrix that stores the IME specific payload data, where N1 can be the following values:
|
| streamMode | VME stream mode, which is an enumeration type with 4 possible values, as listed below. It must be a compile time constant.
|
| searchCtrl | VME search control, which is an enumeration type with 4 possible values, as listed below. It must be a compile time constant.
|
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| ref0 | The position of the left-top integer corner of the first reference window located in the first reference surface (in unit of pixels, relative to the source MB). |
| ref1 | The position of the left-top integer corner of the second reference window located in the second reference surface (in unit of pixels, relative to the source MB; ignored in single reference mode). |
| costCenter | The coordinates for the cost centers relative to the picture source MB. The coordinates are specified in the following order: {FWDCostCenter0X, FWDCostCenter0Y, BWDCostCenter0X, BWDCostCenter0Y, FWDCostCenter1X, FWDCostCenter1Y, BWDCostCenter1X, BWDCostCenter1Y, FWDCostCenter2X, FWDCostCenter2Y, BWDCostCenter2X, BWDCostCenter2Y, FWDCostCenter3X, FWDCostCenter3Y, BWDCostCenter3X, BWDCostCenter3Y} |
| IMEOutput | the matrix that stores the IME output data, where N2 can be the following values:
|
run_vme_sic¶
void run_vme_sic(matrix<uchar, 4, 32> UNIInput, matrix<uchar, 4, 32> SICInput,
SurfaceIndex curSurfIndex, matrix_ref<uchar, 7, 32> UNIOutput);
The compiler generates code for GenX hardware to perform Skip and Intra Check (SIC). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| SICInput | the matrix that stores the SIC specific payload data. |
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| UNIOutput | the matrix that stores the SIC output data (same structure as universal VME output data). |
run_vme_fbr¶
void run_vme_fbr(matrix<uchar, 4, 32> UNIInput, matrix<uchar, 4, 32> FBRInput,
SurfaceIndex curSurfIndex, uchar FBRMbMode, uchar FBRSubMbShape, uchar FBRSubPredMode,
matrix_ref<uchar, 7, 32> UNIOutput);
The compiler generates code for GenX hardware to perform Fractional and Bidirectional Refinement (FBR). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| FBRInput | the matrix that stores the FBR specific payload data. |
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| FBRMbMode | the inter macroblock type, which can be the following 2-bit values:
|
| FBRSubMbShape | the subshape per block for fractional and bidirectional refinement, which can be the following combination of 8-bit values:
where each 2-bit correspond to the following shapes:
|
| FBRSubPredMode | the selection of shapes from the input message for performing FME, which can be the following combination of 8-bit values:
where each 2-bit correspond to the following selections:
|
| UNIOutput | the matrix that stores the FBR output data (same structure as universal VME output data). |
run_vme_idm¶
void run_vme_idm(matrix<uchar, 4, 32> UNIInput, matrix<uchar, 1, 32> IDMInput,
SurfaceIndex curSurfIndex, matrix_ref<uchar, 16, 32> IDMOutput);
The compiler generates code for GenX hardware to generate distortion mesh output (IDM). The formal parameters are described below:
| Parameters | |
|---|---|
| UNIInput | the matrix that stores the universal VME payload data. |
| IDMInput | the matrix that stores the IDM specific payload data. |
| curSurfIndex | surface index. This is an abstract handle that represents the surface created by C for Metal host runtime [6] and must be passed through kernel function parameters. C for Metal does not allow the explicit use of local/global variable or modification of such abstract data types in kernel functions, except used as function call argument. |
| IDMOutput | the matrix that stores the IDM output data. |
4.12.5 Gen10 HEVC VME Interface¶
C for Metal provides the following HEVC-specific Video Motion Estimation (VME) APIs for the Gen10 architecture
cm_vme_hevc_ime¶
void cm_vme_hevc_ime (matrix<uchar, 5, 32> IMEInput, matrix<uchar, 10, 32> StreamInput,
int LenStreamInput, SurfaceIndex curSurfIndex, matrix_ref<uchar, 12, 32> IMEOutput);
These generate code to perform an HEVC Integer Motion Estimation (IME) operation in GenX hardware.
| Parameters | |
|---|---|
| IMEInput | this holds the universal VME and search path (IME) input payloads. |
| LenStreamInput | the length of Stream Input, it could be either 0 (for an IME-F operation) or 10 (for an IME-S operation) . |
| StreamInput | this holds the stream-in major shape motion-vector and distortion (SISO) input payload. Unused if LengthStreamInput is 0. |
| curSurfIndex | the surface index. |
| IMEOutput | this holds the output payload, comprising the universal VME return data and the stream out motion-vector and distortion data (SISO). |
cm_vme_hevc_sic, cm_vme_hevc_sc¶
void cm_vme_hevc_sic(matrix_ref<uchar, 5, 32> SICInput, matrix_ref<uchar, 8, 32> NPInput,
int LengthNP, SurfaceIndex curSurfIndex, matrix_ref<uchar, 22, 32> SICOutput);
void cm_vme_hevc_sc(matrix_ref<uchar, 5, 32> SICInput, SurfaceIndex curSurfIndex,
matrix_ref<uchar, 2, 32> SICOutput);
These generate code to perform an HEVC Skip and/or Intra Check (SIC, IC, SC) operation in GenX hardware.
| Parameters | |
|---|---|
| SICInput | this hold the universal VME and SIC input payloads. |
| NPInput | this holds the neighbor pixel (NP) input payload. Not used if LengthNP is 0. |
| LengthNP | the size of Neighbor Pixel payload, 8 for SIC or IC operations, 0 for SC operations. curSurfIndex - the surface index. |
| SICOutput | this stores the SIC output payload, comprising the universal VME return data followed the intra steam-in steam-out data (SSRA) and Coding Unit (CU) data (these latter two data groups are only meaningful if an Intra Check was performed). |
cm_vme_hevc_sc() should be used in situations where it is always the case that there will be no need for an Intra Check. This avoids having to create NPInput matrix just to satisfy the parameter requirements for cm_vme_hevc_sic() even though it will be unused, and to avoid having SICOutput be unnecessarily large.
cm_vme_hevc_hpm_u¶
void cm_vme_hevc_hpm_u (matrix_ref<uchar, 12, 32> HPMInput, matrix_ref<uchar, 10, 32> StreamInpInter,
SurfaceIndex curSurfIndex, matrix_ref<uchar, 23, 32> HPMOutput);
These generate code to perform an HEVC Partitioning Message (HPM) with single-directional inter prediction in GenX hardware.
| Parameters | |
|---|---|
| HPMInput | this holds the universal VME, Skip Intra Check (SIC), IntraPred and distortion (SSRA) and Neighbor Motion Vector (NMV) input payloads. |
| StreamInpInter | this holds the stream-in major shape motion vector and distortion data (SISO). |
| curSurfIndex | the surface index. |
| HPMOutput | the matrix that hold the output payload, comprising the universal VME return data and major shape stream out data (CU). |
cm_vme_hevc_hpm_b¶
void cm_vme_hevc_hpm_b (matrix<uchar, 12, 32> HPMInput, matrix<uchar, 20, 32> StreamInpInter,
int LenStrmInpInter, SurfaceIndex curSurfIndex, matrix_ref<uchar, 23, 32> HPMOutput);
These generate code to perform HEVC Partitioning Message (HPM) with single- or bi-directional Inter Prediction in GenX hardware.
| Parameters | |
|---|---|
| HPMInput | this holds the universal VME, Skip Intra Check (SIC), IntraPred and distortion (SSRA) and Neighbor Motion Vector (NMV) input payloads. |
| StreamInpInter | this holds the stream-in major shape motion vector and distortion data (SISO). |
| LenStrmInpInter | the size of StreamInputInter payload, 10 for single-directional, 20 for bi-directional. |
| curSurfIndex | the surface index |
| HPMOutput | this holds the output payload, comprising the universal VME return data and major shape stream out data (CU). |
cm_vme_hevc_fbr¶
void cm_vme_hevc_fbr(matrix<uchar, 3, 32> UNIInput, matrix<uchar, 16, 32> CUInput,
int ValidCULength, SurfaceIndex curSurfIndex, matrix_ref<uchar, 18, 32> FBROutput);
void cm_vme_hevc_fbr(matrix_ref<uchar, 3, 32> UNIInput, matrix_ref<uchar, 16, 32> CUInput,
int ValidCULength, SurfaceIndex curSurfIndex, matrix_ref<uchar, 18, 32> FBROutput);
These generate code to perform a Fractional and Bidirectional Refinement (FBR) operation in GenX hardware.
| Parameters | |
|---|---|
| UNIInput | this holds the universal VME input payload. |
| CUInput | this holds the Coding Unit (CU) input payload. |
| ValidCULength | the size of CUInput. Legal value are: 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, or 16. |
| curSurfIndex | the surface index. |
| FBROutput | this holds the FBR output payload, comprising the universal VME return data and the FBR applied Coding Unit data (CU). |
cm_vme_hevc_rpm¶
void cm_vme_hevc_rpm(matrix<uchar, 7, 32> UNIInput, matrix<uchar, 16, 32> CUInput,
int ValidCULength, SurfaceIndex curSurfIndex, matrix_ref<uchar, 8, 32> RPMOutput);
void cm_vme_hevc_rpm(matrix_ref<uchar, 7, 32> UNIInput, matrix_ref<uchar, 16, 32> CUInput,
int ValidCULength, SurfaceIndex curSurfIndex, matrix_ref<uchar, 8, 32> RPMOutput);
These generate code to perform a Residual Prediction Message (RPM) operation in GenX.
| Parameters | |
|---|---|
| RPMInput | this holds the universal VME and Spatial Neighbor Pixel (NP) input payloads. |
| CUInput | this holds the Coding Unit input payload. |
| ValidCULength | the size of CUInput. Legal values are: 1, 4, 7, 10, 13, or 16. |
| curSurfIndex | the surface index. |
| RPMOutput | this stores the 4x4 z-order based approximate predicted residual value or approximate predicted pixel for 32x32 data area (RPM). |
cm_vme_hevc_srm¶
void cm_vme_hevc_srm(matrix<uchar, 8, 32> SRMInput, matrix<uchar, 16, 32> CUInput,
int ValidCULength, SurfaceIndex curSurfIndex, matrix_ref<uchar, 18, 32> SRMOutput);
void cm_vme_hevc_srm(matrix_ref<uchar, 8, 32> SRMInput, matrix_ref<uchar, 16, 32> CUInput,
int ValidCULength, SurfaceIndex curSurfIndex, matrix_ref<uchar, 18, 32> SRMOutput);
These generate code to perform a Skip Replacement Message (SRM) operation in GenX hardware.
| Parameters | |
|---|---|
| SRMInput | this holds the universal VME and Neighbor Motion Vector input payloads. |
| CUInput | this holds the Coding Unit input payload. |
| ValidCULength | the size of CUInput, the legal value as follows: 1, 4, 7, 10, 13, or 16. |
| curSurfIndex | the surface index. |
| SRMOutput | this holds the SRM output payload, comprising the universal VME return data and SRM applied Coding Unit data (CU). |
4.13 Media Walker Interface¶
To support the Media Walker functionality, C for Metal provides the following intrinsic functions for a kernel to query the thread position in the thread space. Please refer to C for Metal runtime specification on the definition of thread space and usage models of Media Walker [6]. The kernel can use these functions to obtain the per-thread X/Y origin and color values set by the C for Metal runtime host.
get_thread_origin_x¶
unsigned short get_thread_origin_x();
This function returns the X value of the thread origin in the thread space. The return value is from 0 to predefined thread space width - 1.
get_thread_origin_y¶
unsigned short get_thread_origin_y();
This function returns the Y value of the thread origin in the thread space. The return value is from 0 to predefined thread space height - 1.
get_color¶
unsigned short get_color();
This function returns the color value of the thread origin in the thread space. The return value is from 0 to predefined thread space color value - 1.
If thread space is not defined by C for Metal runtime host, the default thread space width is fixed at 511.
4.14 Synchronization Functions¶
C for Metal provides the following intrinsic functions for synchronization:
cm_wait¶
void cm_wait(unsigned char mask = 0);
If a thread dependency pattern is specified during the creation of the kernel’s thread space, this function causes the thread to wait until all of its dependency threads have terminated before resuming execution. Refer to [6] for more information on how to create thread dependencies during kernel launch.
| Parameters | |
|---|---|
| mask | the thread dependency clear mask. Each bit corresponds to one of the eight threads this thread may depend on; if set, the dependency is cleared, and this thread will not wait for the corresponding thread’s termination. |
cm_fence¶
void cm_fence(unsigned char mask);
This function causes thread execution to block until all previous reads and writes issued by the thread have been globally observed.
| Parameters | |
|---|---|
| mask | {Gen8+} a bit mask that controls additional cache flush or fence behavior. Valid masks are:
The masks may be combined if more than one cache is to be flushed. {pre-Gen8} The field is ignored and the cache will not be flushed. |
cm_pause¶
void cm_pause(unsigned short length);
This function causes thread to pause for a length of time specified by “length”. The value is decremented by the hardware thread control every 32 EU cycles. Note that the EU clock frequency is variable so the pause is at best an approximate pause. Generally it will be longer than the value written. For architectures that don’t support (pre Gen10) the call will have no effect.
| Parameters | |
|---|---|
| length | number of 32 cycle chunks to pause for |
4.15 Raw Send Functions¶
C for Metal provides the following APIs for issuing raw send messages to GenX shared functions.
cm_send¶
void cm_send(matrix_ref<T1, N1, N2> rspVar,
matrix<T2, N3, N4> msgVar,
uint exDesc, uint msgDesc, uint sendc);
cm_sends {Gen9+}¶
void cm_sends(matrix_ref<T1, N1, N2> rspVar,
matrix<T2, N3, N4> msgVar,
matrix<T3, N5, N6> msg2Var,
uint exDesc, uint msgDesc, uint sendc);
The formal parameters are described below:
| Parameters | |
|---|---|
| rspVar | the matrix that stores the message response data. |
| msgVar | the matrix that stores the message payload data. |
| msg2Var | the matrix that stores the second part of the message payload data in a split send (Gen9+) |
| exDesc | the extended message descriptor, which must be a compile time constant. |
| msgDesc | the message descriptor for the send. |
| sendc | the flag that indicates whether sendc should be used. It must be a compile time constant (0 indicates send should be used, while 1 means sendc) |
Note: When using raw send API, in general, it is the programmer’s responsibility to ensure that the input parameters match the BSPEC requirement for a specific shared function message (e.g., payload size, alignment, descriptor value, etc.). The response data and payload data are 32-bytes aligned. When the destination is not present, the first parameter can be specified as “NULL”.
Cm-icl compiler only:
The SIMD width of the resulting send
or sends
instruction is always SIMD16.
The cm_send
or cm_sends
call cannot be inside SIMD control flow.
Cmc compiler only:
The SIMD width of the resulting send
or sends
instruction defaults to SIMD16.
However, if the cm_send
or cm_sends
is inside SIMD control flow, the
SIMD width of the send
or sends
instruction is adjusted to match the SIMD
control flow. The effect of the SIMD condition on the send
or sends
depends
on how the shared function unit interprets the execution mask.
If the SIMD_IF_BEGIN
has a vector condition that evaluates
to all channels true, then the SIMD control flow code is optimized away but the
SIMD width of the send
or sends
instruction is adjusted anyway.
cm_get_value¶
unsigned int cm_get_value(T index);
This intrinsic can be used to assemble the message descriptor, since C for Metal does not allow direct manipulation of abstract handles such as SurfaceIndex. The input parameter must be one of the abstract data types (SurfaceIndex, SamplerIndex or VmeIndex). The return data is the encapsulated index value.
cm_get_r0¶
vector<uint, 8> cm_get_r0();
This intrinsic can be used to access the thread payload register R0, needed to assemble the raw send message’s payload.
4.16 C for Metal label function¶
The cm_label function is deprecated in cmc. For backwards compatibility it is ignored if used.
4.17 Formatted Output¶
4.17.1 printf¶
Starting with version 3.0, C for Metal includes support for calling printf in-kernel: it prints formatted output from a C for Metal kernel to stdout on the host. Printf is defined as:
int printf(const char* format, ...);
C for Metal device printf works similar to printf in <stdio.h> with the following exceptions:
- Unlike standard printf, which returns the number of bytes of the formatted output written to stdout, C for Metal printf returns the total unformatted bytes written to the special surface that is reserved to printf.
- The format string for the C for Metal printf must have fewer than 128 bytes.
- There can be no more than 64 parameters passed to a C for Metal printf call.
- The following conversion specifiers are currently not supported: p, n.
To use printf there are certain changes required in the host code to allocate the printf surface, read and format the data written, and then print the result to stdout after the kernel finishes execution. Please refer to the C for Metal Runtime API documentation for more information.
Example
#include <cm/cm.h>
_GENX_MAIN_ void printf_demo_genx()
{
int tx = get_thread_origin_x();
int ty = get_thread_origin_y();
printf("Number of bytes returned: %d\n", printf("Hello CM from %dx%d\n", tx, ty));
double foo = 4.2;
printf("Print a double: %f\n", (double)foo);
printf("Print a string: %s\n", "Hello");
if (tx == 0 && ty == 0) // Only print on tid 0
{
printf("Hello from tid 0 with tx/ty %d/%d \n", tx, ty);
}
}
For a kernel with four threads the following would print (not necessarily in the same order):
Number of bytes returned: 224
Number of bytes returned: 224
Number of bytes returned: 224
Number of bytes returned: 224
Print a double: 4.2
Print a double: 4.2
Print a double: 4.2
Print a double: 4.2
Print a string: Hello
Print a string: Hello
Print a string: Hello
Print a string: Hello
Hello from tid 0 with tx/ty: 0/0
4.19 Preprocessor Directives¶
Currently C for Metal supports the following preprocessor directives (pragmas):
#pragma unroll (n)¶
This pragma may be specified immediately before a loop to instruct the C for Metal compiler to unroll a loop for n times. The C for Metal compiler may still not unroll the loop due to lack of resource.
#pragma unroll¶
This pragma may be specified immediately before a loop to instruct the C for Metal compiler to completely unroll a loop. The C for Metal compiler may not unroll the loop due to lack of resources.
4.20 Rounding mode and float control support¶
C for Metal supports setting of floating point rounding mode and other floating point control on a per-kernel basis. This is achieved by using the _GENX_FLOAT_CONTROL_ or _GENX_ROUNDING_MODE_ kernel attributes. _GENX_FLOAT_CONTROL_ supports all control. _GENX_ROUNDING_MODE_ is a synonym for _GENX_FLOAT_CONTROL_ and is retained for backward compatibility.
The values that the attribute can be set to are a subset of the following that can be OR’ed together. The compiler will not enforce using mutually exclusive values (for instance 2 rounding modes) and the results in this case may be undefined.
Valid values for the float control setting are as follows:
| Attribute Name | Description |
|---|---|
| CM_RTE | Set round to nearest even (default) |
| CM_RTP | Set round towards +ve infinity |
| CM_RTN | Set round towards -ve infinity |
| CM_RTZ | Set round towards zero |
| CM_DENORM_RTZ | Set all denorm setting to Flush To Zero (no denorms) (default) |
| CM_DENORM_D_ALLOW | Set double to allow denorms |
| CM_DENORM_F_ALLOW | Set float to allow denorms |
| CM_DENORM_HF_ALLOW | Set half to allow denorms |
| CM_DENORM_ALLOW | Set all float types (double, float, half) to allow denorms |
| CM_FLOAT_MODE_IEEE | Set single float mode to IEEE (default) |
| CM_FLOAT_MODE_ALT | Set single float mode to ALT |
Round to even (RTE) (default)¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_RTE) void rte_kernel(SurfaceIndex ExampleBuffer) {
...
}
Round to positive infinity (RTP)¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_RTP) void rtp_kernel(SurfaceIndex ExampleBuffer) {
...
}
Round to negative infinity (RTN)¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_RTN) void rtn_kernel(SurfaceIndex ExampleBuffer) {
...
}
Round to zero (RTZ)¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_RTZ) void rtz_kernel(SurfaceIndex ExampleBuffer) {
...
}
Denorm behaviour¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_DENORM_ALLOW) void denorm_kernel(SurfaceIndex ExampleBuffer) {
...
}
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_DENORM_D_ALLOW | CM_DENORM_HF_ALLOW) void denorm_d_hf_kernel(SurfaceIndex ExampleBuffer) {
...
}
Float mode behaviour¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_FLOAT_MODE_IEEE) void float_ieee_kernel(SurfaceIndex ExampleBuffer) {
...
}
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_FLOAT_MODE_ALT) void float_alt_kernel(SurfaceIndex ExampleBuffer) {
...
}
Mixed control examples¶
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_DENORM_F_ALLOW | CM_RTN) void denorm_and_round_kernel(SurfaceIndex ExampleBuffer) {
...
}
_GENX_MAIN_ _GENX_FLOAT_CONTROL_(CM_DENORM_ALLOW | CM_RTN | CM_FLOAT_MODE_ALT) void multiple_settings_kernel(SurfaceIndex ExampleBuffer) {
...
}
4.21 Miscellaneous Functions¶
cm_get_hwid¶
uint cm_get_hwid();
This intrinsic can be used to access the hardware thread id from register R0.
5 C for Metal Template Library¶
The C for Metal implementation also provides a template library of functions. Inclusion of the cm/cmtl.h header file is required to make use of these functions.
The functions defined in cm/cmtl.h provide an implementation which has been defined to be as optimal as possible for the C for Metal language. In general, if a function exists in the C for Metal Template Library it is advisable to use it. To some extent this will also better enable code to cope with future variations and enhancements.
The C for Metal Template Library uses a namespace to stop pollution of the global namespace as much as possible. The namespace used for the C for Metal Template Library is cmtl. Here is an example:
#include <cm/cm.h> #include <cm/cmtl.h>
_GENX_MAIN_ void my_func(SurfaceIndex ibuf, SurfaceIndex obuf) {
matrix<short, HEIGHT, WIDTH> io;
cmtl::ReadBlock<short, HEIGHT, WIDTH>(ibuf, 0, 0, io);
...
}
Some functions have not been fully integrated into the compiler regression suite and are marked as such in the reference for each function with limited testing.
5.1 I/O¶
A set of template functions to enhance the I/O routines.
5.1.1 ReadBlock¶
Read a pixel block.
Description: Read a pixel block of size HEIGHT x WIDTH from a surface, all input are in pixel sizes. HEIGHT and WIDTH can be any integer.
The function will deal with any border issues using border replication where necessary when the block being read falls out of bounds of the input surface.
Author: Dori Eldar, Noam Teomim (ReadBlock with border handling)
Functions:
template<T, uint HEIGHT, uint WIDTH> void ReadBlock(SurfaceIndex ibuf,
int h_pix_pos, int v_pix_pos,
matrix_ref<T, HEIGHT, WIDTH> block,
uint surfaceWidth = 0);
template<T, uint HEIGHT, uint WIDTH> void ReadBlock(SurfaceIndex ibuf,
CmBufferAttrib buf_attrib,
int h_pix_pos, int v_pix_pos,
matrix_ref<T, HEIGHT, WIDTH> block,
uint surfaceWidth = 0);
| Parameters | |
|---|---|
| T | A type whose size is the same as the size of a single surface pixel. Example surface types and T values:
|
| HEIGHT | Number of rows for the matrix |
| WIDTH | Number of columns |
| ibuf | Surface index for input buffer |
| h_pix_pos | Horizontal offset in pixels |
| v_pix_pos | Vertical offset in pixels |
| block | Ref to output matrix (matrix_ref only) |
| surfaceWidth | Surface width in pixels. When set ReadBlock will properly replicate pixels across the right hand side boundary for non-dword aligned surfaces. |
Example:
// SurfaceIndex ibuf passed in as parameter
// WIDTH and HEIGHT previously defined
// surfWidth previously defined or passed as parameter
matrix<int, HEIGHT, WIDTH> block;
int x = get_thread_origin_x() * WIDTH;
int y = get_thread_origin_y() * HEIGHT;
// Read without considering non-dword aligned surface and replication
cmtl::ReadBlock(ibuf, x, y, block.select_all());
// Read taking into consideration non-dword aligned surfaces
cmtl::ReadBlock(ibuf, x, y, block.select_all(), surfWidth);
5.1.2 WriteBlock¶
Write a pixel block.
Description: Write a pixel block of size HEIGHT x WIDTH to a surface, all input are in pixel sizes. HEIGHT and WIDTH can be any integer.
The function will deal correctly with any border issues
Author: Dori Eldar
Functions:
template<T, uint HEIGHT, uint WIDTH> void WriteBlock(SurfaceIndex obuf,
int h_pix_pos, int v_pix_pos,
matrix_ref<T, HEIGHT, WIDTH> block);
| Parameters | |
|---|---|
| T | A type whose size is the same as the size of a single surface pixel. Example surface types and T values:
|
| HEIGHT | Number of rows for the matrix |
| WIDTH | Number of columns |
| obuf | Surface index for output buffer |
| h_pix_pos | Horizontal offset in pixels |
| v_pix_pos | Vertical offset in pixels |
| block | Ref to matrix to write out to surface (matrix_ref only) |
Example:
// SurfaceIndex obuf passed in as parameter
// WIDTH and HEIGHT previously defined
matrix<int, HEIGHT, WIDTH> block;
int x = get_thread_origin_x() * WIDTH;
int y = get_thread_origin_y() * HEIGHT;
// Some work to put some relevant values into block
// ...
// Write block to output surface
cmtl::WriteBlock(obuf, x, y, block.select_all());
5.1.3 ReadLinear¶
Read a vector from a linear buffer.
Description: Read a pixel vector of size WIDTH from a linear buffer. WIDTH can be any integer.
Author: Dori Eldar
Functions:
template<T, uint WIDTH> void ReadLinear(SurfaceIndex ibuf,
int pix_pos,
vector_ref<T, WIDTH> block);
| Parameters | |
|---|---|
| T | A type whose size is the same as the size of a single surface pixel. Example surface types and T values: * CM_SURFACE_FORMAT_A8, char * CM_SURFACE_FORMAT_V8U8, short * CM_SURFACE_FORMAT_A8R8G8B8, int |
| WIDTH | Number of elements |
| Ibuf | Surface index for input buffer |
| pix_pos | Offset in pixels |
| Block | Ref to vector to read from surface (vector_ref only) |
Example:
// SurfaceIndex ibuf passed in as parameter
// WIDTH previously defined
vector<int, WIDTH> block;
int x = get_thread_origin_x() * WIDTH;
// Read block from input surface
cmtl::ReadLinear(ibuf, x, block.select_all());
5.1.4 WriteLinear¶
Write a vector to a linear buffer.
Description: Write a pixel vector of size WIDTH to a linear buffer. WIDTH can be any integer.
Author: Dori Eldar
Functions:
template<T, uint WIDTH> void WriteLinear(SurfaceIndex obuf,
int pix_pos,
vector_ref<T, WIDTH> block);
| Parameters | |
|---|---|
| T | A type whose size is the same as the size of a single surface pixel. Example surface types and T values:
|
| WIDTH | Number of elements |
| Obuf | Surface index for input buffer |
| pix_pos | Offset in pixels |
| Block | Ref to vector to write to surface (vector_ref only) |
Example:
// SurfaceIndex obuf passed in as parameter
// WIDTH previously defined
vector<int, WIDTH> block;
int x = get_thread_origin_x() * WIDTH;
// Some work to put some relevant values into block
// ...
// Write block to output surface
cmtl::WriteLinear(obuf, x, block.select_all());
5.3 SLM¶
NOTE: These routines are not ready for general use at the moment (but are documented here for future inclusion)
5.3.1 DumpSLM¶
Limited testing
Dump content of SLM to memory
Description: Dump the contents of SLM to memory. This is primarily intended as a debugging tool. Note: this routine is not ready for general use at the moment.
Author: Aharon Robbins, Liron Atedgi
Functions:
void DumpSLM(uint slmX, SurfaceIndex slmDebugSurface, uint size);
| Parameters | |
|---|---|
| slmX | SLM handle |
| slmDebugSurface | Linear surface in which to dump contents of SLM |
| Size | Number of bytes to dump |
Example:
// SurfaceIndex slmDebugSurface passed in as parameter
// slmX handle is allocated here assuming cm_slm_init etc already done
// elsewhere
// SLM_BUFFER_SIZE defined elsewhere
uint slmX = cm_slm_alloc(SLM_BUFFER_SIZE);
// Some work to put some relevant values into SLM
// ...
// Dump SLM to memory
// In this case we're dumping the whole of the allocated buffer
cmtl::DumpSLM(slmX, slmDebugSurface, SLM_BUFFER_SIZE);
5.3.2 TransposeFromSLM¶
Limited testing
Transpose from SLM
Description: Transpose from SLM. Note: this routine is not ready for general use at the moment.
Author: Aharon Robbins, Liron Atedgi
template <uint N> void TransposeFromSLM(vector_ref<uint, N*4> dst,
vector_ref<uint, N*4> src);
5.3.3 TransposeToSLM¶
Limited testing
Transpose to SLM
Description: Transpose to SLM. Note: this routine is not ready for general use at the moment.
Author: Aharon Robbins, Liron Atedgi
template <uint N> void TransposeToSLM(vector_ref<uint, N*4> dst,
vector_ref<uint, N*4> src);
5.4 Iselect¶
The following templates can be used to pack two small data elements into a single larger data element. This is useful when one needs to simultaneously update multiple matrices through iselect. As iselect is a SIMD-1 for left hand side assignment.
5.4.1 Pack¶
Limited testing
Pack 2 “small” elements into a single double sized element
Description: Use this as part of iselect optimization, see example for more info. Typically packing would be:
- uchar/char -> ushort
- short/ushort -> uint
- int/uint -> double
Pack into double is supported on HSW+
Author: Dori Eldar
Functions:
template <Tpackd, Tcompst, uint WD>
void Pack(vector_ref<Tpackd, WD> src1, vector_ref<Tpackd, WD> src2,
vector_ref<Tcompst, WD> dst);
| Parameters |
- Tpackd
- Data type of the 2 sources
- Tcompst
- Data type of output sizeof(Tcompst) = 2sizeof(Tpackd)
- WD
- WIDTH of data vectors
- src1
- First source vector
- src2
- Second source vector
- Dst
- Destination composite vector
5.4.2 Unpack¶
Limited testing UnPack a compisite element previously generated through Pack(), into 2 elements
Description: Use this as part of iselect optimization. Typically packing would be:
- uchar/char -> ushort
- short/ushort -> uint
- int/uint -> double
Pack into double is supported on HSW+
Author: Dori Eldar
Functions:
template <Tpackd, Tcompst, uint WD>
void UnPack(vector_ref<Tpackd, WD> dst1, vector_ref<Tpackd, WD> dst2,
vector_ref<Tcompst, WD> src);
| Parameters | |
|---|---|
| Tpackd | Data type of the 2 sources |
| Tcompst | Data type of output sizeof(Tcompst) = 2sizeof(Tpackd) |
| WD | WIDTH of data vectors |
| src | Source Composite vector |
| dst1 | First destination vector, corresponding to first source provided to Pack() |
| dst2 | Second destination vector, corresponding to second source provided to Pack() |
Example: See the example for Pack
5.4.3 UnpackSingle¶
Limited testing
UnPack a composite element previously generated through Pack(), return only 1 of the 2 elements
Description: Use this as part of iselect optimization, Use this API, instead of Unpack, when only 1 element is required. Typically packing would be:
- uchar/char -> ushort
- short/ushort -> uint
- int/uint -> double
Pack into double is supported on HSW+
Author: Dori Eldar
Functions:
#define CMRT_LOC_FIRST 0
#define CMRT_LOC_SECOND 1
template <Tpackd, Tcompst, uint WD>
void UnpackSingle(vector_ref<Tpackd, WD> dst, int location, vector_ref<Tcompst, WD> src);
| Parameters | |
|---|---|
| Tpackd | Data type of the 2 sources |
| Tcompst | Data type of output sizeof(Tcompst) = 2sizeof(Tpackd) |
| WD | WIDTH of data vectors |
| Src | Source Composite vector |
| Dst | destination packed element vector |
| Location | Indicates which packed vector to retrieve, either CMRT_LOC_FIRST or CMRT_LOC_SECOND should be returned. The order of vectors is based on the order provided to Pack from left to right, e.g. | Pack(src1,src,2,dst) | UnpackSingle(dst, src, CMRT_LOC_FIRST) | Will set src with values from src1 |
5.5 CachedStack¶
A Cached Stack object represents Multi-Channel (SIMD) Stacks, (optionally) stored in a host memory buffer, with the elements of the stack cached in GRF. The fundamental functionality provided by a Stack object are:
- Push() – add an element to top of stack
- Pop() - extract top element from Stack
- Top() - read the top element without extracting it.
5.5.1 CachedStackInit¶
Limited testing
Description: Initializes a CachedStack Object
Author: Dori Eldar
Functions:
template<T, uint W, uint CACHESIZE>
void CachedStackInit(matrix_ref<short, 3, W*STACKCOUNT> context,
matrix_ref<int, 2, W> context_ii,
uint MaxSize);
| Parameters | |
|---|---|
| CACHESIZE | Pixel Size of Stack cache stored in GRF, currently MUST be: CACHESIZE *sizeof(T) % 128 == 0 (preferable for optimal IO) |
| T | Type of elements stored in stack |
| W | Number of channels (SIMD) for an element on stack context, Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| context_ii | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| MaxSize | Maximum number of elements on stack for a single channel. Caller must allocate the linear surface with: size >= MaxSize*NumThreads*W*Sizeof(T) Optimization note: MaxSize should be aligned to: (CACHELINE / sizeof(T)) (CACHELINE = 64 bytes) |
Example:
#include <cm/cm.h>
#include <cm/cmtl.h>
#define ALIGN_CACHELINE_SHORT(x) (((x) + 64 - 1) & (~ (64 - 1)))
_GENX_MAIN_ void
CachedStackExample(SurfaceIndex stack_surf, int ImageHeight)
{
ushort x_pos = get_thread_origin_x() * SZ;
vector<ushort, 16> element = 1;
vector<ushort, 16> mask = 1;
int aligned_image_hight = ALIGN_CACHELINE_SHORT(ImageHeight);
CachedStackInit<uint, 16, CACHESIZE>(stack_context,
stack_context_ii,
aligned_image_height);
CachedStackPush<uint, 16, CACHESIZE>(stack_surf,
stack_context,
stack_context_ii,
stack, element);
CachedStackPop<uint, SIMD_SZ, CACHESIZE>(stack_surf,
stack_context,
stack_context_ii, stack,
element, mask);
}
5.5.2 CachedStackTop¶
Limited testing
Description: Returns a vector containing top elements in the stack
Author: Dori Eldar
Functions:
template<T, uint W, uint CACHESIZE>
void CachedStackTop(SurfaceIndex surf, matrix_ref<short, 2, W> context,
matrix_ref<int, 2, W> context_ii,
matrix_ref<T, W, CACHESIZE> stack,
vector_ref<T,W> element);
| Parameters | |
|---|---|
| CACHESIZE | Pixel Size of Stack cache stored in GRF, currently MUST be: CACHESIZE *sizeof(T) % 128 == 0 (preferable for optimal IO) |
| T | Type of elements stored in stack |
| W | Number of channels (SIMD) for an element on stack |
| Surf | Pointer to linear surface used for stack |
| Context | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| context_ii | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| stack | User allocated stack cache |
| Element | Returned top element vector |
Example: See example for CachedStackInit
5.5.3 CachedStackPop¶
Limited testing
Description: Conditionaly pop top elements from stack based on mask, for channels with a 0 mask pixel element is returned to caller but not popped (see 5.5.2 CachedStackTop). Note: Caller must avoid Pop() over empty stack channels. See example for details of how to avoid this.
Author: Dori Eldar
Functions:
template<T, uint W, uint CACHESIZE>
void CachedStackPop(SurfaceIndex surf, matrix_ref<short,2,W> context,
matrix_ref<int,2,W> context_ii,
matrix_ref<T,W, CACHESIZE> stack,
vector_ref<T,W> element,
vector_ref<short,W> mask);
| Parameters | |
|---|---|
| CACHESIZE | Pixel Size of Stack cache stored in GRF, currently MUST be: | CACHESIZE *sizeof(T) % 128 == 0 (preferable for optimal IO) |
| T | Type of elements stored in stack |
| W | Number of channels (SIMD) for an element on stack |
| Surf | Pointer to linear surface used for stack |
| Context | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| context_ii | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| Stack | User allocated stack cache |
| Element | Returned top element vector |
| Mask | A 0-1 mask indicating top elements to Pop() (mask = 1) vs elements to Top() (mask = 0). Note: currently only a 0,1 mask is supported, if mask contains other values behavior will be undefined |
Example:
Note: Caller must avoid Pop() over empty stack channels. Caller can use CacheStackEmpty() to set a mask to avoid this condition:
vector<short, W> isEmpty;
vector<short, W> appMask; CallerSetMask(mask);
CachedStackEmpty<...>(..., isEmpty);
mask |= (1-isEmpty);
CachedStackPop<..>(..., mask);
5.5.4 CachedStackPush¶
Limited testing
Description: Push a vector element to top of stack. Note: Caller must not push() over a full stack (top element at MaxSize – 1)
Author: Dori Eldar
Function:
template<T, int W, int CACHESIZE>
void CachedStackPush(SurfaceIndex surf, matrix_ref<short, 2, W> context,
matrix_ref<int, 2, W> context_ii
matrix_ref<T, W, CACHESIZE> stack,
vector_ref<T, W> element);
| Parameters | |
|---|---|
| CACHESIZE | Pixel Size of Stack cache stored in GRF, currently MUST be: | CACHESIZE *sizeof(T) % 128 == 0 (preferable for optimal IO) |
| T | Type of elements stored in stack |
| W | Number of channels (SIMD) for an element on stack |
| surf | Pointer to linear surface used for stack |
| context | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| context_ii | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| stack | User allocated stack cache |
| element | Returned top elements vector |
Example: See example for CachedStackInit
5.5.5 CachedStackEmpty¶
Limited testing
Description: Returns a per element mask if Stack is empty or not
Author: Dori Eldar
template<uint W> void CachedStackEmpty(matrix_ref<short, 2, W> context,
matrix_ref<int, 2, W> context_ii,
vector_ref<short, W> isEmpty);
| Parameters | |
|---|---|
| W | Number of channels (SIMD) for an element on stack |
| context | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| context_ii | Internally used by CachedStack to maintain cache pointers, caller must not modify this parameter. |
| isEmpty | 0-1 mask, 1 Stack Empty 0 - Otherwise |
Example: See example for CachedStackPop
5.6 Matrix transform¶
A series of functions (mainly for 16x16 matrices) to perform various rotation and mirror operations on matrix_ref matrices.
5.6.1 MirrorVertical¶
Limited testing
Vertical mirror matrix transform
Description: Perform a vertical mirror transformation on a matrix, transforming it to a different output * - matrix
Author: Danny Barash, Chaim Rand
Functions:
template<T, uint H, uint W> void MirrorVertical(matrix_ref<T,H,W> in, matrix_ref<T,H,W> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| H | Height of the matrix (number of rows) |
| W | Width of the matrix (number of columns) |
| in | The input matrix (matrix_ref<T,H,W>) |
| out | The output matrix (matrix_ref<T,H,W>) |
Example:
matrix<float, 32, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 32, 16> mirrored_test_matrix;
cmtl::MirrorVertical(test_matrix.select_all(), mirrored_test_matrix.select_all());
5.6.2 MirrorHorizontal_16x16¶
Limited testing
Horizontal mirror for 16x16 matrix transform
Description: Perform a horizontal mirror transformation on a 16x16 matrix, transforming it to a different output matrix
Author: Danny Barash, Chaim Rand
Functions:
template<T> void MirrorVertical(matrix_ref<T,16,16> in, matrix_ref<T,16,16> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| in | The input matrix (matrix_ref<T,16,16>) |
| out | The output matrix (matrix_ref<T,16,16>) |
Example:
matrix<float, 16, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 16, 16> mirrored_test_matrix;
cmtl::MirrorHorizontal_16x16(test_matrix.select_all(), mirrored_test_matrix.select_all());
5.6.3 Rotate90_16x16¶
Limited testing
Rotate 90 clockwise for 16x16 matrix transform
Description: Perform a 90 degree clockwise rotation transformation on a 16x16 matrix, transforming it to a different output matrix
Author: Danny Barash, Chaim Rand
Functions:
template<T> void Rotate90_16x16(matrix_ref<T,16,16> in, matrix_ref<T,16,16> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| in | The input matrix (matrix_ref<T,16,16>) |
| out | The output matrix (matrix_ref<T,16,16>) |
Example:
matrix<float, 16, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 16, 16> rotated_test_matrix;
cmtl::Rotate90_16x16(test_matrix.select_all(), rotated_test_matrix.select_all());
5.6.4 Rotate270_16x16¶
Limited testing Rotate 270 clockwise for 16x16 matrix transform
Description: Perform a 270 degree clockwise rotation transformation on a 16x16 matrix, transforming it to a different output matrix
Author: Danny Barash, Chaim Rand
Functions:
template<T> void Rotate270_16x16(matrix_ref<T,16,16> in, matrix_ref<T,16,16> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| in | The input matrix (matrix_ref<T,16,16>) |
| out | The output matrix (matrix_ref<T,16,16>) |
Example:
matrix<float, 16, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 16, 16> rotated_test_matrix;
cmtl::Rotate270_16x16(test_matrix.select_all(), rotated_test_matrix.select_all());
5.6.5 Rotate180_16x16¶
Limited testing
Rotate 180 for 16x16 matrix transform
Description: Perform a 180 degree rotation transformation on a 16x16 matrix, transforming it to a different output matrix
Author: Danny Barash, Chaim Rand
Functions:
template<T> void Rotate180_16x16(matrix_ref<T,16,16> in, matrix_ref<T,16,16> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| in | The input matrix (matrix_ref<T,16,16>) |
| out | The output matrix (matrix_ref<T,16,16>) |
Example:
matrix<float, 16, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 16, 16> rotated_test_matrix;
cmtl::Rotate180_16x16(test_matrix.select_all(), rotated_test_matrix.select_all());
5.6.6 Transpose_16x16¶
Limited testing
Transpose for 16x16 matrix
Description: Perform a transpose on a 16x16 matrix, transforming it to a different output matrix
Author: Danny Barash, Chaim Rand
Functions:
template<T> void Transpose_16x16(matrix_ref<T,16,16> in, matrix_ref<T,16,16> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| in | The input matrix (matrix_ref<T,16,16>) |
| out | The output matrix (matrix_ref<T,16,16>) |
Example:
matrix<float, 16, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 16, 16> transpose_test_matrix;
cmtl::Transpose_16x16(test_matrix.select_all(), transpose_test_matrix.select_all());
5.6.7 ReverseTranspose16x16¶
Limited testing
Reverse transpose for 16x16 matrix
Description: Perform a reverse transpose on a 16x16 matrix, transforming it to a different output matrix. Note: reverse transpose is not an inverse transpose (which is the same as a transpose), but instead a transpose about the other diagonal than the normal transpose.
Author: Danny Barash, Chaim Rand
Functions:
template<T> void ReverseTranspose_16x16(matrix_ref<T,16,16> in,
matrix_ref<T,16,16> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| in | The input matrix (matrix_ref<T,16,16>) |
| out | The output matrix (matrix_ref<T,16,16>) |
Example:
matrix<float, 16, 16> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 16, 16> reverse_transp_test_matrix;
cmtl::ReverseTranspose_16x16(test_matrix.select_all(),
reverse_transp_test_matrix.select_all());
5.6.8 Transpose_8x8¶
Limited testing
Transpose for 8x8 matrix
Description: Perform a transpose on an 8x8 matrix, transforming it to a different output matrix
Author: Michele Casula
Functions:
template<T> void Transpose_8x8(matrix_ref<T,8,8> in,
matrix_ref<T,8,8> out);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| In | The input matrix (matrix_ref<T,8,8>) |
| Out | The output matrix (matrix_ref<T,8,8>) |
Example:
matrix<float, 8, 8> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 8, 8> transpose_test_matrix;
cmtl::Transpose_8x8(test_matrix.select_all(),
transpose_test_matrix.select_all());
5.6.9 map¶
Limited testing
Generic square matrix mapping
Description: A generic square matrix mapping function. A mapping vector provides the source for mapping each element. For function T(x) -> T(mapping(x)) = x e.g. mapping for 2x2 90 deg clockwise turn: mapping = { 2, 0, 3, 1 }
Author: Danny Barash, Chaim Rand
Functions:
template<T, uint W> void map(matrix_ref<T, W,W> in,
matrix_ref<T, W,W> out,
vector_ref<ushort, W*W> mapping);
| Parameters | |
|---|---|
| T | The type of the matrix elements |
| W | The width and height (rows and columns) for the square matrix |
| In | The input matrix (matrix_ref) |
| Out | The output matrix (matrix_ref) |
| mapping | The mapping vector (vector_ref). Elements proceed in row order (e.g. row 0 is defined, then row 1 etc) |
Example:
matrix<float, 2, 2> test_matrix;
// Set up the values in test matrix in some way
matrix<float, 2, 2> map_test_matrix;
vector<ushort, 4> idx;
idx[0] = 3;
idx[1] = 1;
idx[2] = 2;
idx[3] = 0;
cmtl::map(test_matrix.select_all(), map_test_matrix.select_all(), idx.select_all());
5.7 Init and assignment¶
5.7.1 cm_vector_assign¶
Initialise a vector with some simple rules
Description: Initialise a vector with a sequence of values defined using an initial value and a step.
Functions:
template<T, uint Size> void cm_vector_assign(vector_ref<T,Size> v,
int InitValue, int Step);
| Parameters | |
|---|---|
| T | The type of the vector elements |
| Size | The size of the vector |
| InitValue | The value to assign to the first element in the vector |
| Step | The amount to increase by for each subsequent element assigned |
Example:
vector<int, 100> test_vector;
cmtl::cm_vector_assign(test_vector.select_all(), 20, 10);
// Assigns vector values 20, 30, 40, ... 1000, 1010
5.7.2 cm_matrix¶
Macro to create and initialize a matrix
Description: Create and initialize a new matrix and initialize with some simple values in an optimal way.
Functions:
#define cm_matrix(M, T, R, C, I, S)
| Parameters | |
|---|---|
| M | Name of the matrix to be created |
| T | Type of the matrix to be created |
| R | Number of rows in the new matrix |
| C | Number of columns in the new matrix |
| I | Initial value for the new matrix |
| S | Step value between each element |
Example:
cm_matrix(test_matrix, short, 10, 10, 1, 2)
// Assigns a matrix with values 1, 3, 5 etc. (starting row 0, col 0,
// row 0, col 1 and so on
5.7.3 cm_vector¶
Macro to create and initialize a vector
Description: Create and initialize a new vector and initialize with some simple values in an optimal way.
Functions:
#define cm_vector(M, T, N, I, S)
| Parameters | |
|---|---|
| M | Name of the vector to be created |
| T | Type of the vector to be created |
| N | Number of elements in the new vector |
| I | Initial value for the new vector |
| S | Step value between each element |
Example:
cm_vector(test_vector, char, 20, 20, -1)
// Assigns a vector with values 20, 19, 18 etc
5.8 Extended math¶
5.8.1 cm_atan2_fast¶
Fast atan2
Description: Fast atan2 implementation for various input types (see functions for details). The results of this call are generated more quickly but are less accurate than the standard atan2 function. It is only accurate up to 0.01, where cm_atan2 is precise up to 0.00001. The flag parameter can be used to set the execution mode (e.g. SAT bit) in the same way as other intrinsic functions.
Functions:
template <uint R, uint C> matrix<float,R,C> cm_atan2_fast(
matrix<float,R,C> y, matrix<float,R,C> x,
const uint flags = 0);
template <uint R, uint C> matrix<float,R,C> cm_atan2_fast(
matrix_ref<float,R,C> y,
matrix_ref<float,R,C> x,
const uint flags = 0);
template <uint N> vector<float,N> cm_atan2_fast(vector<float,N> y,
vector<float,N> x,
const uint flags = 0);
template <uint N> vector<float,N> cm_atan2_fast(vector_ref<float,N> y,
vector_ref<float,N> x,
const uint flags = 0);
template <typename T> float cm_atan2_fast(T y, T x,
const uint flags = 0);
| Parameters | |
|---|---|
| R | Number of rows (matrix variant) |
| C | Number of columns (matrix variant) |
| N | Number of elements (vector variant) |
| T | Type for atan2 parameters (scalar variant) |
| y | y parameter for standard atan2(y,x) mathematical function |
| x | x parameter for standard atan2(y,x) mathematical function |
| flags | Set the execution mode flags (e.g. SAT bit). Defaults to 0 |
Example:
matrix<float, 16, 16> y, x;
// Set up the y and x values in some way ...
Matrix<float, 16, 16> result = cmtl::cm_atan2_fast(y, x);
5.8.2 cm_atan2¶
Fast atan2
Description: Fast atan2 implementation for various input types (see functions for details). The results of this call are generated less quickly but are more accurate than the standard cm_atan2_fast function. It is accurate up to 0.00001, where cm_atan2 _fast is only precise up to 0.01. The flag parameter can be used to set the execution mode (e.g. SAT bit) in the same way as other intrinsic functions.
Functions:
template <uint R, uint C> matrix<float,R,C> cm_atan2(
matrix<float,R,C> y, matrix<float,R,C> x,
const uint flags = 0);
template <uint R, uint C> matrix<float,R,C> cm_atan2(
matrix_ref<float,R,C> y,
matrix_ref<float,R,C> x,
const uint flags = 0);
template <uint N> vector<float,N> cm_atan2(vector<float,N> y,
vector<float,N> x,
const uint flags = 0);
template <uint N> vector<float,N> cm_atan2(vector_ref<float,N> y,
vector_ref<float,N> x,
const uint flags = 0);
template <typename T> float cm_atan2(T y, T x,
const uint flags = 0);
| Parameters | |
|---|---|
| R | Number of rows (matrix variant) |
| C | Number of columns (matrix variant) |
| N | Number of elements (vector variant) |
| T | Type for atan2 parameters (scalar variant) |
| Y | y parameter for standard atan2(y,x) mathematical function |
| X | x parameter for standard atan2(y,x) mathematical function |
| Flags | Set the execution mode flags (e.g. SAT bit). Defaults to 0 |
Example:
matrix<float, 16, 16> y, x;
// Set up the y and x values in some way ...
Matrix<float, 16, 16> result = cmtl::cm_atan2(y, x);
5.8.3 cm_fmod¶
Floating point remainder function
Description: Floating-point Remainder. This is the same as C standard function fmod(), namely: cm_fmod(y,x)=r, if y = qx + r where q is an integer and r<x. The flag parameter can be used to set the execution mode (e.g. SAT bit) in the same way as other intrinsic functions.
Functions:
template <uint R, uint C> matrix<float,R,C> cm_fmod (
matrix<float,R,C> y, matrix<float,R,C> x,
const uint flags = 0);
template <uint R, uint C> matrix<float,R,C> cm_fmod(
matrix_ref<float,R,C> y,
matrix_ref<float,R,C> x,
const uint flags = 0);
template <uint N> vector<float,N> cm_fmod(vector<float,N> y,
vector<float,N> x,
const uint flags = 0);
template <uint N> vector<float,N> cm_fmod(vector_ref<float,N> y,
vector_ref<float,N> x,
const uint flags = 0);
template <typename T> float cm_fmod(T y, T x,
const uint flags = 0);
| Parameters | |
|---|---|
| R | Number of rows (matrix variant) |
| C | Number of columns (matrix variant) |
| N | Number of elements (vector variant) |
| T | Type for fmod parameters (scalar variant) |
| Y | y parameter for standard fmod(y,x) mathematical function |
| X | x parameter for standard fmod(y,x) mathematical function |
| Flags | Set the execution mode flags (e.g. SAT bit). Defaults to 0 |
Example:
matrix<float, 16, 16> y, x;
// Set up the y and x values in some way ...
Matrix<float, 16, 16> result = cmtl::cm_fmod(y, x);
5.8.4 cm_floor¶
Floating point floor function
Description: Produces the largest integer not greater than input operand (round down) – this is effectively the same functionality as cm_rndd. This is the same as C standard function floorf(). The flag parameter can be used to set the execution mode (e.g. SAT bit) in the same way as other intrinsic functions.
Functions:
template <typename RT, uint R, uint C> vector<RT, R*C> cm_floor(
const matrix<float,R,C> src,
const uint flags = 0);
template <typename RT, uint SZ> vector<RT, SZ> cm_floor(
const vector<float,SZ> src,
const uint flags = 0);
template <typename RT> RT cm_floor(const float src,
const uint flags = 0);
| Parameters | |
|---|---|
| RT | Return type (elements of return object – scalar, vector or matrix) – usually float |
| R | Number of rows (matrix variant) |
| C | Number of columns (matrix variant) |
| SZ | Number of elements (vector variant) |
| src | Input parameter which will be floor’ed |
| flags | Set the execution mode flags (e.g. SAT bit). Defaults to 0 |
Example:
matrix<float, 16, 16> x;
// Set up the x values in some way ...
matrix<float, 16, 16> result = cmtl::cm_floor(x);
5.8.5 cm_ceil¶
Floating point ceil function
Description: Produces the smallesT integer not less than input operand (round up) – this is effectively the same functionality as cm_rndu. This is the same as C standard function ceilf(). The flag parameter can be used to set the execution mode (e.g. SAT bit) in the same way as other intrinsic functions.
Functions:
template <typename RT, uint R, uint C> vector<RT, R*C> cm_ceil(
const matrix<float,R,C> src,
const uint flags = 0);
template <typename RT, uint SZ> vector<RT, SZ> cm_ceil(
const vector<float,SZ> src,
const uint flags = 0);
template <typename RT> RT cm_ceil(const float src,
const uint flags = 0);
| Parameters | |
|---|---|
| RT | Return type (elements of return object – scalar, vector or matrix) – usually float |
| R | Number of rows (matrix variant) |
| C | Number of columns (matrix variant) |
| SZ | Number of elements (vector variant) |
| src | Input parameter which will be ceil’ed |
| flags | Set the execution mode flags (e.g. SAT bit). Defaults to 0 |
Example:
matrix<float, 16, 16> x;
// Set up the x values in some way ...
matrix<float, 16, 16> result = cmtl::cm_ceil(x);
Appendix A Media Kernel Example¶
Linear Filter Example¶
Linear filter effect illustration¶
==> linear filter ==>
Pseudo code¶
C for Metal implementation¶
_GENX_MAIN_ void
linear(SurfaceIndex ibuf, SurfaceIndex obuf, uint h_pos, uint v_pos)
{
// declare a 8x32 input matrix of uchar elements
matrix<uchar, 8, 32> in;
// declare a 6x24 output matrix of uchar elements
matrix<uchar, 6, 24> out;
matrix<float, 6, 24> m;
// C for Metal intrinsic to read the input matrix via dataport
read(ibuf, h_pos*24, v_pos*6, in);
// Compute the sums of neighbor elements
m = in.select<6,1,24,1>(1,3);
m += in.select<6,1,24,1>(0,0);
m += in.select<6,1,24,1>(0,3);
m += in.select<6,1,24,1>(0,6);
m += in.select<6,1,24,1>(1,0);
m += in.select<6,1,24,1>(1,6);
m += in.select<6,1,24,1>(2,0);
m += in.select<6,1,24,1>(2,3);
m += in.select<6,1,24,1>(2,6);
// Compute the average
out = m * 0.111f;
// Write the result to dataport
write(obuf, h_pos*24, v_pos*6, out);
}
Appendix B VME Interface Access Macros¶
VME Interface Access Macros for Gen6¶
To facilitate the use of VME interface, C for Metal provides the following access macros for setting up the input parameters, as well as retrieving the output results.
List of Input Access Macros¶
There are three formats for the input access macros:
VME_SET_DataFieldName(p, v): set the specified data field in the input payload “p” to value “v”.
This macro may take multiple value fields, such as start center X and Y position. Note that in this case the value should be set as unsigned hexadecimal and it is the programmer’s responsibility to interpret the value properly.
VME_SET_BitFieldName(p): set the specified input payload bit field to TRUE.
VME_CLEAR_BitFieldName(p): set the specified input payload bit field to FALSE.
The type of the input payload variable “p” is pre-defined as follows:
- typedef matrix<unsigned char, 4, 32> vme_InputMrfType;
The expected value or type for the input value “v” is provided in the following list wherever appropriate. For further information on the input payload content and the data field description, please refer to reference [4].
List of Output Access Macros¶
The output access macro is defined in the following format:
- VME_GET_DataFieldName(p, v): retrieve the value of the specified filed in the output data matrix “p” and assign it to the variable “v”.
For “run_vme_inter” and “run_vme_all”, the type of the output data matrix “p” is defined as follows:
- typedef matrix< unsigned char, 4, 32> vme_OutputGrfType;
For “run_vme_intra”, the type of the output data matrix “p” is defined as follows:
- typedef matrix<unsigned char, 1, 32> vme_OutputGrfShortType;
The expected return value or type for “v” is provided in the following list wherever appropriate. For further information on the output content and the data field description, please refer to reference [4].
VME Interface Access Macros for Gen7_5¶
The formats of input/output access macros are similar to those defined for Gen6. The types of input/output data variables are specified in Section 4.12.3.
List of Input Access Macros¶
List of Output Access Macros¶
VME Interface Access Macros for Gen8¶
The formats of input/output access macros are similar to those defined for Gen6. The types of input/output data variables are specified in Section 4.12.4.


Get Process Graph Name Use-Case.Description:Gets the name of a Process Graph.Assumptions:None.Exceptions:None.


Teach us Lord, to number our days. For it is the appointed unto man, once to die as God Almighty in all His wisdom called from labor to reward MRS. SANDRA ELAINE CHASE, on Wednesday, April 26th, 2017 at George Washington University Hospital in Washington, DC. Her maiden name was Sandra Elaine Newman. She was born in Norfolk, VA on April 2nd, 1946. She was the daughter of Vivian Smith and Willie Newman.
Sandra always pursued higher education. She was a successful graduate of the Calvary Bible Institute at Greater Mount Calvary Holy Church. She received her certification in Bible Studies and Ministry. She loved serving the Lord and others. She was a member of the Greater Mount Calvary Deaconess board, health conditions hindered her recent participation. She was one of the original members of Marriet's Children which helped women suffering from drug and alcohol abuse led by Dr. Barbara Reynolds. She also participated in the Evangelistic Outreach Ministry with Evengelist Carolyn Joyner. Her most recent service in the Lord was being an avid supporter and re-source for Withered Hand Ministry with Elder Janice Bennett, Visionary.
Sandra was a devoted Bible reader. She loved to study the ins and outs of God's word. She had so many bibles, concordances and books about the Lord, they filled her bookshelves ad storage containers in her home. She could never get enough of re-searching every word in the bible.
She loved being fashionable. Her favorite colors were orange and gold. She adored her collection of Angels and Miniond from Despicable Me. She tried to collect anything that affiliated with these characters. They made her very happy!
With the Lord's guidance and help, she conquered many struggles in her life which for her started at a very young age. One of those struggles was drug and alchol abuse. After years of fighting the battle alone she decided to admit herself into a Christian based drug rehabilitation program called New Life for Youth. While recovering in this program she gave fer life to Jesus Christ totally and completly. After over a year of she successfully completing this program and returning to her children a clean and sober person, filled with the Holy Spirit!!! She is the reason why all her children have given their lives to Christ as well.
Sandra has joined her husband of 26 years, John Larry Sims, and her oldest son La-mont Foster in Heaven. She leacves to mourn; 3 sons - Kyle Sims, Charles Foster Jr., and Jerome Foster, 2 daughters- Artemesia Foster and Johnell (Foster) King; 13 grandchildren- LaMesia Foster, Lamont Washington, Octavia Bradley ,


--- layout: post title: Tab Sweep tags: - Tumble status: publish type: post published: true meta: dsq_thread_id: '17413868' ---
I think my list is indicative that I divide my attention too thin:


It is important to understand how to use the logging and tracing functionality. If this doesn't resolve your issue, you should clone this repo and add references to the necessary projects to debug directly. See here for building the solution. If the issue still cannot be resolved, please log a GitHub issue, but please make sure you've followed these steps before reporting an issue.
Logging
Device.Net uses the ASP .NET Core logging infrastructure. It would help if you read about this system here. All devices accept an ILogger
, and device factories accept an ILoggerFactory
. When factories create new devices, they inject a logger into each one. With 3rd party libraries, you can write to file or send telemetry to a cloud service like Application Insights. We highly recommend that you send telemetry data to a central location so that you can diagnose issues with your clients' software and devices without having access to their computer.
Debug Tracing
If you set the minimum level of the logs to Trace
or below, logs will output all data transferred to/from the device. The Windows sample logs to the debug window. This is how we initialize logging to the debug window:
_loggerFactory = LoggerFactory.Create((builder) =>
{
builder.AddDebug();
builder.SetMinimumLevel(LogLevel.Trace);
});
When reporting issues, please look at the Debug output window, copy the output, and paste it into the GitHub issue.
Advanced Use
Check out ASP.NET Core logging frameworks such as Serilog, log4net, NLog and the Application Insights SDK.
I Can't See My Device
Run the Windows sample. You should see your device's path appear at the top of the console. If it does not, check the logs and turn on break on all exceptions (see below). The log should tell you what went wrong when the library attempted to detect the device.
Before Reporting an Issue
If anything goes wrong in the framework, the app should throw an exception. To catch Exceptions and obtain a stack trace, you should turn on break on all exceptions in Visual Studio to catch the exact location where the problem is occurring. Please see this article . Please take screenshots of where the Exception issue is occurring and include those in any GitHub reports.


{{{page_description}}}
Weekday Filler is a weblog heavily influenced by MetaFilter with a dash of reddit.
Please post something, suggest features, report bugs, or read more about WeFi.
Fork me on github!


Gartner defines Internet of Things "is the network of physical objects that contain embedded technology to communicate and and sense or interact with their internal states or external environment." As per international Data Corporation (IDC) press release "Internet of things is poised to change Everything",The internet of Things (IoT) represents a new construct in the information and communication technology world that is occupying the minds of IT vendors,service providers and system integrators as it represents huge potential for new streams of revenue and new customers.
Delivering Business with highest level of integrity and core societal values Customer Focus Create People First Organization Create great workplace culture and stable employment
Enriching life Timeless company Delivering High Quality Products and Solutions Establish ever lasting long term internal and external partnerships.


| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(time_type), | public | :: | time_obs | ||||
| character(len=20), | public | :: | monthstring | = | 'Month' | ||
| character(len=20), | public | :: | daystring | = | 'Day' | ||
| character(len=20), | public | :: | hourstring | = | 'Hour' | ||
| character(len=20), | public | :: | doystring | = | 'DoY' | ||
| character(len=20), | public | :: | neestring | = | 'NEE_or_fMDS' | ||
| character(len=20), | public | :: | neeQCstring | = | 'NEE_or_fMDSqc' | ||
| character(len=20), | public | :: | lestring | = | 'LE_f' | ||
| character(len=20), | public | :: | leQCstring | = | 'LE_fqc' | ||
| character(len=20), | public | :: | hstring | = | 'H_f' | ||
| character(len=20), | public | :: | hQCstring | = | 'H_fqc' | ||
| integer, | public | :: | monthindex | ||||
| integer, | public | :: | dayindex | ||||
| integer, | public | :: | hourindex | ||||
| integer, | public | :: | doyindex | ||||
| integer, | public | :: | neeindex | ||||
| integer, | public | :: | neeQCindex | ||||
| integer, | public | :: | leindex | ||||
| integer, | public | :: | leQCindex | ||||
| integer, | public | :: | hindex | ||||
| integer, | public | :: | hQCindex | ||||
| integer, | public | :: | month | ||||
| integer, | public | :: | day | ||||
| real(kind=r8), | public | :: | hour | ||||
| real(kind=r8), | public | :: | doy | ||||
| real(kind=r8), | public | :: | nee | ||||
| integer, | public | :: | neeQC | ||||
| real(kind=r8), | public | :: | le | ||||
| integer, | public | :: | leQC | ||||
| real(kind=r8), | public | :: | h | ||||
| integer, | public | :: | hQC |