7. Introduction to OpenCL
• Open Compute Language, C- like language.
• Framework for writing parallel algorithms
• Heterogeneous platforms
• Developed by Apple
• Is an open standard and controlled by Khronos
group
8. Example of adding two vectors
Serial version
For(i=1 to n)
c[i]= a[i]+b[i];
Using OpenCL
_kernel add(a,b,c)
{
int i =get_global_id(); //get thread id
c[i]=a[i]+b[i];
}
9. OpenCL Architecture
1. Platform model
2. Execution model
3. Memory model
4. Programming model
11. OpenCL-Execution Model
_kernel add(a,b,c)
1. Kernel {
2. Work-items int i =get_global_id();//get thread/workitem id
c[i]=a[i]+b[i];
3. Work group }
4. ND-range
5. Program
6. Memory
objects
7. Command
queues
12. Memory Model in OpenCL
Compute Device
Private register Private register Private register
Compute unit 0 Compute unit 1 Compute unit 2
Local memory/cache Local memory/cache Local memory/cache
Global constant memory-DRAM
Global Memory -DRAM
13. Programming model
1. Data parallel-single function on multiple data
2. Task parallel-Multiple functions on single data
15. Essential Development Tasks
C-code with restrictions
Initialize Initiate
Execute Read back
Parallelize Code Kernel OpenCL kernels and
kernel data to host
environment data
16. Essential Development Tasks
• Query compute device
• Create context
• Compile kernels
Initialize Initiate
Execute Read back
Parallelize Code Kernel OpenCL kernels and
kernel data to host
environment data
17. Essential Development Tasks
• Create memory objects
• Map data structures to OpenCL
supported data structures.
• Initialize kernel parameters
Initialize Initiate
Execute Read back
Parallelize Code Kernel OpenCL kernels and
kernel data to host
environment data
18. Essential Development Tasks
• Specify number of threads to
execute task
• Trigger the execution of kernel-
sync or async
Initialize Initiate
Execute Read back
Parallelize Code Kernel OpenCL kernels and
kernel data to host
environment data
19. Essential Development Tasks
• Map to application datastructure
Initialize Initiate
Execute Read back
Parallelize Code Kernel OpenCL kernels and
kernel data to host
environment data
20. Introduction to WebCL
• Java Script bindings for OpenCL
• First announced in March 2011 by Khronos
• API definition underway
• Prototype plugin is available only for Firefox
browser
21. Binding OpenCL to WebCL
CPU
Host application JavaScript
WebCL
OpenCL
OpenCL Framework compliant
device
23. Applications of OpenCL
• Database mining
• Neural networks
• Physics based simulation,mechanics
• Image processing
• Speech processing
• Weather forecasting and climate research
• Bioinformatics
24. Conclusion
• Significant performance gains in using OpenCL
for computations in client-side environments
like HTML5
• Algorithms need to be ‘parallelizable’
• Further optimizations can be achieved by
exploiting memory model
25. Software/Hardware used in demo application
Hardware
Intel(R) Core(TM)2 Quad core CPU Q8400 @ 2.66GHz
Nvidia 160m Quadro 8 cores @ 580 MHz
Software
OpenCL runtime for CPU
http://software.intel.com/en-us/articles/vcsource-
tools-opencl-sdk/
OpenCL runtime for GPU
http://www.nvidia.com/object/quadro_nvs_notebook.
html
WebCL plugin for Firefox
http://webcl.nokiaresearch.com/
What are multicores?Compare Cpu and GpuAdvantages of using GPUHow is it possible to do so.Moors lawSimple questions
-Explain network diagram-how to render-performance issue-solve it using parallel computation opencl technologyUse different color force directed.Real time use ,giving imp to diagram than textReplace Force directed algorithm with simple lay out algo.
Fontext for demoPause and explain details,with variation in speech
Brief OpenCl intro.Dreaft and open specification.Parallel only!!!Thread amnagement,synch is simple
Why this models?How architecture helps in improving performance
HierarcyHosta calls
What to do with execution model.Acces threads,Create memory,execute program,CommandsWorkgrou-cores corrospondence