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]);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.