GENIE
DeviceCodecFactory.cu
Go to the documentation of this file.
2 #include "DeviceVarintCodec.h"
3 #include "DeviceCompositeCodec.h"
4 #include "DeviceSerialCodec.h"
6 
7 #include "DeviceCodecFactory.h"
8 
9 using namespace genie::compression;
10 using namespace genie::matching;
11 using namespace std;
12 
17 
18 
19 map<COMPRESSION_TYPE, shared_ptr<DeviceIntegerCODEC>> initCodecInstancesMap()
20 {
21  map<COMPRESSION_TYPE, shared_ptr<DeviceIntegerCODEC>> map;
22 
23  map[NO_COMPRESSION] = shared_ptr<DeviceIntegerCODEC>(nullptr);
24  map[COPY] = shared_ptr<DeviceIntegerCODEC>(new DeviceCopyCodec());
25  map[DELTA] = shared_ptr<DeviceIntegerCODEC>(new DeviceDeltaCodec());
26  map[BP32] = shared_ptr<DeviceIntegerCODEC>(new DeviceBitPackingCodec());
27  map[VARINT] = shared_ptr<DeviceIntegerCODEC>(new DeviceVarintCodec());
28  map[COMP_BP32_COPY] = shared_ptr<DeviceIntegerCODEC>(new DeviceCompositeCodec<DeviceBitPackingCodec,DeviceCopyCodec>());
29  map[COMP_BP32_VARINT] = shared_ptr<DeviceIntegerCODEC>(new DeviceCompositeCodec<DeviceBitPackingCodec,DeviceVarintCodec>());
30  map[SERIAL_COPY_COPY] = shared_ptr<DeviceIntegerCODEC>(new DeviceSerialCodec<DeviceCopyCodec,DeviceCopyCodec>());
31  map[SERIAL_DELTA_COPY] = shared_ptr<DeviceIntegerCODEC>(new DeviceSerialCodec<DeviceDeltaCodec,DeviceCopyCodec>());
32  map[SERIAL_DELTA_DELTA] = shared_ptr<DeviceIntegerCODEC>(new DeviceSerialCodec<DeviceDeltaCodec,DeviceDeltaCodec>());
33  map[SERIAL_DELTA_VARINT] = shared_ptr<DeviceIntegerCODEC>(new DeviceSerialCodec<DeviceDeltaCodec,DeviceVarintCodec>());
34  map[SERIAL_DELTA_BP32] = shared_ptr<DeviceIntegerCODEC>(new DeviceSerialCodec<DeviceDeltaCodec,DeviceBitPackingCodec>());
37 
38  return map;
39 }
40 
41 const map<COMPRESSION_TYPE, shared_ptr<DeviceIntegerCODEC>> DeviceCodecFactory::codecInstancesMap = initCodecInstancesMap();
42 
43 // NOTE: Template instantiation of match_integrated is in match_integrated.cu
44 //
45 // TODO: Figure out a way how to separate match_integrated instances into multiple files, similar to how Codecs
46 // templates are instantiated in their respective .cu files
47 
48 map<COMPRESSION_TYPE, MatchIntegratedFunPtr> initIntegratedKernelsMap()
49 {
50  map<COMPRESSION_TYPE, MatchIntegratedFunPtr> map;
51 
52  map[NO_COMPRESSION] = nullptr;
57  map[COMP_BP32_COPY] = match_integrated<DeviceCompositeCodec<DeviceBitPackingCodec,DeviceCopyCodec>>;
58  map[COMP_BP32_VARINT] = match_integrated<DeviceCompositeCodec<DeviceBitPackingCodec,DeviceVarintCodec>>;
59  map[SERIAL_COPY_COPY] = match_integrated<DeviceSerialCodec<DeviceCopyCodec,DeviceCopyCodec>>;
60  map[SERIAL_DELTA_COPY] = match_integrated<DeviceSerialCodec<DeviceDeltaCodec,DeviceCopyCodec>>;
61  map[SERIAL_DELTA_DELTA] = match_integrated<DeviceSerialCodec<DeviceDeltaCodec,DeviceDeltaCodec>>;
62  map[SERIAL_DELTA_VARINT] = match_integrated<DeviceSerialCodec<DeviceDeltaCodec,DeviceVarintCodec>>;
63  map[SERIAL_DELTA_BP32] = match_integrated<DeviceSerialCodec<DeviceDeltaCodec,DeviceBitPackingCodec>>;
64  map[SERIAL_DELTA_COMP_BP32_COPY] = match_integrated<DeviceSerialCodec<DeviceDeltaCodec,DeviceCompositeCodec<DeviceBitPackingCodec,DeviceCopyCodec>>>;
65  map[SERIAL_DELTA_COMP_BP32_VARINT] = match_integrated<DeviceSerialCodec<DeviceDeltaCodec,DeviceCompositeCodec<DeviceBitPackingCodec,DeviceVarintCodec>>>;
66 
67  return map;
68 }
69 
70 const map<COMPRESSION_TYPE, MatchIntegratedFunPtr> DeviceCodecFactory::integratedKernelsMap = initIntegratedKernelsMap();
71 
72 map<COMPRESSION_TYPE, string> initCompressionNamesMap()
73 {
74  map<COMPRESSION_TYPE, string> map;
75  for (auto it = DeviceCodecFactory::codecInstancesMap.begin(); it != DeviceCodecFactory::codecInstancesMap.end(); it++)
76  {
77  if (it->second.get())
78  map[it->first] = it->second->name();
79  }
80  map[NO_COMPRESSION] = string("no");
81  return map;
82 }
83 
84 const map<COMPRESSION_TYPE, string> DeviceCodecFactory::compressionNamesMap = initCompressionNamesMap();
85 
86 map<string, COMPRESSION_TYPE> initCompressionTypesMap()
87 {
88  map<string, COMPRESSION_TYPE> map;
90  map[it->second] = it->first;
91  return map;
92 }
93 
94 const map<string, COMPRESSION_TYPE> DeviceCodecFactory::compressionTypesMap = initCompressionTypesMap();
95 
96 vector<string> initAllCompressionNames()
97 {
98  vector<string> names;
100  names.push_back(i->second);
101  return names;
102 }
103 
105 
106 vector<COMPRESSION_TYPE> initAllCompressionTypes()
107 {
108  vector<COMPRESSION_TYPE> types;
110  types.push_back(i->first);
111  return types;
112 }
113 
114 const vector<COMPRESSION_TYPE> DeviceCodecFactory::allCompressionTypes = initAllCompressionTypes();
115 
116 const shared_ptr<DeviceIntegerCODEC> DeviceCodecFactory::nullCodec = shared_ptr<DeviceIntegerCODEC>(nullptr);
117 
template void match_integrated< DeviceBitPackingCodec >(inv_compr_table &, std::vector< Query > &, thrust::device_vector< data_t > &, thrust::device_vector< u32 > &, int, int, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &)
static const std::map< COMPRESSION_TYPE, std::shared_ptr< DeviceIntegerCODEC > > codecInstancesMap
map< string, COMPRESSION_TYPE > initCompressionTypesMap()
static const std::vector< std::string > allCompressionNames
const COMPRESSION_TYPE DEFAULT_COMPRESSION_TYPE
Definition: interface.cc:48
static const std::vector< COMPRESSION_TYPE > allCompressionTypes
template void match_integrated< DeviceCopyCodec >(inv_compr_table &, std::vector< Query > &, thrust::device_vector< data_t > &, thrust::device_vector< u32 > &, int, int, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &)
static const std::map< COMPRESSION_TYPE, MatchIntegratedFunPtr > integratedKernelsMap
map< COMPRESSION_TYPE, MatchIntegratedFunPtr > initIntegratedKernelsMap()
map< COMPRESSION_TYPE, shared_ptr< DeviceIntegerCODEC > > initCodecInstancesMap()
static const std::shared_ptr< DeviceIntegerCODEC > nullCodec
const COMPRESSION_TYPE LIGHTWEIGHT_COMPRESSION_TYPE
map< COMPRESSION_TYPE, string > initCompressionNamesMap()
static const std::map< std::string, COMPRESSION_TYPE > compressionTypesMap
template void match_integrated< DeviceDeltaCodec >(inv_compr_table &, std::vector< Query > &, thrust::device_vector< data_t > &, thrust::device_vector< u32 > &, int, int, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &)
const COMPRESSION_TYPE HEAVYWEIGHT_COMPRESSION_TYPE
vector< string > initAllCompressionNames()
template void match_integrated< DeviceVarintCodec >(inv_compr_table &, std::vector< Query > &, thrust::device_vector< data_t > &, thrust::device_vector< u32 > &, int, int, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &, thrust::device_vector< u32 > &)
static const std::map< COMPRESSION_TYPE, std::string > compressionNamesMap
vector< COMPRESSION_TYPE > initAllCompressionTypes()
const COMPRESSION_TYPE MIDDLEWEIGHT_COMPRESSION_TYPE