1、 GPU和CPU
CPU:多核,关注性能。
GPU:一般目的的数据并行计算协调器,改善数字精确度
CPU和GPU中的并行程序不一样:domian,ventor
图形API可以用于一般目的的计算
2、 OpenCL
(1)开放的计算语言,访问混合计算资源的接口语言,支持单或多处理器(CPU、GPU、CPU+GPU、多GPU)的并行执行,用于桌面和手持设备,与图形API(如OpenGL)一起工作。审查中的标准:开源,跨平台,厂商中枢。由Apple提出,与工业领导合作开发,性能增强技术(Mac OS X Snow Leopard)
(2)OpenCL的设计目标
A.使用系统中所有计算资源(GPU、CPU等;数据和任务并行计算模式)
B.高效的并行编程模式(基于C;抽取隐含的硬件的细节)
C.强调浮点计算精度(舍入;数值函数的最大允许错误)
D.未来硬件驱动的要求
(3)OpenCL软件层
A.Platform Layer:查询和选择系统的计算设备,初始化计算设备,并用来建立compute contexts和work-queues。
B.Runtime:管理资源,执行程式的kernel
C.编译器:ISO C99的子集合,并加上了OpenCL特殊的语法。编译和建立计算程序的执行(online,offline)。
(4)OpenCL执行模型
A.Compute Kernel:可执行代码的基本单元(类似一个C函数),数据/任务并行。
B.Compute Program:Compute Kernel和内嵌函数的集合,类似一个动态库
C.应用程式:把要执行的Compute Kernel排序;执行时依序或不依序;(最后1句看不懂)
Data-Parallel Execution Model
A 定义了N-Dimensional computation domain。
work-item:ND domain中每一个独立的项目(相当于CUDA的thread),每一个work-item会被并行地执行。
global work size:全部的work-item数量。
B work-group:把几个work-item作群组(相当于CUDA的thread block)。在work-group中的work-item可以通信,同步。在OpenCL中多个work-group并行执行的。
C global work size 映射到work-groups。
D 在所有OpenCL计算设备上执行。
Task-Parallel Execution Model
A 某些计算设备:CPU
B 类似执行单个work-item,用OpenCL书写的kernel,一个本机C/C++函数。
(5)OpenCL存储模型
A 松的,一致的,共享的。
B 多个不同的地址空间:可以冲突,有private memory、local memory、constant memory和global memory四种
(6) OpenGL语言
A源自ISO C99的标准,
B一些限制:recursion、function pointers,C99头文件函数等不能在kernel里使用。
C 支持C99中的预处理指令。
D 内嵌数据类型:数值、向量、结构、指针、图像,数据类型转换函数。
E 内嵌函数:
必须 | 可选 |
work-item functions math.h read and write image relational geometric functions synchronization functions | double precision atomics to global and local memory selection of rounding mode |
3、 OpenCL FFT例程,分host code和computer kernal。
4、 OpenCL和OpenGL
A 共享OpenGL的资源:纹理、缓存对象和描述缓存,数据shared而不是copy。
B 有效排列OpenCL和OpenGL指令。
C 应用程序可以选择执行OpenCL和OpenGL的计算设备。