OpenCL and GPU programming Roadmap

8.9k Views Asked by At

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

4

There are 4 best solutions below

1
On BEST ANSWER

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.

0
On

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.

3
On

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

0
On

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.