concept component in category opencl

appears as: components, components, component, The components
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.

  • Computational vector— A data structure that contains multiple elements of the same data type. During a vector operation, each element (called a component) is operated upon in the same clock cycle.
  • Processing vectors isn’t just simpler than processing data with arrays, it’s faster. And pay attention to the new data type: float4. As you might guess, any variable declared with this type can hold four floats. Elements within a vector are commonly called components, and we’ll use this term throughout this book.

    OpenCL provides three simple ways to select the components of a vector: number-indexing, letter-indexing, and hi/lo/even/odd. Number-indexing is useful for accessing components of vectors in general applications, whereas letter-indexing is more suitable for vectors in graphics applications. The hi, lo, even, and odd suffixes become helpful when you want to access half of a vector’s components at a time. Each method uses a dot-notation similar to that used to access the fields of a composite data structure.

    You can use all four letters if a vector contains four components. Otherwise, you can only use the first N letters to access components of an N-component vector. The code in table 4.7 shows how to use letters to access components of the following vector:

    float4 coord = (float4)(3.0, 5.0, 7.0, 9.0);
    Table 4.7. Accessing components of a vector using letters

    Code

    Result

    float a = coord.x; Sets a to 3.0
    float b = coord.y; Sets b to 5.0
    float c = coord.z; Sets c to 7.0
    float d = coord.w; Sets d to 9.0
    Figure C.1. Selecting components for the MinGW installation