11

i would like to start stating that i know nothing of OpenCL/GPU programming but i am a advanced C# (general .Net) programmer without fear of C++ and i would like to learn OpenCL/GPU programming... my question is... where do i start?!? what should i download?!? is there a way to program OpenCL/GPU on the Visual Studio (on C#)!?! like... hello world stuff... tks all

Leonardo
  • 10,737
  • 10
  • 62
  • 155

4 Answers4

9

The best site I've found for a clear introduction to how GPU programming is different from CPU programming is this site:

http://www.macresearch.org/opencl

Even though these videos are done showing NVIDIA style cards, the important concepts of:

  • many threads running the exact same instructions in lock-step (even if some code is written with if-else constructs), and

  • coalesced memory access

apply equally to AMD or NVIDIA and are crucial for starting to change the way you think about how to structure your algorithm to get performance improvement on the GPU.

K. Brafford
  • 3,755
  • 2
  • 26
  • 30
  • 3
    Sorry, I think this question is mainly about getting started coding as opposed to designing. The MacResearch series is great for starting to think in GPU terms but is not very informative for coding. It is also rather dated now. I would recommend the series, however. – That Realty Programmer Guy Feb 06 '11 at 14:21
7

http://developer.amd.com/zones/OpenCLZone/pages/default.aspx

Assuming you want to do opencl rather than cuda then this has a whole bunch of intro video tutorials. There is a similar set at NVidia - although they have more CUDA based stuff.

If you want to do GPL programming then getting a sample app that can dump opencl/cuda code into a GPU is the simple part. You also have to learn the opencl/cuda language then you have to learn how to think about algorithms in parallel and how to test/measure the results.

There isn't a 'use GPU' push button that instantly makes your code 100x faster

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • i was hoping for a more direct answer... like... "go to that adress and download that... if u have a ATI video card go there... if u have a Geforce go in that site" sort of thing... – Leonardo Dec 13 '10 at 17:15
  • ok... so where do i start?!? what do i have to do to my programs so they use the power of the GPU?!? – Leonardo Dec 13 '10 at 17:29
  • On a you-wish-it-were-related note: Haskell might actually very well have that button. To some extend it's possible with all languages, but with Haskell it's more often possible. And a lot easier to develop. (Functional programming defines behavior more strictly as it it defines results, not procedures) – Lodewijk Oct 18 '13 at 17:19
4

I would say check out OpenTK and their C# bindings to get a jumpstart on OpenCL. Look at OpenCL's website to get the standard C or C++ bindings.

Learning OpenCL, there's various resources.. not a ton. I found following this helpful.

1

I'm sorry for being 7 years late. But here is an open source C# gpgpu library to write your own OpenCL kernels:

https://github.com/tugrul512bit/Cekirdekler/wiki/Beginning

and a hello world as tradition:

ClNumberCruncher  gpus= new ClNumberCruncher(
    ClPlatforms.all().devicesAmd().gpus(), @"
         __constant char text[12] = {'h','e','l','l','o',' ','w','o','r','l','d',' '};
         __kernel void hello(__global char * arr)
         {
              printf(text);
         }
    ");
gpus.performanceFeed = true;
ClArray<byte> array = new ClArray<byte>(5,1);
array.compute(gpus, 1, "hello", 5, 1);
array.compute(gpus, 1, "hello", 5, 1);
array.compute(gpus, 1, "hello", 5, 1);

this is the output:

hello world
hello world
hello world
hello worldhello world

Compute-ID: 1  ----- Load Distributions:  [40.0%] - [60.0%] -----------------------------------------------------
Device 0(gddr): Oland                              ||| time: 29.47ms, workitems: 2
Device 1(gddr): gfx804                             ||| time: 29.76ms, workitems: 3
-----------------------------------------------------------------------------------------------------------------

hello worldhello world
hello world
hello world
hello world

Compute-ID: 1  ----- Load Distributions:  [40.0%] - [60.0%] -----------------------------------------------------
Device 0(gddr): Oland                              ||| time: 1.64ms, workitems: 2
Device 1(gddr): gfx804                             ||| time: 1.33ms, workitems: 3
-----------------------------------------------------------------------------------------------------------------

hello worldhello world
hello world
hello world
hello world

Compute-ID: 1  ----- Load Distributions:  [40.0%] - [60.0%] -----------------------------------------------------
Device 0(gddr): Oland                              ||| time: 1.08ms, workitems: 2
Device 1(gddr): gfx804                             ||| time: .87ms, workitems: 3
-----------------------------------------------------------------------------------------------------------------

it can do a bunch of things from pipelining to task pool scheduling.

huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97