Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

ippsGenCRCOptPoly_8u

Computes optimization table for ippsCRC_8u.

Syntax

IppStatus ippsGenCRCOptPoly_8u(Ipp64u* poly, Ipp8u optPoly[128]);

Include Files

ippe.h

Domain Dependencies

ippcore.h

Libraries

ippe.lib

Parameters

poly

CRC polynomial with explicit leading 1. Indicates CRC length: 8/16/24/32 bits.

optPoly

The initialized data table (NULL, by default).

Description

The ippsGenCRCOptPoly_8u function is auxiliary for ippsCRC_8u and computes a table for low-level optimization in ippsCRC_8u. You can use this function in the initialization procedure of the application.

Low-level ippsCRC_8u optimization requires special tables for every poly value. This function calls the optimized code only for the fixed set of polynomials by default and returns the ippStsNoErr status. If such table is not available for poly, it calculates CRC using non-optimized code and returns the ippStsNonOptimalPathSelected warning.

To compute CRC for an arbitrary polynomial with low-level optimization, you need to initialize the optPoly table first with the ippsGenCRCOptPoly_8u function and transfer optPoly into ippsCRC_8u.

Example

//   Computing the table for the function that does not support CRC16 with the 0x8005 polynomial.
int main()
{
    Ipp8u* src = "123456789";
    IppStatus status;
    Ipp32u CRC;
    Ipp64u poly = 0x18005;
    Ipp32u init = 0;
    Ipp8u optPoly[128];

    //function returns ippStsNonOptimalPathSelected
    status = ippsCRC_8u(src, 9, poly, NULL, init, &CRC);
    printf("status = '%s'\n", ippGetStatusString(status));
    printf("CRC=0x%x\n", CRC);

    //function returns ippStsNoErr and
    //calls optimized code
    status = ippsGenCRCOptPoly_8u(poly, optPoly);
    status = ippsCRC_8u(src, 9, poly, optPoly, init, &CRC);
    printf("status = '%s'\n", ippGetStatusString(status));
    printf("CRC=0x%x\n", CRC);

    return 0;
}

The result:

status = 'The function is inefficient due to the combination of input parameters'
CRC=0xfee8
status = 'ippStsNoErr: No errors'
CRC=0xfee8
//   Computing CRC6
int main()
{
    Ipp8u* src = "123456789";
    IppStatus status;
    Ipp32u CRC;
    Ipp64u poly = 0x61;//CRC6 polynomial;
    Ipp32u init = 0x0;
    Ipp8u optPoly[128];

    //Function calculates crc8/crc16/crc24/crc32
    //Shift 2 bits left, CRC6 -> CRC8
    poly <<= 2;
    status = ippsGenCRCOptPoly_8u(poly, optPoly);
    status = ippsCRC_8u(src, 9, poly, optPoly, init, &CRC);
    printf("status = %d, '%s'\n", status, ippGetStatusString(status));
    //Shift 2 bits right, CRC8 -> CRC6 
    printf("crc6=%x\n", CRC >> 2);
    return 0;
}

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error if the pointer to the source vector is NULL.

ippStsAlgTypeErr

Indicates an error if the most significant 1 bit is in the wrong position.