Brahma is an open source library for parallel computing, written by C # and supported to run on a variety of processors. Currently, Brahma contains only one graphics processor (GPU) module, but its modular structure can support more kinds of processors. With Brahma, statements in the same C # method can run on both the CPU and the GPU without the need for additional code.
Brahma performs parallel computations by converting LINQ statements into target processor code, and the generated code differs according to the target processor. For example, for DirectX, a high level shading Language is generated, and OpenGL shading Language is generated for OpenGL. To improve performance, LINQ queries are compiled only once, and then run as many times as needed
The following code multiplies the elements of an array by 2 in parallel:
Create a calculated object
var computationprovider = new Computationprovider ();
Create a parallel array and populate the data
var data = new Dataparallelarray (Computationprovider,
New[] {0f, 1f, 2f, 3f, 4f, 5f, 6f});
Compiling LINQ Queries
CompiledQuery query = computationprovider.compile>
(
D => from value in D
Select value * 2f
);
Executing queries on data
IQueryable result = Computationprovider.run (query, data);
Print results
foreach (float value in result)
Console.WriteLine (Result[i]);
Releasing resources
Computationprovider.dispose ();
Data. Dispose ();
Result. Dispose ();
Brahma source code and binaries follow Eclipse public License 1.0.
View English Original: LINQ on GPU with Brahma