• No results found

A New Linkless Hierarchical Structure based on Perfect Hashing

N/A
N/A
Protected

Academic year: 2020

Share "A New Linkless Hierarchical Structure based on Perfect Hashing"

Copied!
10
0
0

Loading.... (view fulltext now)

Full text

(1)

2017 International Conference on Computer Science and Application Engineering (CSAE 2017) ISBN: 978-1-60595-505-6

A New Linkless Hierarchical Structure based on Perfect Hashing

Weiwei Duan, Jianxin Luo*, Guiqiang Ni, Qi Hu and Yi Gao

The College of Command Information Systems, The College of Command Information Systems, 210007 Nanjing, China

ABSTRACT

We explore using perfect spatial hashing to store octrees efficiently while needing no explicit parent-to-child pointers. Specifically, we design a new linkless hierarchical structure – one that encodes the absolute locations of the subdivided nodes using specific tokens and packs these nodes into hash tables using perfect hashing. Whereas prior methods have overhead in space and time due to the unused links and chain of the indirection pointers, our linkless hierarchical structure has lower storage requirements and has an efficient random accessibility on the GPUs. The performance of our scheme is demonstrated on different 2D/3D datasets together with some classical algorithms.

INTRODUCTION

While the hierarchical data structures such as quadtrees and octrees are widely used in graphics, they often store the sparse subset of image/volume with an efficient storage which actually intersects the contour or surface of 2D/3D models. In order to handle large models, devising efficient representation with random access becomes paramount.

Among a number of proposed solutions, the pointer-based octrees need to maintain the parent-to-child pointer links in each tree node, which takes significant memory cost with respect to the actual node data. To avoid the wasteful linkers, a linear quadtree/octree stores the hierarchical structure efficiently in depth first order using a one-dimensional array [1]. However, the quadtree/octree is inefficient on random access due to its linear traversal of the array. Choi et al. use a pyramid of coarse-to-fine bitmaps to implement uniform spatial partitioning such as binary image/volume without storing parent-to-child pointers [2]. While remaining efficient storage usage and hierarchical representation, however, the arbitrary access to the hierarchical tree nodes requires a costly sequence of linkers.

(2)

RELATED WORK

Benson and Davis [4] presented octree textures to store the octree nodes which intersect the surface of a model. The octree textures saved a lot of storage requirements and had a symmetrical sampling on the model surface. DeBry et al. [5] developed a similar texture mapping using octrees at the same time. However, octree has some constraints in both storage and random accessibility. The parent-to-child pointer linkers are significant with respect to the actual data which leads to an inefficient memory usage. Besides, the coarse-to-fine hierarchical nodes cause an inefficient access performance due to a costly sequence of linkers.

To improve the octree performance, researchers present a lot of methods such as GPU-based octree [6], adaptive octree [7] and mixed octree [8]. These methods have saved storage requirements in some specific areas such as 3D painting. However, they are not efficient for common applications and still inefficient in random access.

Some researchers tried to use spatial hashing to encode octree. Lefebvre and Hoppe [3] designed a perfect spatial hashing that compressed the spatial data into a compact hash table which could be implemented efficiently on GPUs. Laine and Karrs presented a sparse voxel octree (SVO) which can efficiently carve out empty space [9]. Scandolo et al. proposed a lossless compression scheme for the high-resolution data based on sparse quadtree encoding. They produced a sparse encoding in the form of a hierarchy and obtained high compression rates [10]. Duan et al. presented a novel hashing scheme to compress highly repetitive spatial data [11]. Bastos [12] used octree level and the node location index to achieve a random access. The octree nodes were mapped into a hash table which stored the data associated with a sparse subset of the domain. However, arbitrary data in hash table would return to the hash function while the index was mapped to an invalid point in domain.

Castro et al. [13] presented a statistical model to improve the runtime performance. Whereas traditional methods searched from the first level, they selected the most frequently accessed level as a starting point of the search. Choi et al [2] presented a linkless octree consisting of a pyramid of coarse-to-fine bitmaps. The bitmap volume at the level ) consisted of non-leaf cells at its previous level , which were compactly packed and then uniformly subdivided to produce finer grids. In their method, arbitrary access to octree nodes must start from the first level iteratively until reaching the leaf node level and in bad case even the deepest level. However, it was inefficient for implementing it on GPUs.

In this paper, we use perfect spatial hashing to map the quadtree/octree nodes of each level into different hash tables respectively. For an arbitrary point query, our new scheme does not need to traverse all levels of the linkless structure. It is efficient for GPUs and has a better performance of random access. Moreover, our multi-level method can satisfy different resolution requirements and achieve a smoother rendering effect.

OUR LINKLESS HIERARCHICAL STRUCTURE

(3)

structure. It uses perfect spatial hashing to compress the tree nodes into compact hash tables without storing explicit parent-to-child pointer links. The challenge of using perfect hashing to pack octree nodes is continuous numbering. Perfect spatial hashing can only compress the data with continuous numbering positions such as . However, traditional octree uses level and location to present the tree nodes. The octree nodes can't be mapped directly into a compact hash table.

To solve this problem, we design a specific token for each node. It represents the absolute position in domain for each node. For arbitrary octree nodes, we can convert them into a continuous numbering domain. Then we compress the converted octree efficiently using perfect hashing. In the linkless structure, we first add tokens for octree nodes of each level to present their absolute positions. Then we use perfect spatial hashing to pack the nodes of a specific level into a compact hash table due to their tokens. To satisfy different resolution requirements, we pack the octree nodes of all levels into several hash tables using multi-level perfect spatial hashing. Furthermore, a bilinear filtering of the nearest two levels is used to achieve a smoother rendering effect.

We will first give a short introduction of the perfect spatial hashing in Section 3.1. Then we show the construction of our new linkless structure in 3D domain and the hash mapping process in Section 3.2. The improved multi-level structure will be discussed later in Section 3.3.

[image:3.612.189.406.388.520.2]

The Perfect Spatial Hashing

Figure 1. The overview of perfect spatial hashing from Lefebvre and Hoppe [3].

Lefebvre and Hoppe [3] propose for the first time the use of a GPU to access a hash table using a perfect hashing. If a hash function has no collisions, it is a perfect

hashing. They use hashing to pack the sparse data into a compact hash table. A perfect hash function is defined as the form of

(1) which combines two imperfect hash functions with an offset table . The offset table is to “jitter” the imperfect hash function into a perfect one. Specifically, the function is simple modulo the hash table size while the function is simple modulo the offset table size.

(4)

calculate the offset values using the function . At last the offset values shift the initial entry into the final entry in the hash table. This process can map the defined data into a compact hash table efficiently. For more details, refer to the perfect spatial hashing by Lefebvre and Hoppe [3].

The Single Level Structure

During the construction of an octree, the volume is subdivided if the subset intersects the model surface. We add a token for each node in the process of

subdivision. The token of node is

[image:4.612.180.413.233.355.2]

evaluated by the center coordinate of this node to express its absolute position in 3D domain.

Figure 2. The subdivision of an octree node .

As shown in Figure 2, during the subdivision of the node , the parameter of its child nodes can be calculated by

(2)

where represents the child nodes and represents the octree level. Specifically, the first octree level has only one root node with a token of

(3) when . The child nodes of other levels can be calculated from the root node iteratively by Formula (2) and Formula (3).

For an arbitrary node of level , according to its token and the level , we can calculate its position in the domain using the following formula:

(4)

(5)
[image:5.612.154.452.66.179.2] [image:5.612.115.443.207.349.2]

Figure 3. Transform octree node to continuous numbering point in domain.

Figure 4 shows the pseudocode of our algorithm:

Figure 4. The pseudocode of our algorithm.

First load the 3D model file and transform the model coordinates into the normalized zone [0, 1]. Then subdivide the 3D model into an octree and calculate the tokens for all nodes using Formula (2) and Formula (3). For a specific resolution requirement, map the corresponding nodes into the continuous numbering domain . Next pack the domain into a compact hash table using the perfect spatial hashing. At last, we can render the 3D model on GPUs efficiently using the compact hash table.

[image:5.612.188.406.502.589.2]

The Multi-Level Structure

Figure 5. Multi-level hash mapping.

(6)

In practical experiments, we use a bilinear filtering of the nearest two levels to achieve a smoother rendering effect.

[image:6.612.148.445.109.260.2]

Figure 6 gives the pseudocode of the multi-level algorithm:

Figure 6. The pseudocode of the multi-level algorithm.

Similar with the single level algorithm, we first load the 3D model file and transform the model coordinates into the normalized zone [0, 1]. Then subdivide the 3D model into an octree and calculate the tokens for all nodes using Formula (2) and Formula (3). For each level of the octree, we iteratively map the nodes into the continuous numbering domains. And pack each domain into the compact hash tables using the perfect spatial hashing. According to the resolution requirement, we select the proper hash tables of the nearest levels and . At last, we can render 3D models on GPUs efficiently using the selected perfect hash tables.

APPLICATIONS AND RESULTS

We next demonstrate the performance of our linkless hierarchical structure on several 2D/3D datasets. Our scheme is compared with Choi's linkless octree [2] and a pointer-based octree [4] on these datasets. The implementations of the compared schemes are self-programmed. We implement them according to the algorithms presented in their papers [2][4]. For simplicity, we test them on datasets with maximal sizes of in 2D domain and of in 3D domain. We think these examples are reprehensive in the paper and can show the efficiency of our method. All results are measured on a 2.3GHz Intel Core2 i7-4712 computer with 4 Gbyte main memory and an NVIDIA GeForce 840M GPU.

Memory Cost

(7)

linkless octree of Choi is 244.55 Kbytes and the memory size of the pointer-based octree is 537.48 Kbytes. Meanwhile, our single level and multi-level linkless octrees require only 168.49 Kbytes and 236.31 Kbytes, respectively. For different experimental results shown in TABLE I, our multi-level octree achieves a compression rate of nearly 50% with respect to the classical pointer-based octree, and nearly equal to the linkless octree of Choi. Furthermore, our single level octree needs less storage than the multi-level octree.

TABLE I. THE MEMORY COST OF DIFFERENT METHODS (kbtyes).

Dataset Resolution

Our single-level method Our multi-level method Linkless octree by Choi Pointer based octree Bulb

104.02 159.61 162.19 350.89 34.13 55.59 58.93 127.50 13.36 21.46 21.83 47.22

5.18 8.10 7.99 17.28

1.77 2.92 2.80 6.04

Drawing

109.84 183.15 185.79 403.89 42.09 73.31 77.89 168.97 19.88 31.22 32.04 69.80

7.76 11.34 12.28 27.28

3.39 3.58 3.39 7.34

Female

168.49 236.31 244.55 537.48 52.21 67.82 64.61 139.79 11.39 15.43 15.08 32.80

2.93 4.04 3.84 8.17

Construction Time

[image:7.612.124.471.174.388.2]

We have compared the construction time among our method, the linkless octree of Choi and the pointer-based octree in this subsection. For the 2D image, the construction of our method takes 48.54 seconds, which is nearly equal to the linkless octree of Choi, and about ten times slower than the pointer-based octree of 4.93 seconds. For the 3D model, the construction of our method takes 31.23 seconds, which is nearly equal to the linkless octree of Choi, and about ten times slower than the pointer-based octree of 2.85 seconds. As shown in TABLE II, for different examples, our method usually takes more construction time than the classical octrees.

TABLE II. THE CONSTRUCTION TIME OF DIFFERENT METHODS (SECONDS).

Dataset Resolution Our

method Linkless octree by Choi Pointer based octree

Bulb 48.54 49.02 4.93

Drawing 50.12 50.36 5.15

Female 31.23 30.31 2.85

(8)

hash table entry for each defined elements without collisions. Since the defined element location depends on the locations of previous defined elements, the inherent sequential construction of hash table and offset table is very costly. The construction time of our method usually takes more time than other two schemes. Fortunately, the costly hash evaluation can be done in the precomputation which does not affect the runtime performance.

During the rendering process, the hash table and offset table are used for point access instead of the original domain. For an arbitrary position query, evaluating a perfect hash value only requires two modulo operations and one lookup operation which takes little time. Hence, the costly hash construction does not affect the efficient runtime performance.

Access Analysis and Rendering Effect

Next we have analyzed the access time performance of different methods. Our method has a better efficiency of random access than the pointer-based octree and the linkless octree of Choi. To achieve random access of a 3D model with defined elements, the pointer-based octree and the linkless octree of Choi must calculate the root node from level 0 to the leaf nodes of level

iteratively. The process is time costly and they are inefficient on the GPUs. Due to the perfect hashing, our linkless structure can access arbitrary defined elements in

[image:8.612.100.479.372.561.2]

time using a compact hash table, which is very suitable for GPUs.

Figure 7. The rendering effects of the pointer-based octree (a), the Choi’s scheme (b), our single level method (c) and our multi-level method (d).

(9)

However, the memory consumption of our multi-level method is no more than the Choi’s scheme and the pointer-based scheme.

ACKNOWLEDGEMENT

This research work was supported by the grants from the Chinese National Defense Foundation of Science and Technology (CNDFST) under No.3602027 and was also supported by the Natural Science Youth Foundation of Jiangsu Province (NSYFJP) under grant NO.BK20150722. We would like to thank all the reviewers of this paper for their valuable and constructive comments. The authors declare that there is no conflict of interest regarding the publication of this paper.

CONCLUSIONS

We present a new linkless hierarchical structure without storing explicit parent-to-child pointer linkers while maintaining efficient random access. In our method, we first add tokens for the octree nodes to represent their absolute position. Then we convert these nodes into several continuous numbering domains. Next we pack the defined data of the domains into compact hash tables using perfect spatial hashing. We use several small hash tables to store all octree nodes without any loss. Furthermore, our method needs less storage and shows a smoother rendering effect as a result of using a bilinear filtering of the nearest two hash tables.

However, our method still has some limitations. Since perfect spatial hashing is sensitive to data structure, inserting or deleting operations in a hash table usually lead to rebuilding the entire hash table. Our linkless tree can’t represent dynamically changing data. In the future, we will improve our linkless structure for dynamic updates.

REFERENCES

1. I. G. 1982. “An effective way to represent quadtrees,” Communications of ACM, 25(12):905-910. 2. Choi, M., Ju, E., Chang, J., Lee, J. and Y. Kim. 2009. “Linkless octree using multi-level perfect

hashing,” Computer Graphics Forum, 28(7):1773-1780.

3. Lefebvre, S. and H. Hoppe. 2006. “Perfect spatial hashing,” ACM Transactions on Graphics, 25(3):579-588.

4. Benson, D. and J. Davis. 2002. “Octree textures,” ACM Transactions on Graphics, 21(3):785-790.

5. Debry, D., Gibbs, J., Petty, D. and N. Robins. 2002. “Painting and rendering textures on unparameterized models,” ACM, pp.763-768.

6. Frolov, V., Kharlamov, A., Galaktionov, V. and K. Vostryakov. 2014. “Multiple reference octrees for a gpu photon mapping and irradiance caching,” Programming and Computer Software, 40(4):208-214.

7. Wong, T., Leach, G. and F. Zambetta. 2014. “An adaptive octree grid for gpu based collision detection of deformable objects,” The Visual Computer, 30(6):729-738.

8. Zhang, C., Pan, M. and X. Huihong. 2007. “Hybrid blocking octree-based mass volume rendering,” Computer Engineering, 33(14):33-35.

9. Laine, L. and T. Karras. 2011. “Efficient sparse voxel octrees,” IEEE Trans Vis Computer Graph, 17(8):1048-1059.

(10)

11.Duan, W., Luo, J., Ni, G., Tang, B., Hu, Q. and Y. Gao. 2017. “Exclusive Grouped Spatial Hashing,” Computer & Grpahics, in press.

12.Bastos, T. and W. Celes. 2008. “Gpu-accelerated adaptively sampled distance fields,” IEEE International Conference on Shape Modeling and Applications, pp.171-178.

Figure

Figure 1. The overview of perfect spatial hashing from Lefebvre and Hoppe [3].
Figure 2. The subdivision of an octree node .
Figure 3. Transform octree node   to continuous numbering point  in domain.
Figure 6. The pseudocode of the multi-level algorithm.
+3

References

Related documents