GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
graphlab_options.hpp
1 /**
2  * Copyright (c) 2009 Carnegie Mellon University.
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an "AS
13  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14  * express or implied. See the License for the specific language
15  * governing permissions and limitations under the License.
16  *
17  * For more about this software visit:
18  *
19  * http://www.graphlab.ml.cmu.edu
20  *
21  */
22 
23 
24 /**
25  * Also contains code that is Copyright 2011 Yahoo! Inc. All rights
26  * reserved.
27  *
28  * Contributed under the iCLA for:
29  * Joseph Gonzalez ([email protected])
30  *
31  */
32 
33 
34 
35 #ifndef GRAPHLAB_GRAPHLAB_OPTIONS_HPP
36 #define GRAPHLAB_GRAPHLAB_OPTIONS_HPP
37 
38 #include <graphlab/options/options_map.hpp>
39 
40 #include <graphlab/parallel/pthread_tools.hpp>
41 namespace graphlab {
42 
43 
44  /**
45  * The engine options class is really a simple struct that contains
46  * the basic options needed to create an engine. These options
47  * include:
48 
49  <ul>
50 
51  <li> size_t ncpus: The number of cpus (threads) to use for this
52  engine. </li>
53 
54  <li> std::string engine_type: The type of engine to use. Currently
55  we support {async, synchronous}. </li>
56 
57  <li> std::string scheduler_type: The type of scheduler to user.
58  Currently we support a wide range of schedulers: {synchronous,
59  fifo, priority, sampling, splash, sweep, multiqueue_fifo,
60  multiqueue_priority, set, clustered_priority, round_robin,
61  chromatic} </li>
62 
63  <li> size_t splash_size: The size parameter for the splash
64  scheduler. </li>
65  </ul>
66  */
68  public:
69  //! The number of cpus
70  size_t ncpus;
71 
72  //! The type of scheduler to use
73  std::string scheduler_type;
74 
75  //! additional arguments to the engine
77 
78  //! additional arguments to the scheduler
80 
81  //! Options for the graph
83 
85  ncpus(thread::cpu_count() > 2 ? (thread::cpu_count() - 2) : 2) {
86  // Grab all the compiler flags
87  /* \todo: Add these back at some point
88  #ifdef COMPILEFLAGS
89  #define QUOTEME_(x) #x
90  #define QUOTEME(x) QUOTEME_(x)
91  compile_flags = QUOTEME(COMPILEFLAGS);
92  #undef QUOTEME
93  #undef QUOTEME_
94  #endif
95  */
96  } // end of constructor
97 
98 
99 
100 
101  virtual ~graphlab_options() {}
102 
103 
104  //! Set the number of cpus
105  void set_ncpus(size_t n) { ncpus = n; }
106 
107  //! Get the number of cpus
108  size_t get_ncpus() const { return ncpus; }
109 
110  void set_scheduler_type(const std::string& stype) {
111  //! \todo: ADD CHECKING
112  scheduler_type = stype;
113  }
114 
115 
116  //! Get the type of scheduler
117  const std::string& get_scheduler_type() const {
118  return scheduler_type;
119  }
120 
121  //! Get the engine arguments
122  const options_map& get_engine_args() const {
123  return engine_args;
124  }
125 
126  //! Get the engine arguments
128  return engine_args;
129  }
130 
131  const options_map& get_graph_args() const {
132  return graph_args;
133  }
134 
135  options_map& get_graph_args() {
136  return graph_args;
137  }
138 
139 
140  const options_map& get_scheduler_args() const {
141  return scheduler_args;
142  }
143 
144  options_map& get_scheduler_args() {
145  return scheduler_args;
146  }
147 
148  /**
149  * Display the current engine options
150  */
151  virtual void print() const {
152  std::cout << "GraphLab Options -------------------\n"
153  << "ncpus: " << ncpus << "\n"
154  << "scheduler: " << scheduler_type << "\n";
155  std::cout << "\n";
156  std::cout << "Scheduler Options: \n";
157  std::cout << scheduler_args;
158  std::cout << "Graph Options: \n";
159  std::cout << graph_args;
160  std::cout << "Engine Options: \n";
161  std::cout << engine_args;
162  std::cout << std::endl;
163  }
164 
165 
166 
167  };
168 
169 
170 
171 }
172 #endif
173