Prefer Your Language

Search This Blog

Multi GPU programming using texture memory in CUDA | CUDA multi-gpu textures



Those of you who have used CUDA texture should be familiar with the insane programming interface that they present. Texture references can be declared only as global variables, and only in the file where you are using them. You can't pass them around as by - value/by –reference arguments in functions, you can't create them inside function/class scope, and you cannot make array s of them. This brings us to an interesting point. The way Multi-GPU programming is handled in CUDA is that you spawn off many CPU threads. Each CPU thread initializes its own GPU. For each thread, you create thread specific variables that store pointers to the device memory, and allocate device memory in EACH thread. That's right, since memory is not shared between GPUs, if you are doing the same thing on many GPUs, you need to allocate the same stuff again and again, once on each GPU (of course, if you are doing Different things on different GPUs, that’s a different ball game). Now comes the fun part. Since you cannot create array s of Texture References, and you cannot encapsulate them inside a class/structure, how on earth can you create one Texture Reference for each GPU? Should we hard code this? Should we replicate our code for each GPU we have, and just change the name of the Texture Reference to some unique name? The answer is NO!!
Well, it turns out that NVidia has sneakily done something here. When we spawn off multiple CPU threads, and select a different GPU in each thread, CUDA "auto magically” creates a separate copy of the texture reference for each GPU. So, all you have to do is bind the SAME Texture reference again and again, once in each CPU thread (i.e.: once for each GPU). While it may look weird, because it looks like we are initializing the same(?) global variable several times, this actually works.
I have uploaded a small code sample here that demonstrates this stuff. It loads a bunch of numbers onto the GPUs and squares them. This code sample uses some helper classes that I wrote to simplify CUDA development. This is still ongoing work, and may not be as good as a
Framework/library should be. Also, you will need Boost C++ libraries (the cpu threading and     synchronization uses boost).

I hope you must like this article and have learned CUDA multi-gpu textures

Got Questions?
Feel free to ask me any question because I'd be happy to walk you through step by step! 
Want to Contact us? Click here

8 comments:

  1. Excellent blog here! Also your web site loads up very fast!
    What web host are you using? Can I get your affiliate link to your host?
    I wish my website loaded up as quickly as yours lol 토토

    ReplyDelete
  2. I have read so many posts regarding the blogger lovers
    but this article is truly a good paragraph, keep it up. 경마

    ReplyDelete
  3. After looking at a handful of the articles on your blog, I truly like your technique of writing a blog. 바카라

    ReplyDelete
  4. I book marked it to my bookmark webpage list and will be checking back in the near future. Please visit my web site too and let me know what you think. 사설토토

    ReplyDelete
  5. Yay google is my queen assisted me to find this great web site!
    I was studying some of your content on this internet site and I think this internet site is very informative!
    Keep on posting.
    안전놀이터

    ReplyDelete
  6. Hi there very cool web site!! Man .. Excellent .. Superb ..
    I will bookmark your web site and take the feeds additionally…I am satisfied to search out a lot of helpful information right here in the publish, we want work out more techniques on this regard, thanks for sharing.
    성인웹툰

    ReplyDelete
  7. This design is wicked! You obviously know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Wonderful job. I really loved what you had to say, and more than that, how you presented it. Too cool!
    먹튀검증

    ReplyDelete

Help us to improve our quality and become contributor to our blog

Become a contributor to this blog. Click on contact us tab
Blogger Template by Clairvo