简体   繁体   English

OpenCL和GPU编程路线图

[英]OpenCL and GPU programming Roadmap

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?!? 我想开始说明我对OpenCL / GPU编程一无所知,但我是一位高级C#(通用.Net)程序员,无需担心C ++,我想学习OpenCL / GPU编程...我的问题是...我从哪里开始?!? what should i download?!? 我应该下载什么?! is there a way to program OpenCL/GPU on the Visual Studio (on C#)!?! 有没有一种方法可以在Visual Studio(在C#上)上对OpenCL / GPU进行编程! like... hello world stuff... tks all 像...你好世界的东西...全部

The best site I've found for a clear introduction to how GPU programming is different from CPU programming is this site: 我找到的关于GPU编程与CPU编程有何不同的最佳站点是以下站点:

http://www.macresearch.org/opencl http://www.macresearch.org/opencl

Even though these videos are done showing NVIDIA style cards, the important concepts of: 即使这些视频显示了NVIDIA样式卡,但以下重要概念:

  • many threads running the exact same instructions in lock-step (even if some code is written with if-else constructs), and 许多线程在锁步中运行完全相同的指令(即使某些代码是使用if-else构造编写的),并且

  • 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. 同样适用于AMD或NVIDIA,对于开始改变思考如何构造算法以提高GPU性能的方式至关重要。

http://developer.amd.com/zones/OpenCLZone/pages/default.aspx 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. 假设您要执行opencl而不是cuda,那么这里有很多入门视频教程。 There is a similar set at NVidia - although they have more CUDA based stuff. NVidia也有类似的设置-尽管他们有更多基于CUDA的东西。

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. 如果您想进行GPL编程,那么获得一个可以将opencl / cuda代码转储到GPU中的示例应用程序就是简单的部分。 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. 您还必须学习opencl / cuda语言,然后还必须学习如何并行考虑算法以及如何测试/测量结果。

There isn't a 'use GPU' push button that instantly makes your code 100x faster 没有“使用GPU”按钮可以立即使您的代码快100倍

I would say check out OpenTK and their C# bindings to get a jumpstart on OpenCL. 我会说检查一下OpenTK及其C#绑定,以获取有关OpenCL的快速入门 Look at OpenCL's website to get the standard C or C++ bindings. 请访问OpenCL网站,以获取标准的C或C ++绑定。

Learning OpenCL, there's various resources.. not a ton. 学习OpenCL,这里有各种资源。 I found following this helpful. 我发现遵循此帮助。

I'm sorry for being 7 years late. 对不起,晚了7年。 But here is an open source C# gpgpu library to write your own OpenCL kernels: 但是,这里有一个开放源代码的C#gpgpu库,用于编写您自己的OpenCL内核:

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

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. 从流水线到任务池调度,它可以做很多事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM