LINQ on GPU with Brahma

| by Abel Avram Follow 7 Followers on May 04, 2010. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Brahma is an open source C# library that provides support for parallel computations running on a variety of processors. Currently, Brahma has a GPU provider but its modular structure allows using different providers for other types of processors. One C# method can contain both statements running on CPU and GPU without additional glue code.

Brahma performs parallel computations by transforming LINQ statements into programs that run on the target processor. The program generated contains High Level Shading Language statements if it was targeted for DirectX or OpenGL Shading Language statements if it was targeted for OpenGL. For performance improvements LINQ queries are compiled once and used many times as necessary.

The following code multiplies the values in an array by 2 in parallel: 

// Create the computation provider
var computationProvider = new ComputationProvider();

// Create a data-parallel array and fill it with data
var data = new DataParallelArray<float>(computationProvider, 
    new[] { 0f, 1f, 2f, 3f, 4f, 5f, 6f });

// Compile the query
CompiledQuery query = computationProvider.Compile<DataParallelArray<float>>
    d => from value in d
    select value * 2f

// Run the query on this data
IQueryable result = computationProvider.Run(query, data);

// Print out the results
foreach (float value in result)

// Get rid of all the stuff we created

The source code and binaries are available under Eclipse Public License 1.0.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Brahma ??! by Rodolfo de Paula

Looks cool, but with this name it would be cool anyway: Brahma is a popular trademark here in Brazil and also a company within that group that brought Budweiser.

Re: Brahma ??! by Sanket Naik

As per Hindu mythology, Brahma is the one who is the conciever / Creator of the Universe.

Re: Brahma ??! by Rodolfo de Paula

Thanks for sharing it, Sanket

I will search for some books about Hindu mythology. Beside being an interesting subject, I have another motivation: this year my sister married a guy from India.

I also will keep drinking beer from Brahma company ;)

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

3 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you