concept integer in category opencl

appears as: n integer, integers, integer, integer
OpenCL in Action: How to Accelerate Graphics and Computation

This is an excerpt from Manning's book OpenCL in Action: How to Accelerate Graphics and Computation.

The last two parameters are easy to understand. The user_data parameter can point to any data type, from a char to an int to a table of environment variables. This data is accessed by the callback function when an error occurs. The error parameter identifies an integer that will hold the function’s error code. If the cl_context is created successfully, this will be set to 0.

  • integer—This argument can be any integer type: uchar, char, ushort, short, uint, int, ulong, and long
  • 5.5.1. Adding and subtracting integers

    OpenCL provides the + and - operators for addition and subtraction, but these may not be sufficient for all cases. Table 5.10 lists the OpenCL functions that add and subtract integers.

    Table 5.10. Integer addition functions

    Function

    Purpose

    integern add_sat(integern x,
    integern y)
    Returns x + y with saturation
    integern hadd(integern x,
    integern y)
    Returns x + y, shifted right by 1 to prevent overflow
    integern rhadd(integern x,
    integern y)
    Returns x + y + 1, shifted right by 1 to prevent overflow
    integern sub_sat(integern x,
    integern y)
    Returns x – y, saturating the result

    When performing integer arithmetic, the fundamental question is what to do when a result requires more memory than either of the operands. This condition is called arithmetic overflow. In the case of addition, overflow occurs when the sum of two integers exceeds the maximum value for the data type or falls below the minimum value. In subtraction, this occurs when the operands have different signs, and the subtraction produces a value that exceeds the maximum or falls below the minimum.