CLH blog AI CV Algorithm

OpenCL Tutorials

2017-06-08
CLH

OpenCL Open Computing Language#


  • Open specification 开放架构/规范
  • Proposed by Apple in 2008
  • Specification developed by a number of companies(Nvidia AMD Intel)
  • Specificaton is maintained by the Khronos Group(Also OpenGL)
  • Multiple CUPs and Programmable GPUs
  • Supports general purpose parallel computations
  • OpenCL is device agnostic(设备兼容)

OpenCL devices

  1. Commonly CPUs and GPUs
  2. Could be ant type of hardware that is compliant(兼容):多媒体芯片、FPGA、嵌入式处理器等

Goals of OpenCL


  1. Simple computing model - clean API
  2. ANSI-C99 language support. Additional qualifiers,data types and built-in functions
  3. Thread management framework. Application and thread-level synchronization(同步)
  4. Easy to use and needs to be lightweight and efficient
  5. Need to be able to use all computational resources in computer
  6. IEEE-754 compliant in rounding behavior(舍入行为)
  7. Minimum errors for math functions
  8. Provides guidelines for new hardware requirements

Uses of OpenCL

Data-parallel algorithms that are computationally significant.

Where OpenCL can be used :

  1. Image, video and audio processing
  2. Simulations and scientific calculations
  3. Medical imaging
  4. Financial models

OpenCL入门


OpenCL程序主要是分两部分,一部分是在设备上执行(GPU),另一部分是在主机上运行(CPU)。在设备上执行需要写一个Kernel函数,由OpenCL语言编写;OpenCL语言在C语言的基础上加了一些约束、关键字和数据类型。在主机运行的程序提供了API,主机程序可以用C/C++编写,控制OpenCL的环境(上下文,指令队列等)。


基本概念


Kernel 是设备程序执行的入口点,即唯一可以从主机上调用执行的函数。

SIMT 单指令多线程(Single Instruction Multi Thread),相同代码在不同线程中并行执行,每个线程使用不同的数据来执行同一段代码。

Work-item 工作项,类似CUDA Threads,是最小的执行单元。 Work-group 工作组,允许工作项之间通信和协作,类似于CUDA Thread Blocks

ND-Range 是下一个组织级别,定义了工作组的组织形式。


上一篇 Git思维导图

下一篇 OpenGL Tutorials

Comments

Content