
Pattern: Data Parallelism 243
Listing 11.5: Binary thresholding.
int x [ m ][n ];
int i , j ;
for ( i =0; i <m ; i ++)
for ( j =0; j <n ; j ++)
if ( x [i ][j ] < t)
x[i ][ j] = 0;
else
x[i ][ j] = 1;
in the function invocation. Another approach is to use languages that pro-
vide syntax for invoking these small functions (often called kernels) over the
whole array using specialized syntax. New language extensions such as CUDA
and OpenCL provide tools for programmers to do these types of operations.
Unfortunately, these languages are nearly as concise as those that provide
elemental functions and often require the programmer to do many low-level
operations to ...