GENIE
config.cc
Go to the documentation of this file.
3 
4 #include "config.h"
5 
6 using namespace genie;
7 using namespace genie::utility;
8 using namespace std;
9 
10 uint32_t genie::Config::GetK() const
11 {
12  return k_;
13 }
14 
16 {
17  return query_range_;
18 }
19 
21 {
22  return num_of_queries_;
23 }
24 
26 {
27  return save_to_gpu_;
28 }
29 
30 uint8_t genie::Config::GetGpuId() const
31 {
32  return gpu_id_;
33 }
34 
35 Config& genie::Config::SetK(const uint32_t k)
36 {
37  k_ = k;
38  k_initialized_ = true;
39  return *this;
40 }
41 
42 Config& genie::Config::SetQueryRange(const uint32_t query_range)
43 {
44  query_range_ = query_range;
45  query_range_initialized_ = true;
46  return *this;
47 }
48 
49 Config& genie::Config::SetNumOfQueries(const uint32_t num_of_queries)
50 {
51  num_of_queries_ = num_of_queries;
52  num_of_queries_initialized_ = true;
53  return *this;
54 }
55 
56 Config& genie::Config::SetSaveToGpu(const bool save_to_gpu)
57 {
58  save_to_gpu_ = save_to_gpu;
59  return *this;
60 }
61 
62 Config& genie::Config::SetGpuId(const uint8_t gpu_id)
63 {
64  gpu_id_ = gpu_id;
65  return *this;
66 }
67 
68 Config& genie::Config::LoadFromFile(const string& filename)
69 {
71 }
72 
74 {
75  return k_initialized_;
76 }
77 
79 {
80  return query_range_initialized_;
81 }
82 
84 {
85  return num_of_queries_initialized_;
86 }
87 
89 {
90  if (!k_initialized_)
91  throw exception::InvalidConfigurationException("K is not set.");
92  if (!num_of_queries_initialized_)
93  throw exception::InvalidConfigurationException("Number of query is not set.");
94 }
95 
97 {
98  Logger::log(Logger::INFO, "GENIE configuration:");
99  Logger::log(Logger::INFO, "K: %d", k_);
100  Logger::log(Logger::INFO, "Number of queries: %d", num_of_queries_);
101  if (IsQueryRangeSet())
102  Logger::log(Logger::INFO, "Query range: %d", query_range_);
103  Logger::log(Logger::INFO, "Save to GPU: %s", save_to_gpu_ ? "true" : "false");
104  Logger::log(Logger::INFO, "GPU used: %d", gpu_id_);
106 }
Config & SetGpuId(const uint8_t gpu_id)
Set the ID of the GPU used.
Definition: config.cc:62
uint8_t GetGpuId() const
Return the ID of the GPU used.
Definition: config.cc:30
This is the top-level namespace of the project.
Config & SetNumOfQueries(const uint32_t num_of_queries)
Set the number of query to search.
Definition: config.cc:49
Config & SetQueryRange(const uint32_t query_range)
Set the range used in range-based search.
Definition: config.cc:42
void Validate() const
Validate that all required options are set.
Definition: config.cc:88
static const int INFO
Definition: Logger.h:49
uint32_t GetK() const
Return K.
Definition: config.cc:10
Config & SetSaveToGpu(const bool save_to_gpu)
Set whether table should be saved to GPU after search.
Definition: config.cc:56
uint32_t GetQueryRange() const
Return the range used in range-based search.
Definition: config.cc:15
void DisplayConfiguration()
Display enabled configuration options.
Definition: config.cc:96
static int log(int level, const char *fmt,...)
Record and print a message into log file.
Definition: Logger.cc:99
Config & SetK(const uint32_t k)
Set k.
Definition: config.cc:35
Config class holds all user configurable settings of GENIE.
Definition: config.h:20
Config & LoadFromFile(const std::string &filename)
Load configuration from a file.
Definition: config.cc:68
bool IsNumOfQueriesSet() const
Return whether the number of query has been set.
Definition: config.cc:83
bool IsQueryRangeSet() const
Return whether the query range has been set.
Definition: config.cc:78
bool GetSaveToGpu() const
Return whether table should be saved to GPU after search.
Definition: config.cc:25
uint32_t GetNumOfQueries() const
Return the number of query to search.
Definition: config.cc:20
bool IsKSet() const
Return whether K has been set.
Definition: config.cc:73