cheshirekow  v0.1.0
PackedIndex.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
26 #ifndef MPBLOCKS_DUBINS_CURVES_CUDA_PACKEDINDEX_H_
27 #define MPBLOCKS_DUBINS_CURVES_CUDA_PACKEDINDEX_H_
28 
29 // Don't include <cstdint> as that requires c++11 and nvcc does not yet
30 // support that. It doest support c99 hover, co stdint.h is OK.
31 #include <stdint.h>
34 
35 namespace mpblocks {
36 namespace dubins {
37 namespace curves_cuda {
38 
41 template <unsigned int BYTES>
42 struct PackedStorage{ typedef uint32_t Result; };
43 
44 template <> struct PackedStorage<1>{ typedef uint8_t Result; };
45 template <> struct PackedStorage<2>{ typedef uint16_t Result; };
46 template <> struct PackedStorage<4>{ typedef uint32_t Result; };
47 template <> struct PackedStorage<8>{ typedef uint64_t Result; };
48 
52 template <typename PunType>
53 class PackedIndex {
54  public:
56 
57  private:
59 
60  public:
62  PackedIndex(PunType bits);
63 
66 
68  SolutionId getId() const;
69 
71  StorageType getIdx() const;
72 
74  void setId(SolutionId id);
75 
77  void setIdx(StorageType idx);
78 
80  PunType& getPun();
81 
83  void setPun(PunType bits);
84 
87 
89  void setUnsigned(StorageType bits);
90 };
91 
92 } // curves
93 } // dubins
94 } // mpblocks
95 
96 #endif // MPBLOCKS_DUBINS_CURVES_CUDA_PACKEDINDEX_H_
PackedStorage< sizeof(PunType)>::Result StorageType
Definition: PackedIndex.h:55
__device__ __host__ Storage_t getIdx() const
Definition: PackedIndex.hpp:66
__device__ __host__ SolutionId getId() const
Definition: PackedIndex.hpp:53
__device__ __host__ Format_t & getPun()
Definition: PackedIndex.hpp:99
__device__ __host__ void setUnsigned(Storage_t bits)
__device__ __host__ void setIdx(Storage_t idx)
Definition: PackedIndex.hpp:89
__device__ __host__ PackedIndex(Format_t bits)
Definition: PackedIndex.hpp:46
Template meta function which defines internal typedef Result to be an unsigned integer of size BYTES...
Definition: PackedIndex.h:41
__device__ __host__ void setId(SolutionId id)
Definition: PackedIndex.hpp:80
__device__ __host__ Storage_t getUnsigned()
#define __device__
Definition: fakecuda.h:34
#define __host__
Definition: fakecuda.h:37
stores both the index of the entry and the solution id of it's best solver in a bitfield ...
Definition: PackedIndex.h:52
SolutionId
enumerates solution types
Definition: types.h:49
compatability macros between host code and device code
__device__ __host__ void setPun(Format_t bits)