NEWS

Monday, May 30, 2011

Microsoft Accelerator Research Project

As you know we can great performance benefits from the new .net 4.0 features like Task Parallel Library (TPL), Coordination Data Structures (CDS) and Parallel LINQ (PLINQ). But all of these features revolve around Task Parallelism. Now what about data parallelism? Should I be writing a Parellel.ForEach just to add elements of an integer array?




To provide a tool, for this need, in the toolkit of developer, there has been work going on in Microsoft for sometime. This is called Microsoft Accelerator Project. The whole idea around Accelerator is to provide implicit parallelism for array processing through functional constructs provided through managed wrapper in any .net language.
 
In this article I would not be discussing about the detailed architecture of Acclerator. I would just be presenting the introduction of this framework so that an application developer might be using it easily using the functional programming constructs provided in the toolkit. In parallel processing world, a vector is a one-dimensional array. We have always been in need to exploit parallel operations in our software. Using accelerator, you would really have the following resulting logical behavior.


var arr3 = arr1 + arr2;


Here arr1 and arr2 may be two numeric arrays. This is evident from above statement that Accelerator is based on SIMD (Single Instruction Multiple Data) architecture of Flynn’s taxonomy.

Target Platforms:


When Accelerator was first introduced, the whole idea was to use the capabilities (large numbers of arithmetic units) of graphics processor for computations even in non-graphic applications to gain huge speed-ups. But after the introduction of multicore machines in general use, it was updated to take advantage of multiple cores. Now the developer has option to use either of graphics processor (GPU) or multiple main cores in the machine.
With Acclerator, we can target the code generation for two platforms. They are as follows:

1.DX9: To run the computation on GPU. When we specify this target then the code is JIT compiled into pixel shader code and pushed to GPU for processing. After computation, the result is pushed back to the CPU and the result is available for the main program.


2.X64MulticoreTarget: To run the computation on a multicore CPU (only 64 bits).

How it works?


Accelerator uses delayed processing (Lazy computations) to perform its computations. It keeps on adding all the operations in the form of a graph. As the framework receives instructions to execute the computations, it translates the graph based on the platform selected (DX9 or X64MulticoreTarget). It sends the generated code the target and receives result where it gets executed. These results are then provided to the calling program.


This is the same process as in LINQ. It maintains the operations and operands in the form of Directed Acyclic Graphs (DAG) in order to execute them later on. This DAG is called Expression Graph. After computation the Data Parallel object is converted to System.Object object (Array or Bitmap).


The idea is load your arrays in DataParallelArray objects (discussed later). Perform computations on them. Convert them to System.Object back when the computation is done.

 Accelerator Architecture:

ParallelArray:
The architecture of accelerator is based on ParallelArray class. This is the base class of 4 classes available. They are IntParallelArray, FloatParallelArray, Float4ParallelArray and BoolParallelArray. They are further specialized with their disposable versions like DisposableIntParallelArray, DisposableFloatParallelArray, DisposableFloat4ParallelArray and DisposableBoolParallelArray.

ParallelArrays:




It is a set of static methods for parallel operations. These operations also include initialization and uninitialization CPU and GPU accelerator. Some of these operations are also available through the overloaded operators for array by Accelerator.

Exception:

The framework also supports exceptions. Currently only UnexpectedOperation exception is supported.

Using Accelerator in .net Applications:


To use accelerator in .net projects, following steps should be followed:

•Install Accelerator. The latest download (msi) can be obtained from the following Microsoft Connect page. https://connect.microsoft.com/acceleratorv2

•Add a reference of Microsoft.Accelerator.dll in your project. The library should be available in the installation directory of Microsoft Accelerator
•Add Microsoft.ParallelArrays namespace to the desired namespace. It includes all the accelerator types to write data parallel operations.

•Copy Accelerator.dll from the installation folder of Microsoft Acclerator v2 (…\Microsoft\Accelerator v2\bin\x86\Release) to the application folder. Since I am running in on an x86 machine, I have copied x86 version of the dll. You might use x64 one for a 64-bit machine.

Operations supported:




•Element Wise operations

In this kind of operation, an operation is applied between corresponding elements of an array. The dimensions of the operands should be same for this kind of operations. In the following example, we have added the elements of two float arrays. The results are available in result float array. As expected, the result is {2.0f, 4.0f, 6.0f, 8.0f, 10.0f}.





float[] arr1 = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };

float[] arr2 = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };



var acc_arr1 = new FloatParallelArray(arr1);

var acc_arr2 = new FloatParallelArray(arr2);



var acc_arr3 = ParallelArrays.Add(acc_arr1, acc_arr2);



var target = new DX9Target();

var result = target.ToArray1D(acc_arr3);



Since ‘+’ operator is overloaded, we could write the same operation as follows:



var acc_arr3 = acc_arr1 + acc_arr2;



•Reductions (sum, product, min, max etc).

Accelerator supports reduction operations using ParallelArrays. In the following example, we are obtaining sum of all elements of a float array.





float[] arr1 = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };

var acc_arr1 = new FloatParallelArray(arr1);

var acc_result = ParallelArrays.Sum(acc_arr1);



var target = new DX9Target();

var result = target.ToArray1D(acc_result);



•Conversions between Ints and Floats:

Not only we can do operations on arrays, we can also convert between them. In the following example, we are converting an int array to a float one.





int[] arr1 = { 1, 2, 3, 4 };

var acc_arr1 = new IntParallelArray(arr1);

var acc_result = ParallelArrays.ToFloatParallelArray(acc_arr1);



var target = new DX9Target();

var result = target.ToArray1D(acc_result);

To verify the actual conversion, IDE can also help during debugging.


•Logical operations:


Accelerator may be used for performing various logical operations on operands. These operations might be boolean (Not, AND, OR), comparison (Less than, GreaterThan) and selection operations (Selection). Currently most of these operations are not implemented completely.





float[] arr1 = { 1.0f, 2.0f, 3.0f, 4.0f };

float[] arr2 = { 0.0f, 1.0f, 7.0f, 3.0f };

bool[] arr3 = { false, true, false, true };



var acc_arr1 = new FloatParallelArray(arr1);

var acc_arr2 = new FloatParallelArray(arr2);

var acc_arr3 = new BoolParallelArray(arr3);



var acc_result = ParallelArrays.Cond(acc_arr3, acc_arr1, acc_arr2);

var target = new DX9Target();

var result = target.ToArray1D(acc_result);



The above code should result in {0.0f, 2.0f, 7.0f, 4.0f} in result. But currently, it has {0.0f, 1.0f, 7.0f, 3.0f} (which is definitely an issue).







•Transformations on data parallel arrays (shift, duplicate):

Some operations require transformation of arrays to be used in an operation. In the following example, we are creating an array. The elements of the result array are the sum of the element in the original array in the specified position and the element before it.





float[] arr1 = { 1, 2, 3, 4 };

var acc_arr1 = new FloatParallelArray(arr1);



var acc_result = ParallelArrays.Add(ParallelArrays.Shift(acc_arr1, -1), acc_arr1);

var target = new DX9Target();

var result = target.ToArray1D(acc_result);



Some operations require transformation of arrays to be used in an operation. In the following example, we are creating an array. The elements of the result array are the sum of the element in the original array in the specified position and the element before it.


This explains that (-1) has shifted each element 1 position to the right keeping the 1st element and truncating the last one.












•Matrix computations:

There are many matrix operations which are directly available in Acclerator. The other operations can be implemented using already existing element wise, transformation and reduction operations available.



In the following example, we are creating the transpose of a matrix.



float[,] arr1 = {

{ 1, 2, 3, 4 },

{ 1, 2, 3, 4 },

{ 1, 2, 3, 4 },

{ 1, 2, 3, 4 }

};

var acc_arr1 = new FloatParallelArray(arr1);



var acc_result = ParallelArrays.Transpose(acc_arr1);

var target = new DX9Target();

var result = target.ToArray2D(acc_result);



You can see that instead of using ToArray1D method from target, we have used ToArray2D operation. The result array should be as follows:



{

{ 1, 1, 1, 1 },

{ 2, 2, 2, 2 },

{ 3, 3, 3, 3 },

{ 4, 4, 4, 4 }

};









Application Areas:

The main areas which have potential for extensive use of Accelerator are compression and image processing. These are the areas where there is large number of array processing and matrix manipulation operations.












52 comments:

  1. My partner and I stumbled over here from a different website and thought I
    should check things out. I like what I see so now i am following you.
    Look forward to exploring your web page repeatedly.


    Feel free to visit my page ... how to detox your body
    Also see my site > how to detox your body

    ReplyDelete
  2. I think the admin of this website is really working hard
    in support of his web site, since here every information is
    quality based stuff.

    my blog post ... league of legends download

    ReplyDelete
  3. Excellent goods from you, man. I have understand your stuff previous to and you are just extremely magnificent.
    I really like what you have acquired here, really like what you're saying and the way in which you say it. You make it enjoyable and you still take care of to keep it smart. I can't wait to read much
    more from you. This is really a great site.


    My blog post ... march 11Th

    ReplyDelete
  4. Thanks for any other great article. Where else
    could anyone get that type of info in such a perfect method of writing?
    I have a presentation subsequent week, and I am
    at the look for such info.

    Here is my web-site - World Of Tanks Hack

    ReplyDelete
  5. This is a topic that is near to my heart..
    . Cheers! Where are your contact details though?

    Feel free to visit my site; starcraft 2 hack

    ReplyDelete
  6. I do not even know how I ended up here, but I believed this publish
    was once great. I don't know who you're however definitely
    you're going to a well-known blogger when you aren't already.
    Cheers!

    Also visit my blog post Http://www.mariapinto.es/

    ReplyDelete
  7. I have been surfing online more than 2 hours today,
    yet I never found any interesting article like yours.
    It's pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the internet will be a lot more useful than ever before.

    My weblog - Permanent hair straightening

    ReplyDelete
  8. I do not know if it's just me or if perhaps everyone else encountering issues with your blog. It seems like some of the written text within your posts are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too? This could be a problem with my internet browser because I've had
    this happen previously. Many thanks

    Feel free to visit my weblog: tattoo removal cream reviews

    ReplyDelete
  9. I was able to find good info from your blog posts.

    Check out my web blog recycling facts

    ReplyDelete
  10. Ridiculous story there. What happened after? Thanks!


    Look into my webpage - Permanent Hair Straightening

    ReplyDelete
  11. You should take part in a contest for one of the best blogs
    on the internet. I will recommend this site!

    Have a look at my web site: diaper rash home remedies

    ReplyDelete
  12. An outstanding share! I've just forwarded this onto a coworker who was conducting a little homework on this. And he actually ordered me breakfast simply because I discovered it for him... lol. So let me reword this.... Thanks for the meal!! But yeah, thanx for spending time to discuss this matter here on your blog.

    Also visit my page; Coconut oil for hair

    ReplyDelete
  13. Write more, thats all I have to say. Literally,
    it seems as though you relied on the video to make your point.
    You clearly know what youre talking about, why waste your intelligence on just posting videos to your site when you
    could be giving us something informative to read?


    Feel free to surf to my blog: http://Tasha6166.Xanga.com/

    ReplyDelete
  14. When someone writes an post he/she keeps the image of a user in his/her mind that how a user can be aware of it.
    Therefore that's why this post is great. Thanks!

    Feel free to surf to my web site: diarrhea remedies

    ReplyDelete
  15. Magnificent items from you, man. I have keep in mind your stuff prior to and you're simply extremely magnificent. I actually like what you have obtained right here, really like what you're saying and the way during which you assert it.
    You're making it enjoyable and you still take care of to keep it sensible. I cant wait to read far more from you. That is really a great site.

    My webpage: unknown

    ReplyDelete
  16. Informative article, just what I wanted to find.


    My web-site: Unknown

    ReplyDelete
  17. Thanks very interesting blog!

    My site :: Unknown

    ReplyDelete
  18. Hi there! I could have sworn I've been to this website before but after browsing through a few of the posts I realized it's new to me.

    Anyways, I'm certainly delighted I stumbled upon it and I'll be
    book-marking it and checking back regularly!

    Feel free to surf to my webpage - Unknown

    ReplyDelete
  19. WOW just what I was searching for. Came here by searching for ps3 jailbreak

    Here is my webpage - unknown

    ReplyDelete
  20. I don't even understand how I finished up right here, but I assumed this put up used to be good. I don't recognise
    who you are but certainly you're going to a famous blogger if you aren't already.
    Cheers!

    my web-site :: Www.youtube.com

    ReplyDelete
  21. Hey there! I know this is somewhat off topic but I
    was wondering if you knew where I could get a captcha plugin for my comment
    form? I'm using the same blog platform as yours and I'm having difficulty
    finding one? Thanks a lot!

    Feel free to surf to my site stretch marks

    ReplyDelete
  22. Great blog! Do you have any tips for aspiring writers?
    I'm planning to start my own site soon but I'm
    a little lost on everything. Would you suggest starting with a free platform like Wordpress or go for a paid
    option? There are so many choices out there that I'm completely confused .. Any suggestions? Thank you!

    My webpage; Mon Jervois

    ReplyDelete
  23. This paragraph gives clear idea designed for the new visitors of blogging,
    that really how to do blogging and site-building.

    My website: Diaper Rash Remedies

    ReplyDelete
  24. Thanks on your marvelous posting! I really enjoyed reading it, you might be a great author.
    I will be sure to bookmark your blog and may come back in the foreseeable future.
    I want to encourage you to ultimately continue
    your great writing, have a nice day!

    Here is my blog post: Tattoo removal Cream reviews

    ReplyDelete
  25. Appreciating the time and energy you put into your blog and detailed information you offer.
    It's good to come across a blog every once in a while that isn't
    the same old rehashed information. Fantastic read!

    I've bookmarked your site and I'm including your RSS feeds to my Google account.


    Take a look at my weblog Psn Code Generator

    ReplyDelete
  26. There is certainly a lot to find out about this topic. I love all the points you've made.

    Take a look at my web-site; Psn Code Generator

    ReplyDelete
  27. Excellent web site you have here.. It's difficult to find excellent writing like yours these days. I honestly appreciate people like you! Take care!!

    My web page; unknown

    ReplyDelete
  28. Thanks for finally talking about > "Microsoft Accelerator Research Project" < Liked it!

    Here is my web-site: Unknown

    ReplyDelete
  29. Pretty! This has been a really wonderful article.
    Thank you for supplying these details.

    Check out my web page Unknown

    ReplyDelete
  30. It's very trouble-free to find out any matter on web as compared to books, as I found this piece of writing at this web page.

    My homepage - Unknown

    ReplyDelete
  31. My partner and I stumbled over here different page and thought
    I should check things out. I like what I see so i am just following you.
    Look forward to looking into your web page yet again.

    Feel free to surf to my web page; Unknown

    ReplyDelete
  32. Way cool! Some extremely valid points! I appreciate you penning
    this post plus the rest of the website is really good.


    Feel free to visit my website; christianrand.healthkicker.com

    ReplyDelete
  33. Good info. Lucky me I recently found your website by accident (stumbleupon).
    I have book marked it for later!

    Feel free to surf to my homepage: pirater un compte facebook

    ReplyDelete
  34. Hurrah, that's what I was looking for, what a data! existing here at this web site, thanks admin of this website.

    Here is my blog; Generateur De Code PSN

    ReplyDelete
  35. Thanks in favor of sharing such a fastidious idea, paragraph is fastidious, thats why i have read it entirely

    Here is my blog Unknown

    ReplyDelete
  36. I've been exploring for a bit for any high quality articles or weblog posts in this kind of house . Exploring in Yahoo I eventually stumbled upon this site. Studying this information So i am satisfied to express that I've an incredibly just right uncanny
    feeling I discovered exactly what I needed. I most
    surely will make certain to don?t overlook this website and give it a
    glance on a continuing basis.

    Here is my website: diarrhea remedies

    ReplyDelete
  37. Magnificent beat ! I would like to apprentice while you amend your site, how could i subscribe for a blog site?

    The account aided me a acceptable deal. I had been tiny bit acquainted of this
    your broadcast provided bright clear concept

    Here is my web site; Tumblr.Com

    ReplyDelete
  38. I enjoy what you guys are usually up too. This kind of clever work and exposure!
    Keep up the fantastic works guys I've included you guys to blogroll.

    my blog post The Interlace

    ReplyDelete
  39. Pretty element of content. I just stumbled upon your website and in accession capital to claim that I get actually enjoyed account your
    blog posts. Anyway I'll be subscribing to your augment and even I fulfillment you get right of entry to constantly quickly.

    Here is my blog :: Dailymotion.com

    ReplyDelete
  40. Does your website have a contact page? I'm having a tough time locating it but, I'd like to send you an email.
    I've got some ideas for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it develop over time.

    My homepage candy crush saga cheats

    ReplyDelete
  41. Hmm is anyone else experiencing problems with the images
    on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog.

    Any feed-back would be greatly appreciated.

    Feel free to visit my website: youtube.Com

    ReplyDelete
  42. Hmm it appears like your blog ate my first comment (it was extremely
    long) so I guess I'll just sum it up what I wrote and say, I'm thoroughly enjoying
    your blog. I as well am an aspiring blog writer but I'm still new to everything. Do you have any helpful hints for first-time blog writers? I'd
    genuinely appreciate it.

    Feel free to surf to my page ... Psn Code Generator

    ReplyDelete
  43. Hi! This is my first comment here so I just wanted to give a quick shout out and say I genuinely enjoy reading your posts.
    Can you suggest any other blogs/websites/forums that cover the same topics?
    Thanks for your time!

    Here is my site ... World Of Tanks Hack

    ReplyDelete
  44. You need to be a part of a contest for one
    of the greatest blogs on the web. I'm going to highly recommend this blog!

    my web site: www.dailymotion.com

    ReplyDelete
  45. It's remarkable for me to have a site, which is beneficial in support of my knowledge. thanks admin

    Also visit my web site: Ps3 Usb Jailbreak

    ReplyDelete
  46. WOW just what I was searching for. Came here by searching for download 7zip

    Feel free to surf to my web site: 7Zip Download

    ReplyDelete
  47. I am truly pleased to read this weblog posts which includes tons of useful information, thanks for providing these statistics.


    Review my website - Geohot Jailbreak Ps3

    ReplyDelete
  48. Write more, thats all I have to say. Literally, it seems as though you relied on the
    video to make your point. You definitely know what youre talking about, why waste your intelligence on just
    posting videos to your blog when you could be giving
    us something enlightening to read?

    Feel free to surf to my homepage; minecraft gift code generator

    ReplyDelete
  49. Hey! Do you know if they make any plugins to protect against hackers?

    I'm kinda paranoid about losing everything I've worked hard on.
    Any suggestions?

    my blog post - Minecraft crack

    ReplyDelete
  50. Really no matter if someone doesn't be aware of after that its up to other people that they will assist, so here it occurs.

    My homepage: ps3 jailbreak 4.1

    ReplyDelete
  51. Spot on with this write-up, I actually think this site needs a lot more attention.
    I'll probably be returning to see more, thanks for the information!

    Also visit my site ... code psn gratuit

    ReplyDelete
  52. Admiring the hard work you put into your website and in depth information you present.
    It's nice to come across a blog every once in a while that isn't the
    same unwanted rehashed information. Excellent read! I've bookmarked your site and I'm
    including your RSS feeds to my Google account.

    My weblog itunes code Generator

    ReplyDelete