In this paper, we report fast calculation of a computer-generated-hologram using a new architecture of the HD5000 series GPU (RV870) made by AMD and its new software development environment, OpenCL. Using a RV870 GPU and OpenCL, we can calculate 1,920×1,024 resolution of a CGH from a 3D object consisting of 1,024 points in 30 milli-seconds. The calculation speed realizes a speed approximately two times faster than that of a GPU made by NVIDIA.
©2010 Optical Society of America
CGH (Computer-generated-hologram) has the ability to correctly record and reconstruct a light wave for a 3D object. Electroholography using the CGH technique is attractive as a 3D display, because the CGH technique has remarkable features ; however, due to two significant problems, it is difficult to develop a practical 3D display system using electroholography. One problem is the need for an SLM (spatial light modulator) that can display a CGH with large area and high resolution, because the resolution of a CGH is that of wavelength-order[2, 3, 4]. The other problem is the enormous computational time required for generating a CGH. This paper focuses on this problem.
Assuming that a 3D object is composed of N point light sources, the formula for computing a CGH is expressed as:
where, I(xh,yh) is the light intensity on a CGH, (xh,yh) and (xj,yj,zj) are the coordinates for the CGH and a 3D object, Aj is the light intensity of the 3D object, λ is the wavelength of the reference light, and Pj = πp 2/(λzj), where p is the sampling interval on the CGH plane. Note that the coordinates (xj,yj) and (xh,yh) are normalized by p. The computational complexity of the above formula is O(NNxNy), where Nx and Ny are the horizontal and vertical sampling numbers of the CGH. This creates very enormous computational complexity.
To solve this problem, several software approaches have been proposed: for example, recurrence approaches, and the look-up table methods[5, 7]. Another approach to dramatically reduce the calculation time is the hardware approach, such as FPGA (field-programmable gate array) and GPU (graphics processing unit). In 1995, a specialized stream-processing hardware for hologram computation was reported . We have also designed and built special-purpose computers for holography using FPGA technology, called HORN (Holographic ReconstructioN) . The FPGA-based approaches showed excellent computational speed, however, the approach has the following restrictions: the high cost for developing the FPGA board, long development time and technical know-how required for the FPGA technology.
GPU-based approaches have already been applied to the optics field. Especially, CGH calculations [10, 11, 12, 13, 14] and reconstruction calculations in digital holography [15, 16] are used to accelerate the calculation. In 2007, NVIDIA released a new architecture of GPU and its software development environment, CUDA (Compute Unified Device Architecture). Using CUDA allows us to program GPU easier than prior software developments, such as HLSL, Cg language and so forth. Since the release, many papers using NVIDIA GPU and CUDA have been published in optics.
On the other hand, more recently in December 2009, a new GPU of the HD5000 series (RV870) made by AMD was released. The RV870 GPU has new architecture and its software environment, OpenCL (Open Computing Language). The architecture of the RV870 GPU is different from that of the NVIDIA GPU. The RV870 GPU has huge potential for fast calculation because one GPU chip has over 1,000 floating-point number processors, while one NVIDIA GPU chip has about 200 floating-point number processors. However, fast CGH calculation using the RV870 GPU has not been reported so far.
In this paper, we report fast CGH calculation using RV870 GPU and OpenCL. Using these, we can calculate 1,920×1,024 resolution of a CGH from a 3D object consisting of 1,024 points in 30 milli-seconds. To the best of our knowledge, this article is the first report of using the RV870 GPU and OpenCL in optics. In addition, we compare the calculation performance between the RV870 GPU and the GPU made by NVIDIA.
In Section 2, we describe a fast CGH calculation on AMD RV870 and OpenCL. In Section 3, we show and compare the performance between the RV870 GPU and the GPU made by NVIDIA. In Section 4, we conclude this work.
2. Fast calculation of computer-generated-hologram on AMD RV870 and OpenCL
The architecture of RV870 GPU is shown in Fig.1. The top level of the GPU consists of many SIMD (Single Instruction Multiple Data) engines. The SIMD engine has 16 thread processors (TP) and a shared memory, which is small and high-speed. The approach is similar to “Connection Machine Model 2 supercomputer” .
In addition, the thread processor has four stream cores and one T-stream core. The stream core is a simple floating-point-number operation unit. And, the T-stream core also has a floating-point-number operation unit and special function unit. The special function unit can calculate special functions at high speed, such as trigonometric function, logarithm function and so on. The stream cores in the same SIMD engine operate by the same instructions; therefore, the SIMD engine is similar to a SIMD processor.
Calculation on the GPU using OpenCL is executed using the following steps: (1) We initialize a GPU using OpenCL API (Application Program Interface) functions. (2) We allocate the required amount of memory on a device memory in Fig.1. The device memory is large amount of memory. However it takes large latency access. (3) We send an input data to the device memory. (4) We send a kernel function from the host computer to the GPU. The kernel function is compiled to native code of GPU using the OpenCL compiler. The GPU executes the kernel function. (5) We receive a calculated result from the device memory. (6) We release the device memory and GPU resources.
Figure 2(a) shows the outline of the CGH calculation on the RV870 GPU with OpenCL. When calculating a CGH with the resolution of Nx× Ny, we need to divide the CGH area into groups with the size of Tx ×Ty. Therefore, the number of groups is Nx/Tx×Ny/Ty. In addition, each group has Tx×Ty items (In the CUDA, group and item are equivalent to block and thread, respectively). Each group is allocated to SIMD engines and each item simultaneously calculate Eq.(1) by each stream core on an SIMD engine.
In Fig.2(b), we show the kernel source code of the CGH calculation on the RV870 GPU with OpenCL. The source code is not optimized because we understand it easily. The optimization is shown in the next subsection.
Each group and item have the indices, group_id and local_id. The OpenCL functions, get_group_id(0) and get_group_id(1), give us the horizontal and vertical indices of group_ids respectively. The OpenCL functions, get_local_id(0) and get_local_id(1), also give us the horizontal and vertical indices of local_ids respectively.
The arguments of the kernel function are a CGH data (d_hol), an object data (d_obj), the number of object points (N) and the CGH size (Nx,Ny). An object data (d_obj) consists of the coordinates and the intensity as four float data (float4). In lines 5, 6 and 7 of the Fig.2(b), the variables x and y calculate the coordinates (xh,yh) on the CGH plane and adr calculates the address of the device memory for storing the calculation result I(xh,yh). In lines 11 to 16, a CGH point I(xh,yh) can be calculated by iterating for N. Although seeming to execute only one kernel, in fact, each stream core corresponding to local_id and global_id can perform the kernel in parallel.
When calculating a CGH with 1,920×1,024 from a 3D object composed of 1,024 points, the kernel with Tx×Ty = 16×16 took about 215ms. The calculation speed of the kernel is slow.
For more acceleration, we applied the following optimization techniques to the previous kernel: (1) Recurrence algorithm (2) Shared memory (3) Loop unrolling (4) Vectorization (5) Native instruction.
We proposed a fast CGH computation method using two recurrence formulas [6, ?, ?, 9]. Our recurrence algorithm can compute the phase component of the cosine function in Eq.(1) by two recurrence formulas. The recurrence algorithm is as follows:
Here, we define Γ0 = Pj ((xh - xj)2+(yh-yj)2), θ 0 = Pj(2(xh-xy)+1), ∆ = 2Pj. Eventually, we can compute the phase Γn at the next coordinate by the two recurrence formulas. For more details, see Ref.
In lines 15 to 18, we copy the object data from the device memory (d_obj) to a shared memory (s_obj). The shared memory can store 256 object points at a time because the shared memory is small and high-speed. Therefore, in the 13, we must iterate N/256 times. Note that barrier(CLK_LOCAL_MEM_FENCE) means a barrier synchronization in line 18. It is equivalent to the syncthreads function in the CUDA.
Loop unrolling is a well-known technique for optimizing a kernel function. It can be realized by reducing the number of iterations and replicating the body of the loop. Benefits of the loop unrolling are the capable to decrease the loop frequency, branch instructions and conditional instructions. In the optimized kernel, we applied the loop unrolling to the loop of object points. In lines 20 to 51 in Fig.3, we can perform four object points per one iteration of the loop. In addition, we vectorize the operations in the loop using the float4 type, in order to handle four object points at a time. For example, in line 22, we can calculate the four subtractions simultaneously. In the same way, the kernel can handle eight CGH points using the float8 type at same time in lines 40 to 50.
In lines 42 to 45, we used native cosine functions, instead of the normal cosine function shown in Fig.2(b). The native cosine function can compute the fast cosine function using the hardware.
Table 1 shows a comparison of the calculation times for a CPU alone, NVIDIA GPU and an AMD RV870 GPU. The size of the CGH is 1,920×1,024. The specifications of the personal computer are as follows: Intel Core 2 Quad Q6600 (We used one core for the calculation), 2 GB of memory, Microsoft Windows XP SP3. We used a GeForce GTX260 as the NVIDIA GPU board and its software development environment of CUDA version 2.3, and a RADEON HD5850 as the AMD GPU board and its software development environment of StreamSDK version2.0. The RADEON HD5850 GPU has 1,440 stream cores (namely, 18 SIMD engines) with the clock frequency of 725MHz.
We can see that the optimization method for the AMD GPU described in Section 2.1 can perform more than ten times faster than that without the optimization. In the calculation times for the NVIDIA GPU in the table, we optimized the kernel for the NVIDIA GPU using the same method as described in Section 2.1: namely, recurrence algorithm, shared memory, loop unrolling, vectorization, native instruction. And, in the calculation times for the CPU alone in the table, we used Eq.(2) for the CGH calculation. All calculation times using AMD and NVIDIA are superior to those using the CPU alone. In addition, the AMD GPU can calculate a CGH approximately two times faster than the NVIDIA GPU.
In this paper, we described a fast CGH calculation using an AMD RV870 GPU with new architecture and its new software development environment, OpenCL. Many fast CGH calculation methods using a NVIDIA GPU and the CUDA have already been reported in optics field; however, a study using the RV870 GPU has not been reported so far. To the best of our knowledge, this article is the first report of using the RV870 GPU and OpenCL in optics. Using the RV870 GPU and OpenCL, we can calculate 1,920×1,024 resolution of a CGH from a 3D object consisting of 1,024 points in about 30 ms. The calculation speed can realize approximately two times faster than the NVIDIA GPU.
This research was partially supported by the Ministry of Internal Affairs and Communications, Strategic Information and Communications R&D Promotion Programme (SCOPE), 2009, and Japan Society for the Promotion of Science (JSPS), Grant-in-Aid for Scientific Research (C) (21500094).
References and links
1. S. A. Benton, “Experiments in holographic video imaging,” Proc.SPIE IS8, 247–267 (1991).
2. K. Maeno, N. Fukaya, O. Nishikawa, K. Sato, and T. Honda, “ELECTRO-HOLOGRAPHIC display using 15MEGA pixels LCD,” Proc.SPIE 2652, 15–13 (1996). [CrossRef]
3. C. W. Slinger et al., “Recent Developments in Computer-Generated Holography: Toward a Practical Electro-holography System for Interactive 3D Visualization,” Proc SPIE 5290, 27–41 (2004). [CrossRef]
4. J. Hahn, H. Kim, Y. Lim, G. Park, and B. Lee, “Wide viewing angle dynamic holographic stereogram with a curved array of spatial light modulators,” Opt. Express 16, 12372–12386 (2008). [CrossRef] [PubMed]
5. M. Lucente, “Interactive Computation of holograms using a Look-up Table,” J. Electron. Imaging 2, 28–34 (1993). [CrossRef]
6. T. Shimobaba and T. Ito, “Special-purpose computer for holography HORN-4 with recurrence algorithm,” Comp. Phys. Commun. 148, 160–170 (2002). [CrossRef]
7. H. Yoshikawa, T. Yamaguchi, and R. Kitayama, “Real-Time Generation of Full color Image Hologram with Compact Distance Look-up Table,” OSA Topical Meeting on Digital Holography and Three-Dimensional Imaging 2009 DWC4 (2009).
8. J. A. Watlington, M. Lucente, C. J. Sparrell, V. M. Bove Jr., and I. Tamitani, “A Hardware Architecture for Rapid Generation of Electro-Holographic Fringe Patterns,” Proc. SPIE Practical Holography IX 2406, 172–183 (1995).
9. Y. Ichihashi, H. Nakayama, T. Ito, N. Masuda, T. Shimobaba, A. Shiraki, and T. Sugie, “HORN-6 special-purpose clustered computing system for electroholography,” Opt. Express 17, 13895–13903 (2009). [CrossRef] [PubMed]
10. M. Lucente and T. A. Galyean, “Rendering Interactive Holographic Images,” Proc. of SIGGRAPH 95387–394 (1995).
11. N. Masuda, T. Ito, T. Tanaka, A. Shiraki, and T. Sugie, “Computer generated holography using a graphics processing unit,” Opt. Express 14(2), 587–592 (2008). [CrossRef]
14. Y. Pan, X. Xu, S. Solanki, X. Liang, R. Bin, A. Tanjung, C. Tan, and T. C. Chong, “Fast CGH computation using S-LUT on GPU,” Opt. Express 17, 18543–18555 (2009). [CrossRef]
15. T. Shimobaba, T. Ito, N. Masuda, Y. Abe, Y. Ichihashi, H. Nakayama, N. Takada, A. Shiraki, and T. Sugie, “Numerical calculation library for diffraction integrals using the graphic processing unit : the GWO library,” J. Opt. A: Pure Appl. Opt. 10, 075308 (5pp) (2008). [CrossRef]