вторник, 23 октября 2012 г.

Conflux


Conflux is a self-contained library that is capable of transforming parallel algorithms written in C# and executing them on GPU and/or CPU.
As of now Conflux is a proof of concept that successfully executes simple parallel algorithms written directly in C# (without any shader code in plain strings, without any interop with CUDA driver, just high-level code).
Here's how Conflux works:
You encode a parallel algorithm using C#, debug it as usual and so on.

Now you write something like this (code is simplified a bit): Conflux.RunOnGPU<Algorithm>(args). After that, the algorithm is decompiled, analyzed, transformed to fit NVIDIA CUDA architecture and executed on GPU. Of course, not all syntactical constructs of C# are supported due to architectural restrictions of GPUs, though Conflux supports everything that can be efficiently mapped to CUDA 3.1.

If end-user doesn't have a GPU, you can provide a fallback option to execute the algorithm on a multi-core CPU. This looks like the following (again, code is a bit simplified): if (Cuda.GpuCount == 0) Conflux.RunOnCPU<Algorithm>(args). Nothing more is required - Conflux will transparently generate marshalling and computational code that's appropriate for this architecture. When you run algorithms on CPU, Conflux also has a possibility to generate debuggable code, so that you can set breakpoints within your computational kernel, watch variables and so on.

Embedding parallel algorithms into high-level language as opposed to being forced to use non-debuggable and non-refactorable strings of shader-like code.
Support for traditional control flow (ifs, loops, subroutines) and data structures (arrays work right now, structs coming soon).
JIT-compilation of computational kernels (some tools that implement #1-2 do all code generation at compile-time - Conflux defers this till the runtime and can leverage all the benefits of such approach, e.g. adjust its backend for target hardware).

There are similar projects, though the combination of the following features makes Conflux unique: