CUDA and OpenCL recursion

9

Is it possible to work with recursion in parallel when working with technologies unique to multielement using the video card as instrument CUDA and OpenCL ? if so, how do we synchronize and pass values, if not how to simulate this recursion since many operations in estruturas de dados as Árvores of all types use recursion to obtain the data. >

Cuda is an extension to the C / C ++ programming language.

OpenCL is an architecture for writing programs that work on heterogeneous platforms, includes a language (based on C99) to write kernels (functions executed on OpenCL devices)

    
asked by anonymous 23.05.2015 / 16:51

1 answer

4

SIMD technologies (single-source source, multiple data sources) usually do not have the ability to perform asynchronous tasks, as in the case of recursive functions.

Typical CPUs have a reasonable amount of working memory (registers and CACHE) for a small number of CPUs (1, 2, 4 or 8), and these CPUs act independently, executing different instructions simultaneously (MIMD - Multiple instruction sources, multiple data sources. Typical processors are able to mount high data stacks of executed statements, allowing several recursive iterations of the same function. For this, they need complex and intelligent instruction pointers to store multiple return points.

SIMD co-processors, such as GPGPUs, give up such complexities and sophistica- tions for the number of logical and arithmetic units. Imagine a device that would allow a single person to push the same operation button on several calculators, even if they could enter different values in each one. The same operation is performed simultaneously in several values. The cost of such acceleration is the sophistication of the instruction read and interpret system, which does not have the ability to manage multiple return pointers needed for recursion use.

However, it is possible to work in parallel in GPGPUs in recursive functions, in the case that the IF clause and other operations of the recursive function are executed in CPU, being internal calculations of each iteration of the function performed in GPGPU, completely alienated from the origin of the instructions of the main program. As an example, the pseudo-code below.

function calcularDados( var dados, var localidade[])    //GPGPU
    return calcular(localidade, dados)                  //GPGPU

function souRecursiva(var dados)            //CPU
    if dados != condição_final then         //CPU
        GPGPU <<dados, calcularDados>> dadosResposta    //GPGPU
        return souRecursiva(dadosResposta)  //CPU
    else                                    //CPU
        return dados                        //CPU
    
11.09.2015 / 05:55