## Abstract

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

## 1. Introduction

CGH (Computer-generated-hologram) has the ability to correctly record and reconstruct a light wave for a 3D object. Electroholography[1] 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[5]:

where, *I*(*x _{h}*,

*y*) is the light intensity on a CGH, (

_{h}*x*,

_{h}*y*) and (

_{h}*x*,

_{j}*y*,

_{j}*z*) are the coordinates for the CGH and a 3D object,

_{j}*A*is the light intensity of the 3D object,

_{j}*λ*is the wavelength of the reference light, and

*P*=

_{j}*πp*

^{2}/(

*λz*), where

_{j}*p*is the sampling interval on the CGH plane. Note that the coordinates (

*x*,

_{j}*y*) and (

_{j}*x*,

_{h}*y*) are normalized by

_{h}*p*. The computational complexity of the above formula is O(

*NN*), where

_{x}N_{y}*N*and

_{x}*N*are the horizontal and vertical sampling numbers of the CGH. This creates very enormous computational complexity.

_{y}To solve this problem, several software approaches have been proposed: for example, recurrence approaches[6], 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 [8]. We have also designed and built special-purpose computers for holography using FPGA technology, called HORN (Holographic ReconstructioN) [9]. 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” [5].

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 *N _{x}*×

*N*, we need to divide the CGH area into

_{y}*groups*with the size of

*T*×

_{x}*T*. Therefore, the number of

_{y}*groups*is

*N*/

_{x}*T*×

_{x}*N*/

_{y}*T*. In addition, each

_{y}*group*has

*T*×

_{x}*T*

_{y}*item*s (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 (*N _{x}*,

*N*). An object data (

_{y}*d*_

*obj*) consists of the coordinates and the intensity as four float data (

*float*4). In lines 5, 6 and 7 of the Fig.2(b), the variables

*x*and

*y*calculate the coordinates (

*x*,

_{h}*y*) on the CGH plane and

_{h}*adr*calculates the address of the device memory for storing the calculation result

*I*(

*x*,

_{h}*y*). In lines 11 to 16, a CGH point

_{h}*I*(

*x*,

_{h}*y*) can be calculated by iterating for

_{h}*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 *T _{x}*×

*T*= 16×16 took about 215ms. The calculation speed of the kernel is slow.

_{y}#### 2.1. Optimization

The previous source code is not optimized. In this section, we optimize the previous source code to obtain more acceleration speed. Figure 3 shows the optimized kernel function from Fig.2(b).

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} = *P _{j}* ((

*x*-

_{h}*x*)

_{j}^{2}+(

*y*-

_{h}*y*)

_{j}^{2}),

*θ*

_{0}=

*P*(2(

_{j}*x*-

_{h}*x*)+1), ∆ = 2

_{y}*P*. Eventually, we can compute the phase Γ

_{j}_{n}at the next coordinate by the two recurrence formulas. For more details, see Ref.[6]

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 *float*4 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 *float*8 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.

#### 2.2. Results

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.

## 3. Conclusion

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 **95**387–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]

**12. **L. Ahrenberg, P. Benzie, M. Magnor, and J. Watson, “Computer generated holography using parallel commodity graphics hardware,” Opt. Express **14**(17), 7636–7641 (2006). [CrossRef] [PubMed]

**13. **H. Kang, F. Yaras, and L. Onural, “Graphics processing unit accelerated computation of digital holograms,” Appl. Opt. **48**, H137–H143 (2009). [CrossRef] [PubMed]

**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]

**16. **T. Shimobaba, Y. Sato, J. Miura, M. Takenouchi, and T. Ito, “Real-time digital holographic microscopy using the graphic processing unit,” Opt. Express **16**, 11776–11781 (2008) [CrossRef] [PubMed]