ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
SlabMacros.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 // Copyright 2019 Saman Ashkiani
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
19 // implied. See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 #include <cstdint>
24 
26 
27 namespace cloudViewer {
28 namespace core {
29 
30 // Device-specific, safe for current NVIDIA architectures.
31 static constexpr uint32_t kWarpSize = 32;
32 
34 // Tunable variables
36 // HashMap
37 static constexpr uint32_t kSuperBlocks = 32;
38 static constexpr uint32_t kBlocksPerSuperBlock = 4;
39 static constexpr uint32_t kBlocksPerSuperBlockInBits = 2;
40 static constexpr uint32_t kSlabsPerBlock = 1024;
41 
42 // Misc
43 static constexpr uint32_t kMaxKeyByteSize = 32;
44 static constexpr uint32_t kThreadsPerBlock = 128;
45 
47 // Combination of tunable variables
49 static constexpr uint32_t kUIntsPerBlock = kSlabsPerBlock * kWarpSize;
50 // We need one bitmap (32-bit) per slab (32 nodes). Number of bitmaps is equal
51 // to number of slabs.
52 static constexpr uint32_t kBitmapsPerSuperBlock =
54 static constexpr uint32_t kUIntsPerSuperBlock =
56 
58 // Non-tunable variables
60 // Mask offsets
61 static constexpr uint32_t kSuperBlockMaskBits = 27;
62 static constexpr uint32_t kBlockMaskBits = 10;
63 static constexpr uint32_t kSlabMaskBits = 5;
64 
65 // Masks & flags
66 static constexpr uint32_t kSyncLanesMask = 0xFFFFFFFF;
67 static constexpr uint32_t kNodePtrLanesMask = 0x7FFFFFFF;
68 static constexpr uint32_t kNextSlabPtrLaneId = 31;
69 
70 static constexpr uint32_t kHeadSlabAddr = 0xFFFFFFFE;
71 
72 static constexpr uint32_t kEmptySlabAddr = 0xFFFFFFFF;
73 static constexpr uint32_t kEmptyNodeAddr = 0xFFFFFFFF;
74 static constexpr uint32_t kNullAddr = 0xFFFFFFFF;
75 
76 static constexpr uint32_t kNotFoundFlag = 0xFFFFFFFF;
77 
78 #define MEMCPY_AS_INTS(dst, src, num_bytes) \
79  auto dst_in_int = reinterpret_cast<int*>(dst); \
80  auto src_in_int = reinterpret_cast<const int*>(src); \
81  int count_in_int = num_bytes / sizeof(int); \
82  for (int i = 0; i < count_in_int; ++i) { \
83  dst_in_int[i] = src_in_int[i]; \
84  }
85 
86 } // namespace core
87 } // namespace cloudViewer
Common CUDA utilities.
static constexpr uint32_t kBlocksPerSuperBlock
Definition: SlabMacros.h:38
static constexpr uint32_t kNullAddr
Definition: SlabMacros.h:74
static constexpr uint32_t kNextSlabPtrLaneId
Definition: SlabMacros.h:68
static constexpr uint32_t kHeadSlabAddr
Definition: SlabMacros.h:70
static constexpr uint32_t kEmptyNodeAddr
Definition: SlabMacros.h:73
static constexpr uint32_t kUIntsPerSuperBlock
Definition: SlabMacros.h:54
static constexpr uint32_t kUIntsPerBlock
Definition: SlabMacros.h:49
static constexpr uint32_t kSyncLanesMask
Definition: SlabMacros.h:66
static constexpr uint32_t kSlabsPerBlock
Definition: SlabMacros.h:40
static constexpr uint32_t kWarpSize
Definition: SlabMacros.h:31
static constexpr uint32_t kBlockMaskBits
Definition: SlabMacros.h:62
static constexpr uint32_t kEmptySlabAddr
Definition: SlabMacros.h:72
static constexpr uint32_t kNodePtrLanesMask
Definition: SlabMacros.h:67
static constexpr uint32_t kSlabMaskBits
Definition: SlabMacros.h:63
static constexpr uint32_t kMaxKeyByteSize
Definition: SlabMacros.h:43
static constexpr uint32_t kSuperBlocks
Definition: SlabMacros.h:37
static constexpr uint32_t kNotFoundFlag
Definition: SlabMacros.h:76
static constexpr uint32_t kSuperBlockMaskBits
Definition: SlabMacros.h:61
static constexpr uint32_t kBitmapsPerSuperBlock
Definition: SlabMacros.h:52
static constexpr uint32_t kThreadsPerBlock
Definition: SlabMacros.h:44
static constexpr uint32_t kBlocksPerSuperBlockInBits
Definition: SlabMacros.h:39
Generic file read and write utility for python interface.