On Open CL and Chaotic Phenomena By Mohamed
On Open. CL and Chaotic Phenomena By Mohamed Khalifa, Ali Alsaadi, and Ali Alkhathlan Department of Computer Science & Engineering University of Colorado Denver
Outline: 1. 2. 3. 4. 5. 6. 7. 8. Introduction. GPUs. GPGPU. Nvidia CUDA. Open. CL. Mandelbrot Set. Bifurcation Diagram. Conclusion.
Introduction: The. Presentationdiscussthemodernarchitectureof GPUs as contrasted with that of CPUs, as well as the development of GPGPU and Open. CL, and basic information regarding chaotic phenomena, with special emphasis on the Mandelbrot set and the bifurcation diagram of the logistic map. Actual implementation and experimentation is deferred to the project paper. ▫ GPU architecture. ▫ GPGPU (How successfully was GPGPU used? ) �The Development of GPGPU & Success Stories
GPU architecture: • What’s so special about GPUs? The GPU architecture is highly parallel. The Quadro FX 3400 card has 32 fragment processors running in parallel, and the newest card from Nvidia, the Ge. Force 8800, has up to 128 fragment processors running in parallel. Compared to today’s CPUs which can run up till four (quad core) tasks in parallel, the GPU has an huge advantage in performance.
Ø The GPU has become an extremely powerful processor. The speed of the GPUs are increasing faster than CPUs and is doubling every six months. One of the reasons that the GPUs are increasing in speed so much faster than the CPUs are the different in the architecture of the processors.
GPU architecture: • GPUs are highly optimized for SIMD ▫ Single Instruction, Multiple Data - Same instruction on different data units. • Capable of simultaneously performing operations on 30, 000 data units. • Compare to superscalar CPU architectures: 1632 simultaneous instructions.
Basic GPU Architecture: - It is the architecture of Nvidia Fermi S 2050 Tesla GPU (448 cores per GPU). - Nvidia’s newest & most advanced GPU technology. It’s Ø parallel Data. Cache, NVIDIA Giga. Thread, and ECC Support). http: //pds. ucdenver. edu/index. php? p=video&c=tech&a=t&i=2
GPU architecture - Limitations : ▫ Lack branching ▫ Traditionally lacking in precision: �Used to be limited to support single-precision floating point. �Now has double-precision and integers. ▫ Lack flow control: ▫ However, GPU cores are much more lightweight than CPU cores; They have far fewer control structures and lack branch prediction. ▫ Despite these tradeoff, GPUs remain a highly viable alternative to traditional processors due to their incredible speed and parallelism, and serving as prime examples of SIMD.
How GPUs Work? • Utilizing the GPU for non-graphics computation, known as GPGPU. ▫ Price/Performance Ratio. ▫ Evolution Speed. v. The main idea here is to study how we can use a cluster of GPUs for scientific computation, and how the performance of a GPU cluster is compared to a cluster of CPUs.
What is GPGPU? The GPGPU is General Programming on Graphics Processing Units. GPGPU is the usage of specialized GPUs for general computation. GPGPU has been in use since at least 2002. GPGPU operates by using graphics methods and graphics primitives to perform general computation. . Textures, for example, are used as memory, while shaders are programmed to be used as kernels, which are computed on each graphics primitive.
Transfer Data Between CPU and GPU o binding the texture to a texture target.
How has GPU been improved? • Changed by the emergence of GPGPU frameworks: ▫ Nvidia CUDA. ▫ Open. CL. ▫ Microsoft Direct. Compute.
How successfully was GPGPU used? v Success stories: • Folding@home • GPUSort • Network intrusion detection • Antivirus Scanning
How successfully was GPGPU used? 1 st_Success story – Folding@home • Distributed computing: § Largest distributed computing system in the world. “Fastest supercomputer” until 2011 § Before 2011, was 5 x faster than the fastest non- distributed supercomputer (5 TFLOPS vs 1 TFLOPS).
Success story – Folding@home GPUs Folding@home ▫ First used GPGPU in 2006. - This is before the release of CUDA and Open. CL, which made GPGPU easier. ▫ Up to 700 times faster than single-core CPU! ▫ Right now, total contribution of GPUs is 12 times total contribution of CPUs -But there are far fewer GPUs.
2 nd_Success story -GPUSort §GPUSort versus qsort()on the. CPU: -. • Require highly efficient and very fast algorithms Sorting is a key algorithm • Aside from obvious use of sorting, also used for binary search and duplicate finding.
Success story -GPUSort § Comparison of GPUSort with previous approaches for sorting on the GPU: • Naju Mancheril implemented GPUSort on Postgre. SQL ▫ Scaled very well compared to quick sort and heap sort. ▫ Up to 3 x as fast on commodity hardware.
3 rd_Success story – Network intrusion detection • Used a DFA-based (deterministic finite automaton) engine instead of a backtracking engine • 9 to 10 x faster than CPU!
4 th_Success story – Antivirus Scanning Nvidia embarks on GPU-based virus scans Antivirus Scanning • Similarly, antivirus scanning requires searching for patterns (signatures) in executables • Signatures are long, complex, and numerous -Computationally intensive • But highly parallelizable
Success story – Antivirus Scanning • Vasiliadis, et al. implemented a DFA-based signature scanning algorithm for GPUs • Used for Clam. AV, an open-source AV software • 20 -45 Gbit/s - 100 to 200 x faster than single-core CPU
Do you think I’m the best? I don’t think so, someone is coming! Here is the best that can work faster by GPGPU, CUDA, and Open. CL v Overall, The GPU implementation have better performance in some cases, compared to the CPU versions on the cluster. Moreover, I would expect other application which improve the GPU to perform even better compared to the CPU.
Nvidia CUDA: What is it? - It is an architecture used for parallel computing. - It is released by Nvidia on 2007. - It enables dramatic increases in computing performance by harnessing the power of the GPU. [16] “CUDA Zone. ” Nvidia Developer Zone. Nvidia. n. d. Web. 27 Mar 2012.
Nvidia CUDA - Important information • Compute Unified Device Architecture • Simplifies GPGPU ▫ A C-based language for defining compute kernels. ▫ Kernels are executed on each data unit in parallel.
Example of CUDA processing flow Figure 1 The scenario of this figure is that: 1. Copy data from main memory to GPU memory. 2. CPU instructs the process to GPU. 3. GPU execute parallel in each core. 4. Copy the result from GPU memory to main memory.
Nvidia CUDA - Limitations • Only supported by Nvidia • Specific to graphics processing units only ▫ CUDA allows developers to program applications in high level languages like C/C++ and supports APIs ▫ However, still matched by Open. CL, which can be used for GPUs, CPUs, and even FPGAs. [24] Fang, Jianbin, et al. “A Comprehensive Performance Comparison of CUDA and Open. CL.
Open. CL: What is it? • Open Computing Language is a language and a framework: - Developing and executing programs over heterogeneous devices and platforms. - For example: CPUs, and GPUs. • It includes: - A language(based on C 99) for writing kernels. - APIs to define and control the platforms. • By Apple, now held by the Khronos Group: �ARM , NVidia, AMD/ATI, and Intel. • A study has found that Open. CL has the same performance as CUDA, provided they are properly tuned. Fang, Jianbin, et al. “A Comprehensive. Performance Comparison of CUDA and Open. CL. “
Open. CL Objects: • Compute devices. • Memory objects. • Arrays. • Images. • Executable objects • Compute kernel. • Compute program.
Compute devices. • The Open. CL platform model is designed to present a uniform view of many different kinds of parallel processors. Figure 2
Memory Objects: A set of memory objects visible to the host and the Open. CL devices. Memory objects contain values that can be operated on by instances of a kernel float *array; 0 1 Arrays • Work exactly like arrays in C. • Address elements via a pointer. • Array reads/writes on the CPU and GPU. 2 3 4 5 float element = array[3]; element == 3
Memory Objects- images: • An image object is used to store a two- or three- dimensional texture, frame-buffer or image. • The elements of an image object are selected from a list of predefined image formats. • Kernels take memory objects as input, and output to one or more memory objects. Figure 3
Executable objects: Compute kernel: • A data-parallel function that is executed by the compute object (CPU or GPU) __kernel void Sum(_global const float *a, _global const float *b, _global float *answer) { int xid = get_global_id(0); answer[xid] = a[xid] + b[xid]; } float *a= 0 1 2 3 4 5 float *b= 0 1 2 3 4 5 __kernel void sum(…); float *answer= 0 2 4 6 8 10
Executable objects: • Compute program • A group of compute kernels and functions __kernel void sub{. . . } __kernel void transpose{. . . } float cross_product{. . . }. . __kernel void fft_radix 2{. . . }
Execution Mode of an Open. Cl: • Kernel: - It is a basic unit of execution code-similar to a C function. - Data parallel or task parallel. • Program: - Collection of kernel and other functions. - Analogous to a dynamic library. • Application queue kernel execution-instances: - Queued in- order or out- of order.
How Execution Model occur: • Execution of an Open. CL program occurs in two parts: - kernels that execute on one or more Open. CL devices. - host program that executes on the host. The host program defines the context for the kernels and manages their execution.
Open. CL Computing Model: Figure 4 1. Create a context (cl_context) containing the target devices. 2. Create command queues (cl_command_queue*) for each device in the context. 3. Create memory objects cl_mem) needed to share memory with the co -processor devices. 4. Load and link one or more computational kernels (cl_kernel). http: //www. browndeertechnology. com/docs/BDT_Open. CL_Tutorial_NBody-rev 3. html
OPENCL WORK UNITS: • A unit of work is called a work-item. • Work items are grouped into a workgroup • In CUDA a work-item is a CUDA thread. • In CUDA a work-group is a CUDA thread block. [--- NDRange Size Gx ---] [Work Group Sx ] [ Work Group Sx] NDRange Size = Global Size Work Group Size = Local Size Let us expand an example to show you 2 dimensional index space
An example to show you two dimensional index space : Figure 5 • A Kernel is invoked once for each work item. - Each work item has private memory. • Work items are grouped into a work group. - Each work group shares local memory • The total number of all work items is specified by the global work size. - global and constants memory is shared across all work items of all work groups.
WORK-ITEM IDENTIFIERS: • Each work-item is "aware” Array= 6 elements of what element of a 0 1 2 3 4 5 problem it is working on. • Each work-item or workglobal_id = 1 global_id = 4 group can be identified within the kernel. • The entire range of workitems is defined by the NDRange.
OPENCL KERNELS: • On the GPU each instance of a kernel executing (work-item) is run as its own thread. • The GPU can host thousands of threads. • Threads on the GPU are extremely lightweight and are managed in hardware. NDRange Size Gx Thread 14
What is the goal of Open. CL? • Leverage CPUs, GPUs, other processor such as cell/B. E processor and DSPs to accelerate parallel computation. • Get dramatic for computationally intensive application. • Write accelerate portable code across different devices and architectures. AMD’s Open. Cl: Leverage AMD’s CPUs, and AMD’s GPUs to accelerate parallel computation.
Why is Open. CL important? Concept of Open. CL device architecture Figure 6 • Hierarchical structure. • Thread-scaling approach. [10] "The Open. CL Specification. ” Khronos Open. CL Working Group, n. d. Version: 1. 0
Chaotic Phenomena (Chaos Theory) • Chaos theory studies the behavior of dynamical system. • It describes the systems that theory describes are apparently disordered • Popularly known as “the Butterfly Effect” ▫ A flap of a butterfly’s wings can cause a tornado on the other side of the world
Chaotic Phenomena (Chaos Theory) • Characterized by three properties: ▫ Sensitivity to initial conditions ▫ Topological mixing ▫ Density of periodic orbits
Sensitivity to initial conditions • small changes of the initial condition may lead to significantly different future behavior. ” after a while the system cant be predictable”. • Example: Tossing a coin
Topological Mixing • Any point or region in the phase space of the phenomenon will eventually overlap (mix) with any other region as the phenomenon evolves. • An example of non-mixing phenomenon: ▫ The function f(x) =x 2 is sensitive to initial conditions, but is not topologically mixing • An example of a mixing phenomenon: ▫ mixing of colored or fluids
Density of periodic orbits • Each point in the parameter space is arbitrarily close to a periodic orbit • i. e. , moving arbitrarily small distances from chaos in the parameter space can bring you back to order
Mandelbrot Set • Discovered, and popularized by Benoit Mandelbrot • Exhibits infinite complexity and self-similarity ▫ Fractal • But characterized by a simple mapping in the complex plane: zn+1 = zn 2 + c z 0 = c where c = original point
Mandelbrot Set
Mandelbrot Set • The Mandelbrot set is the set of all complex points that remain bounded after repeated iteration of the previous map. • When |z| >= 2, it is guaranteed to tend to infinity • Iteration number when this happens is called the escape time
Mandelbrot Set • Zooming into the edge of the Mandelbrot set reveals small replicas of the original set • Zooming into the edges of those reveal even smaller replicas • Infinite self-similarity and complexity
Mandelbrot set with a GPU and without
Logistic Map • Defined by the mapping: x n+1 = rxn(1 – xn) where r > 0 and 0 <= x <= 1 • Common and easy-to-compute and understand model for population growth
Logistic Map • Converges to an oscillating set of states when the map is iterated infinitely, dependent on the value of r • Visualized by a bifurcation diagram ▫ x-axis is the r values ▫ y-axis is the value of xn • Why is it called the bifurcation diagram?
Logistic Map
Logistic Map • At specific points, the period of the convergent set doubles – period doubling • Eventually chaos emerges
Logistic Map
Logistic map • As with the Mandelbrot Set, the bifurcation diagram of the logistic map is also infinitely selfsimilar • Zooming into the bifurcation diagram reveals multiple smaller copies of the original
Summary • Identify the potential use of Open. CL for the investigation of chaotic phenomena by using Mandelbrot set and bifurcation diagram. • As a result, GPUs are designed for fast execution of many parallel instruction threads. Besides, graphics cards use faster memory. • GPGPU is the technique of using a GPU, which typically handles computation only for computer graphics, to perform computation in applications traditionally handled by the CPU.
Acknowledgements: These slides contain material developed and copyright by: • Gita Alaghband (UC Denver). Refrences: [1] Alligood, K. T. , Sauer, T. , and Yorke, J. A. Chaos: an introduction to dynamical systems. New York City, NY: Springer-Verlag, 1997. Print. [2] “AMD Accelerated Parallel Processing SDK”. AMD Developer Central. AMD, n. d. Web. 6 Mar 2012. [3] Devaney, Robert L. An Introduction to Chaotic Dynamical Systems, 2 nd ed, . Boulder, CO: Westview Press, 2003. Print. [4] Garcia, V. , E. Debreuve, and M. Barlaud. Fast k nearest neighbor search using GPU. In Proceedings of the CVPR Workshop on Computer Vision on GPU, 2008. Print.
[5] Harrison, Owen, and John Waldron. “AES on SM 3. 0 compliant GPUs. ” In Proceedings of CHES 2007. Print. [6] "Intel® Open. CL SDK. " Intel Visual Computing Source. Intel Corporation, n. d. . Web. 6 Mar 2012. [7] Mancheril, Naju. “GPU-based Sorting in Postgre. SQL. ” Thesis, School of Computer Science - Carnegie Mellon University. Print. [8] Milnor, John W. Dynamics in One Mathematics Studies 160. Princeton, NJ: Princeton University Press, 2006 [9] “Open. CL. ” Nvidia Developer Zone. Nvidia, n. d. Web. 6 Mar 2012. [10] "The Open. CL Specification. ” Khronos Open. CL Working Group, n. d. Version: 1. 0 Web. 14 November 2011. Print. 11] Scarpino, Matthew. Open. CL in Action. Greenwich, CT: Manning Publications, 2011. Print. [12] Strogatz, Steven (2000). Nonlinear Dynamics and Chaos. Perseus Publishing. [13] Vasiliadis, Giorgos, et al. “Gr. AVity: A Massively Parallel Antivirus Engine. ” In proceedings of RAID 2010. Print. [14] Vasiliadis, Giorgos, et al. “Regular Expression Matching on Graphics Hardware for Intrusion Detection. ” In proceedings of RAID 2009. Print.
[16] “CUDA Zone. ” Nvidia Developer Zone. Nvidia. n. d. Web. 27 Mar 2012. [17] “Next Generation CUDA Architecture, Code Named Fermi. ” Nvidia. n. d. Web. 27 Mar 2012. [18] Friedrichs, M. S. et al. "Accelerating Molecular Dynamic Simulation on Graphics Processing Units". Journal of Computational Chemistry 30 (6): 864– 72, 2009. Web. 27 Mar 2012. [33] Blogger Guest. “ Corel Takes a look at an Open. CL Decision Framework. ” Web. 15 June 2011.
Question ?
- Slides: 63