コード例 #1
0
ファイル: unity_server_capi.cpp プロジェクト: ana2s007/SFrame
/**
 * Starts the server in the same process.
 *
 * \param root_path directory of the graphlab installation
 * \param server_address the inproc address of the server, could be anything like "inproc://test_server"
 * \param log_file local file for logging
 */
EXPORT void start_server(const char* root_path,
                         const char* server_address,
                         const char* log_file,
                         size_t log_rotation_interval,
                         size_t log_rotation_truncate) {

  ASSERT_MSG(boost::starts_with(std::string(server_address), "inproc://"), "Server address must starts with inproc://");

  namespace fs = boost::filesystem;
  global_logger().set_log_level(LOG_INFO);
  global_logger().set_log_to_console(false);

  graphlab::unity_server_options server_options;
  // Example: "inproc://graphlab_server";
  server_options.server_address = server_address;
  // Example: "/tmp/sframe.log";
  server_options.log_file = log_file;
  // Example: "/home/jay/virtualenv/lib/python2.7/site-packages/sframe"
  server_options.root_path = fs::path(root_path).string();
  // Example: "log_rotation_interval = 86400", "log_rotation_truncate = 8"
  server_options.log_rotation_interval = log_rotation_interval;
  server_options.log_rotation_truncate = log_rotation_truncate;

  graphlab::start_server(server_options);
}
コード例 #2
0
ファイル: unity_server.cpp プロジェクト: imjerrybao/SFrame
void unity_server::set_log_progress(bool enable) {
  global_logger().add_observer(LOG_PROGRESS, NULL);
  if (enable == true) {
    // set the progress observer
    global_logger().add_observer(
        LOG_PROGRESS,
        [=](int lineloglevel, const char* buf, size_t len){
          std::cout << "PROGRESS: " << std::string(buf, len);
        });
  }
}
コード例 #3
0
ファイル: log_rotate.cpp プロジェクト: Hannah1999/Dato-Core
void log_rotation_background_thread() {
  while(thread_running) {
    // set up the current logger
    std::string current_log_file = make_file_name(log_base_name, log_counter);
    global_logger().set_log_file(current_log_file);
    unlink(symlink_name.c_str());
    symlink(current_log_file.c_str(), symlink_name.c_str());
    
    // if our counter exceeds the truncate limit, delete earlier files
    if (truncate_limit > 0 && log_counter >= truncate_limit) {
      // delete oldest files
      std::string oldest_log_file = make_file_name(log_base_name, 
                                                   log_counter - truncate_limit); 
      unlink(oldest_log_file.c_str());
    }

    // sleep for the log interval period.
    // We maintain our own additional timer to prevent spurious wakeups
    timer ti; ti.start();
    lock.lock();
    while (thread_running && ti.current_time() < log_interval) {
      cond.timedwait(lock, log_interval);
    }
    lock.unlock();

    ++log_counter;
  }
}
コード例 #4
0
AOVoxelTree::AOVoxelTree(
    const Scene&    scene,
    const GScalar   max_extent_fraction)
{
    assert(max_extent_fraction > GScalar(0.0));

    // Print a progress message.
    RENDERER_LOG_INFO("building ambient occlusion voxel tree...");

    // Compute the bounding box of the scene.
    const GAABB3 scene_bbox = scene.compute_bbox();

    // Compute the maximum extent of a leaf, in world space.
    const GScalar max_extent = max_extent_fraction * max_value(scene_bbox.extent());

    // Build the tree.
    BuilderType builder(m_tree, scene_bbox, max_extent);
    build(scene, builder);
    builder.complete();

    // Print statistics.
    TreeStatisticsType tree_stats(m_tree, builder);
    RENDERER_LOG_DEBUG("ambient occlusion voxel tree statistics:");
    tree_stats.print(global_logger());
}
コード例 #5
0
AOVoxelTreeIntersector::~AOVoxelTreeIntersector()
{
#ifdef FOUNDATION_VOXEL_ENABLE_TRAVERSAL_STATS
    RENDERER_LOG_DEBUG("ambient occlusion voxel traversal statistics:");
    m_traversal_stats.print(global_logger());
#endif
}
コード例 #6
0
ファイル: logger_factory.cpp プロジェクト: 01org/intelRSD
LoggerSPtr LoggerFactory::get_logger(const char* name, bool only_defined) const {
    if (!name) {
        return global_logger();
    }
    std::string logger(name);
    return get_logger(logger, only_defined);
}
コード例 #7
0
ファイル: logger_factory.cpp プロジェクト: 01org/intelRSD
std::vector<LoggerSPtr> LoggerFactory::get_loggers() const {
    std::vector<LoggerSPtr> loggers;
    loggers.emplace_back(global_logger());
    for (auto logger: m_loggers) {
        loggers.emplace_back(logger.second);
    }
    return loggers;
}
コード例 #8
0
int main(int argc, char** argv) {
    std::cout << "Starting PageRank computation." << std::endl;
    // Initialize control plain using mpi
    //graphlab::mpi_tools::init(argc, argv);

    global_logger().set_log_level(LOG_INFO);

    // Parse command line options -----------------------------------------------
    graphlab::command_line_options clopts("PageRank algorithm.");
    std::string graph_dir;
    std::string format = "adj";
    std::string exec_type = "synchronous";
    clopts.attach_option("graph", graph_dir,
                         "The graph file.  If none is provided "
                         "then a toy graph will be created");
    clopts.add_positional("graph");
    clopts.attach_option("engine", exec_type,
                         "The engine type synchronous or asynchronous");
    clopts.attach_option("tol", TOLERANCE,
                         "The permissible change at convergence.");
    clopts.attach_option("format", format,
                         "The graph file format");
    size_t powerlaw = 0;
    clopts.attach_option("powerlaw", powerlaw,
                         "Generate a synthetic powerlaw out-degree graph. ");
    clopts.attach_option("iterations", ITERATIONS,
                         "If set, will force the use of the synchronous engine"
                         "overriding any engine option set by the --engine parameter. "
                         "Runs complete (non-dynamic) PageRank for a fixed "
                         "number of iterations. Also overrides the iterations "
                         "option in the engine");
    clopts.attach_option("use_delta", USE_DELTA_CACHE,
                         "Use the delta cache to reduce time in gather.");
    std::string saveprefix;
    clopts.attach_option("saveprefix", saveprefix,
                         "If set, will save the resultant pagerank to a "
                         "sequence of files with prefix saveprefix");

    if(!clopts.parse(argc, argv)) {
        std::cout << "Error in parsing command line arguments." << std::endl;
        return EXIT_FAILURE;
    }

    // Enable gather caching in the engine
    clopts.get_engine_args().set_option("use_cache", USE_DELTA_CACHE);

    if (ITERATIONS) {
        // make sure this is the synchronous engine
        std::cout << "--iterations set. Forcing Synchronous engine, and running "
                  << "for " << ITERATIONS << " iterations." << std::endl;
        clopts.get_engine_args().set_option("type", "synchronous");
        clopts.get_engine_args().set_option("max_iterations", ITERATIONS);
        clopts.get_engine_args().set_option("sched_allv", true);
    }

    start(clopts, graph_dir, format, exec_type, saveprefix);
    return EXIT_SUCCESS;
} // End of main
コード例 #9
0
 inline static void exec(int loglevel,const char* file,const char* function,
                         int line,const char* fmt, ... ) {
   va_list argp;
   va_start(argp, fmt);
   global_logger()._log(loglevel, file, function, line, fmt, argp);
   va_end(argp);
   if(loglevel == LOG_FATAL) {
     __print_back_trace();
     GRAPHLAB_LOGGER_FAIL_METHOD("LOG_FATAL encountered");
   }
 }
コード例 #10
0
void TestRunnerThread::run()
{
    QtTestListener listener(m_output_widget, m_result_widget);
    TestResult result;

    global_logger().set_enabled(false);

    const filesystem::path old_current_path =
        Application::change_current_directory_to_tests_root_path();

    m_repository.run(listener, result);

    filesystem::current_path(old_current_path);

    global_logger().set_enabled(true);

    const int failed_count = static_cast<int>(result.get_case_failure_count());
    const int passed_count = static_cast<int>(result.get_case_execution_count()) - failed_count;

    emit signal_finished(passed_count, failed_count);
}
コード例 #11
0
int main(int argc, char** argv) {
  // Initialize control plain using mpi
  graphlab::mpi_tools::init(argc, argv);
  graphlab::distributed_control dc;
  global_logger().set_log_level(LOG_INFO);

  std::string ingraph, informat;
  std::string outgraph, outformat;
  bool gzip = true;
  // Parse command line options -----------------------------------------------
  graphlab::command_line_options clopts("Graph Format Conversion.", true);

  clopts.attach_option("ingraph", ingraph,
                       "The input graph file. Required ");
  clopts.attach_option("informat", informat,
                       "The input graph file format");
  clopts.attach_option("outgraph", outgraph,
                       "The output graph file. Required ");
  clopts.attach_option("outformat", outformat,
                       "The output graph file format");
  clopts.attach_option("outgzip", gzip,
                       "If output is to be gzip compressed"); 

  if(!clopts.parse(argc, argv)) {
    dc.cout() << "Error in parsing command line arguments." << std::endl;
    return EXIT_FAILURE;
  }
 
  if (ingraph.length() == 0 || outgraph.length() == 0) {
    clopts.print_description();
    return EXIT_FAILURE;
  } 
  typedef graphlab::distributed_graph<graphlab::empty, graphlab::empty> graph_type;
  graph_type graph(dc, clopts);

  dc.cout() << "Loading graph in format: "<< ingraph << std::endl;
  graph.load_format(ingraph, informat);
  graph.finalize();

  dc.cout() << "#vertices: " << graph.num_vertices()
            << " #edges:" << graph.num_edges() << std::endl;

  graph.save_format(outgraph, outformat, gzip);

  graphlab::mpi_tools::finalize();
  return EXIT_SUCCESS;
} // End of main
コード例 #12
0
ファイル: unity_server.cpp プロジェクト: imjerrybao/SFrame
void unity_server::start(const unity_server_initializer& server_initializer) {

  // log files
  if (!options.log_file.empty()) {
    if (options.log_rotation_interval) {
      graphlab::begin_log_rotation(options.log_file,
                                   options.log_rotation_interval,
                                   options.log_rotation_truncate);
    } else {
      global_logger().set_log_file(options.log_file);
    }
  }

  graphlab::configure_global_environment(options.root_path);
  graphlab::global_startup::get_instance().perform_startup();

  // server address
  options.server_address = parse_server_address(options.server_address);

  // construct the server
  server = new cppipc::comm_server(std::vector<std::string>(), "", 
                                   options.server_address,
                                   options.control_address,
                                   options.publish_address,
                                   options.secret_key);

  set_log_progress(true);

  // initialize built-in data structures, toolkits and models, defined in unity_server_init.cpp
  server_initializer.init_toolkits(*toolkit_functions);
  server_initializer.init_models(*toolkit_classes);
  create_unity_global_singleton(toolkit_functions,
                                toolkit_classes,
                                server);
  auto unity_global_ptr = get_unity_global_singleton();
  server_initializer.register_base_classes(server, unity_global_ptr);

  // initialize extension modules and lambda workers
  server_initializer.init_extensions(options.root_path, unity_global_ptr);
  lambda::set_pylambda_worker_binary_from_environment_variables();

  // start the cppipc server
  server->start();
  logstream(LOG_EMPH) << "Unity server listening on: " <<  options.server_address << std::endl;
  logstream(LOG_EMPH) << "Total System Memory Detected: " << total_mem() << std::endl;
}
コード例 #13
0
ファイル: hdfs_test.cpp プロジェクト: hoytak/SFrame
int main(int argc, char **argv) {

    if (argc < 3) {
        std::cout << "Usage: " << argv[0] << " <hostname> <port> " << std::endl;
        std::cout << std::endl;
        std::cout << "Note: CLASSPATH and LD_LIBRARY_PATH should be set correctly." << std::endl;
        std::cout << "export LD_LIBRARY_PATH=/usr/lib/jvm/default-java/jre/lib/amd64/server:$LD_LIBRARY_PATH" << std::endl;
        std::cout << "From active graphlab virtualenv, run python gen-classpath.py (if not in debug dir then look in src/fileio)" << std::endl;
        exit(1);
    }

    std::string hostname = std::string(argv[1]);
    size_t port = atoi(argv[2]);

    {
        global_logger().set_log_level(LOG_INFO);
        graphlab::hdfs hdfs(hostname, port);
        const bool write = true;
        graphlab::hdfs::fstream file(hdfs, "/user/rajat/test.txt", write);
        file.good();
        file << "Hello World\n";
        file.close();
        std::vector<std::string> files = hdfs.list_files("/user/rajat/test.txt");
        for(size_t i = 0; i < files.size(); ++i) {
            std::cout << files[i] << std::endl;
        }
    }

    /*
      {
        graphlab::hdfs hdfs(hostname, port);
        graphlab::hdfs::fstream file(graphlab::hdfs::get_hdfs(), "/tmp/joeytest.txt");
        file.good();
        std::string answer;
        std::getline(file, answer);
        file.close();
        std::cout << "contents: " << std::endl;
        std::cout << answer << std::endl;
      }
    */
    std::cout << "Done!" << std::endl;
}
コード例 #14
0
int main(int argc, char** argv) {

  global_logger().set_log_level(LOG_INFO);
  ///! Initialize control plain using mpi
  graphlab::mpi_tools::init(argc, argv);
  graphlab::dc_init_param rpc_parameters;
  graphlab::init_param_from_mpi(rpc_parameters);
  graphlab::distributed_control dc(rpc_parameters);

  graphlab::command_line_options clopts("Test code.");
  clopts.set_scheduler_type("queued_fifo");
  std::cout << "Creating a powerlaw graph" << std::endl;
  graph_type graph(dc, clopts);
  graph.load_synthetic_powerlaw(100);

  test_in_neighbors(dc, clopts, graph);
  test_out_neighbors(dc, clopts, graph);
  test_all_neighbors(dc, clopts, graph);
  test_aggregator(dc, clopts, graph);
  graphlab::mpi_tools::finalize();
} // end of main
コード例 #15
0
ファイル: PageRank.cpp プロジェクト: pkuwalter/evaluation
int main(int argc, char** argv) {
    graphlab::mpi_tools::init(argc, argv);

    char *input_file = "hdfs://master:9000/pullgel/twitter";
    char *output_file = "hdfs://master:9000/exp/twitter";
    ROUND = 10;
    graphlab::distributed_control dc;
    global_logger().set_log_level(LOG_INFO);

    graphlab::timer t;
    t.start();
    graph_type graph(dc);
    graph.load(input_file, line_parser);
    graph.finalize();

    dc.cout() << "Loading graph in " << t.current_time() << " seconds" << std::endl;
    std::string exec_type = "synchronous";

    graphlab::omni_engine<pagerank> engine(dc, graph, exec_type);

    engine.signal_all();
    engine.start();

    dc.cout() << "Finished Running engine in " << engine.elapsed_seconds()
        << " seconds." << std::endl;

    const double total_rank = graph.map_reduce_vertices<double>(map_rank);
    std::cout << "Total rank: " << total_rank << std::endl;


    t.start();

    graph.save(output_file, pagerank_writer(), false, // set to true if each output file is to be gzipped
            true, // whether vertices are saved
            false); // whether edges are saved
    dc.cout() << "Dumping graph in " << t.current_time() << " seconds" << std::endl;

    graphlab::mpi_tools::finalize();
}
コード例 #16
0
ファイル: AsyncCC.cpp プロジェクト: ddmbr/pregelplus-code
int main(int argc, char** argv)
{
    graphlab::mpi_tools::init(argc, argv);

    char* input_file = "hdfs://master:9000/pullgel/friend";
    char* output_file = "hdfs://master:9000/exp/friend";
    std::string exec_type = "asynchronous";

    graphlab::distributed_control dc;
    global_logger().set_log_level(LOG_INFO);

    graphlab::timer t;
    t.start();
    graph_type graph(dc);
    graph.load(input_file, line_parser);
    graph.finalize();
    graph.transform_vertices(init_vertex);

    dc.cout() << "Loading graph in " << t.current_time() << " seconds"
              << std::endl;
    //std::string exec_type = "synchronous";
    graphlab::omni_engine<cc> engine(dc, graph, exec_type);

    engine.signal_all();
    engine.start();

    dc.cout() << "Finished Running engine in " << engine.elapsed_seconds()
              << " seconds." << std::endl;

    t.start();

    graph.save(output_file, cc_writer(), false, // set to true if each output file is to be gzipped
               true, // whether vertices are saved
               false); // whether edges are saved
    dc.cout() << "Dumping graph in " << t.current_time() << " seconds"
              << std::endl;

    graphlab::mpi_tools::finalize();
}
コード例 #17
0
ファイル: logger_factory.cpp プロジェクト: 01org/intelRSD
LoggerSPtr LoggerFactory::get_logger(const std::string& name, bool only_defined) const {
    if (name == GLOBAL_LOGGER_NAME) {
        return global_logger();
    }

    const auto it = m_loggers.find(name);
    if (it != m_loggers.cend()) {
        return it->second;
    }

    // logger isn't defined
    if (only_defined) {
        return nullptr;
    }

    const auto main_it = m_loggers.find(LoggerFactory::get_main_logger_name());
    if (main_it != m_loggers.cend()) {
        return main_it->second;
    }

    return LoggerFactory::global_logger();
}
コード例 #18
0
ファイル: assemblytree.cpp プロジェクト: tomcodes/appleseed
void AssemblyTree::build_assembly_tree()
{
    // Insert all assembly instances of the scene into the tree.
    for (const_each<AssemblyInstanceContainer> i = m_scene.assembly_instances(); i; ++i)
    {
        // Retrieve the assembly instance.
        const AssemblyInstance& assembly_instance = *i;

        // Retrieve the assembly.
        const Assembly& assembly = assembly_instance.get_assembly();

        // Skip empty assemblies.
        if (assembly.object_instances().empty())
            continue;

        // Insert the assembly instance into the root leaf.
        insert(
            assembly_instance.get_uid(),
            assembly_instance.compute_parent_bbox());
    }

    // Log a progress message.
    RENDERER_LOG_INFO(
        "building assembly bvh (%s %s)...",
        pretty_int(size()).c_str(),
        plural(size(), "assembly instance").c_str());

    // Build the assembly tree.
    AssemblyTreePartitioner partitioner;
    AssemblyTreeBuilder builder;
    builder.build(*this, partitioner);

    // Collect and print assembly tree statistics.
    AssemblyTreeStatistics tree_stats(*this, builder);
    RENDERER_LOG_DEBUG("assembly bvh statistics:");
    tree_stats.print(global_logger());
}
コード例 #19
0
log_level_setter::log_level_setter(int loglevel) {
  prev_level =  global_logger().get_log_level();
  global_logger().set_log_level(loglevel);
}
コード例 #20
0
// MAIN =======================================================================>
int main(int argc, char** argv) {
  std::cout << "This program creates and denoises a synthetic " << std::endl
            << "image using loopy belief propagation inside " << std::endl
            << "the graphlab framework." << std::endl;

  // set the global logger
  global_logger().set_log_level(LOG_WARNING);
  global_logger().set_log_to_console(true);


  double bound = 1E-4;
  double damping = 0.1;
  size_t colors = 5;
  size_t rows = 200;
  size_t cols = 200;
  double sigma = 2;
  double lambda = 2;
  std::string smoothing = "laplace";
  std::string orig_fn = "source_img.pgm";
  std::string noisy_fn = "noisy_img.pgm";
  std::string pred_fn = "pred_img.pgm";
  std::string pred_type = "map";




  // Parse command line arguments --------------------------------------------->
  graphlab::command_line_options clopts("Loopy BP image denoising");
  clopts.attach_option("bound",
                       &bound, bound,
                       "Residual termination bound");
  clopts.attach_option("damping",
                       &damping, damping,
                       "The amount of message damping (higher = more damping)");
  clopts.attach_option("colors",
                       &colors, colors,
                       "The number of colors in the noisy image");
  clopts.attach_option("rows",
                       &rows, rows,
                       "The number of rows in the noisy image");
  clopts.attach_option("cols",
                       &cols, cols,
                       "The number of columns in the noisy image");
  clopts.attach_option("sigma",
                       &sigma, sigma,
                       "Standard deviation of noise.");
  clopts.attach_option("lambda",
                       &lambda, lambda,
                       "Smoothness parameter (larger => smoother).");
  clopts.attach_option("smoothing",
                       &smoothing, smoothing,
                       "Options are {square, laplace}");
  clopts.attach_option("orig",
                       &orig_fn, orig_fn,
                       "Original image file name.");
  clopts.attach_option("noisy",
                       &noisy_fn, noisy_fn,
                       "Noisy image file name.");
  clopts.attach_option("pred",
                       &pred_fn, pred_fn,
                       "Predicted image file name.");
  clopts.attach_option("pred_type",
                       &pred_type, pred_type,
                       "Predicted image type {map, exp}");
  

  clopts.set_scheduler_type("splash(splash_size=100)");
  clopts.set_scope_type("edge");
  

  bool success = clopts.parse(argc, argv);
  if(!success) {    
    return EXIT_FAILURE;
  }


  
  std::cout << "ncpus:          " << clopts.get_ncpus() << std::endl
            << "bound:          " << bound << std::endl
            << "damping:        " << damping << std::endl
            << "colors:         " << colors << std::endl
            << "rows:           " << rows << std::endl
            << "cols:           " << cols << std::endl
            << "sigma:          " << sigma << std::endl
            << "lambda:         " << lambda << std::endl
            << "smoothing:      " << smoothing << std::endl
            << "engine:         " << clopts.get_engine_type() << std::endl
            << "scope:          " << clopts.get_scope_type() << std::endl
            << "scheduler:      " << clopts.get_scheduler_type() << std::endl
            << "orig_fn:        " << orig_fn << std::endl
            << "noisy_fn:       " << noisy_fn << std::endl
            << "pred_fn:        " << pred_fn << std::endl
            << "pred_type:      " << pred_type << std::endl;

  
  

  // Create synthetic images -------------------------------------------------->
  // Creating image for denoising
  std::cout << "Creating a synthetic image. " << std::endl;
  image img(rows, cols);
  img.paint_sunset(colors);
  std::cout << "Saving image. " << std::endl;
  img.save(orig_fn.c_str());
  std::cout << "Corrupting Image. " << std::endl;
  img.corrupt(sigma);
  std::cout << "Saving corrupted image. " << std::endl;
  img.save(noisy_fn.c_str());


 
  
  
  // Create the graph --------------------------------------------------------->
  gl_types::core core;
  // Set the engine options
  core.set_engine_options(clopts);
  
  std::cout << "Constructing pairwise Markov Random Field. " << std::endl;
  construct_graph(img, colors, sigma, core.graph());

  
  // Setup global shared variables -------------------------------------------->
  // Initialize the edge agreement factor 
  std::cout << "Initializing shared edge agreement factor. " << std::endl;

  // dummy variables 0 and 1 and num_rings by num_rings
  graphlab::binary_factor edge_potential(0, colors, 0, colors);
  // Set the smoothing type
  if(smoothing == "square") {
    edge_potential.set_as_agreement(lambda);
  } else if (smoothing == "laplace") {
    edge_potential.set_as_laplace(lambda);
  } else {
    std::cout << "Invalid smoothing stype!" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << edge_potential << std::endl;
  
  EDGE_FACTOR.set(edge_potential);
  BOUND.set(bound);
  DAMPING.set(damping);
  


  // Running the engine ------------------------------------------------------->
  core.sched_options().add_option("update_function",bp_update);

  std::cout << "Running the engine. " << std::endl;

  
  // Add the bp update to all vertices
  core.add_task_to_all(bp_update, 100.0);
  // Starte the engine
  double runtime = core.start();
  
  size_t update_count = core.last_update_count();
  std::cout << "Finished Running engine in " << runtime 
            << " seconds." << std::endl
            << "Total updates: " << update_count << std::endl
            << "Efficiency: " << (double(update_count) / runtime)
            << " updates per second "
            << std::endl;  


  // Saving the output -------------------------------------------------------->
  /*std::cout << "Rendering the cleaned image. " << std::endl;
  if(pred_type == "map") {
    for(size_t v = 0; v < core.graph().num_vertices(); ++v) {
      const vertex_data& vdata = core.graph().vertex_data(v);
      img.pixel(v) = vdata.belief.max_asg();    
    }
  } else if(pred_type == "exp") {
    for(size_t v = 0; v < core.graph().num_vertices(); ++v) {
      const vertex_data& vdata = core.graph().vertex_data(v);
      img.pixel(v) = vdata.belief.expectation();
    }
  } else {
    std::cout << "Invalid prediction type! : " << pred_type
              << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "Saving cleaned image. " << std::endl;
  img.save(pred_fn.c_str());
 */
  std::cout << "Done!" << std::endl;
  return EXIT_SUCCESS;
} // End of main
コード例 #21
0
ファイル: logger.cpp プロジェクト: jj4jj/adjust_reporter
void            logger_unlock(logger_t * logger){
    if (!logger){
        return global_logger()->lock.unlock();
    }
    return logger->lock.unlock();
}
コード例 #22
0
ファイル: pagerank.cpp プロジェクト: YosubShin/PowerGraph
int main(int argc, char** argv) {
  // Initialize control plain using mpi
//  graphlab::mpi_tools::init(argc, argv);
  graphlab::distributed_control dc;
  global_logger().set_log_level(LOG_INFO);

  // Parse command line options -----------------------------------------------
  graphlab::command_line_options clopts("PageRank algorithm.");
  std::string graph_dir;
  std::string format = "adj";
  std::string exec_type = "synchronous";
  clopts.attach_option("graph", graph_dir,
                       "The graph file.  If none is provided "
                       "then a toy graph will be created");
  clopts.add_positional("graph");
  clopts.attach_option("engine", exec_type,
                       "The engine type synchronous or asynchronous");
  clopts.attach_option("tol", TOLERANCE,
                       "The permissible change at convergence.");
  clopts.attach_option("format", format,
                       "The graph file format");
  size_t powerlaw = 0;
  clopts.attach_option("powerlaw", powerlaw,
                       "Generate a synthetic powerlaw out-degree graph. ");
  clopts.attach_option("iterations", ITERATIONS,
                       "If set, will force the use of the synchronous engine"
                       "overriding any engine option set by the --engine parameter. "
                       "Runs complete (non-dynamic) PageRank for a fixed "
                       "number of iterations. Also overrides the iterations "
                       "option in the engine");
  clopts.attach_option("use_delta", USE_DELTA_CACHE,
                       "Use the delta cache to reduce time in gather.");
  std::string saveprefix;
  clopts.attach_option("saveprefix", saveprefix,
                       "If set, will save the resultant pagerank to a "
                       "sequence of files with prefix saveprefix");

  if(!clopts.parse(argc, argv)) {
    dc.cout() << "Error in parsing command line arguments." << std::endl;
    return EXIT_FAILURE;
  }


  // Enable gather caching in the engine
  clopts.get_engine_args().set_option("use_cache", USE_DELTA_CACHE);

  if (ITERATIONS) {
    // make sure this is the synchronous engine
    dc.cout() << "--iterations set. Forcing Synchronous engine, and running "
              << "for " << ITERATIONS << " iterations." << std::endl;
    clopts.get_engine_args().set_option("type", "synchronous");
    clopts.get_engine_args().set_option("max_iterations", ITERATIONS);
    clopts.get_engine_args().set_option("sched_allv", true);
  }

  graphlab::timer timer;

  // Build the graph ----------------------------------------------------------
  graph_type graph(dc, clopts);
  if(powerlaw > 0) { // make a synthetic graph
    dc.cout() << "Loading synthetic Powerlaw graph." << std::endl;
    graph.load_synthetic_powerlaw(powerlaw, false, 2.1, 100000000);
  }
  else if (graph_dir.length() > 0) { // Load the graph from a file
    dc.cout() << "Loading graph in format: "<< format << std::endl;
    graph.load_format(graph_dir, format);
  }
  else {
    dc.cout() << "graph or powerlaw option must be specified" << std::endl;
    clopts.print_description();
    return 0;
  }

  double load_time = timer.current_time();
  timer.start();

  // must call finalize before querying the graph
  graph.finalize();

  double finalize_time = timer.current_time();
  double ingress_time = load_time + finalize_time;
  dc.cout() << "#vertices: " << graph.num_vertices()
            << " #edges:" << graph.num_edges() << std::endl;

  // Initialize the vertex data
  graph.transform_vertices(init_vertex);

  // Running The Engine -------------------------------------------------------
  graphlab::omni_engine<pagerank> engine(dc, graph, exec_type, clopts);
  engine.signal_all();
  timer.start();
  engine.start();
  const double runtime = timer.current_time();
  dc.cout() << "Finished Running engine in " << runtime
            << " seconds." << std::endl;


  const double total_rank = graph.map_reduce_vertices<double>(map_rank);
  std::cout << "Total rank: " << total_rank << std::endl;

  const double replication_factor = (double)graph.num_replicas()/graph.num_vertices();

  // Save the final graph -----------------------------------------------------
  if (saveprefix != "") {
    graph.save(saveprefix, pagerank_writer(),
               false,    // do not gzip
               true,     // save vertices
               false);   // do not save edges
  }

  double totalpr = graph.map_reduce_vertices<double>(pagerank_sum);
  std::cout << "Totalpr = " << totalpr << "\n";

  if (dc.procid() == 0) {
    const std::string output_filename = "/projects/sciteam/jsb/shin1/output.csv";
    std::ofstream ofs;
    ofs.open(output_filename.c_str(), std::ios::out | std::ios::app);
    if (!ofs.is_open()) {
      std::cout << "Failed to open output file.\n";
      return EXIT_FAILURE;
    }
    std::string ingress_method = "";
    clopts.get_graph_args().get_option("ingress", ingress_method);

    bool topology_aware = dc.topology_aware();

    double num_master2mirror_hops = (double) graph.num_master2mirror_hops() / graph.num_vertices();

    double average_local_own_nverts = graph.average_num_local_own_vertices();

    double variance_local_own_nverts = graph.variance_num_local_own_vertices();

    // algorithm,partitioning_strategy,num_iterations,replication_factor,load_time,finalize_time,ingress_time,computation_time,total_time,topology_aware,master2mirror_hops,average_local_own_nverts,variance_local_own_nverts
    ofs << "pagerank," << ingress_method << "," << ITERATIONS << "," << replication_factor << "," << load_time << "," << finalize_time << "," << ingress_time << "," << runtime << "," << (ingress_time + runtime) << "," << topology_aware << "," << num_master2mirror_hops<< "," << average_local_own_nverts<< "," << variance_local_own_nverts << std::endl;

    ofs.close();

    std::cout << "Topologies:\n";
    for (size_t i = 0; i < dc.topologies().size(); ++i) {
      std::cout << "procid: " << i << ": ";
      std::vector<int> coord = dc.topologies()[i];
      for (size_t j = 0; j < coord.size(); ++j) {
        std::cout << coord[j] << " ";
      }
      std::cout << std::endl;
    }
  }

  // Tear-down communication layer and quit -----------------------------------
//  graphlab::mpi_tools::finalize();
  return EXIT_SUCCESS;
} // End of main
コード例 #23
0
 inline static file_logger& exec(int lineloglevel,const char* file,const char* function, int line, bool do_start = true) {
   return global_logger().start_stream(lineloglevel, file, function, line, do_start);
 }
コード例 #24
0
ファイル: pagerank.cpp プロジェクト: xvz/giraphuc
int main(int argc, char** argv) {
  graphlab::timer total_timer; total_timer.start();

  // Initialize control plain using mpi
  graphlab::mpi_tools::init(argc, argv);
  graphlab::distributed_control dc;
  global_logger().set_log_level(LOG_INFO);

  // Parse command line options -----------------------------------------------
  graphlab::command_line_options clopts("PageRank algorithm.");
  std::string graph_dir;
  std::string format = "adj";
  std::string exec_type = "synchronous";
  clopts.attach_option("graph", graph_dir,
                       "The graph file.  If none is provided "
                       "then a toy graph will be created");
  clopts.add_positional("graph");
  clopts.attach_option("engine", exec_type,
                       "The engine type synchronous or asynchronous");
  clopts.attach_option("tol", TOLERANCE,
                       "The permissible change at convergence.");
  clopts.attach_option("format", format,
                       "The graph file format");
  size_t powerlaw = 0;
  clopts.attach_option("powerlaw", powerlaw,
                       "Generate a synthetic powerlaw out-degree graph. ");
  clopts.attach_option("iterations", ITERATIONS,
                       "If set, will force the use of the synchronous engine"
                       "overriding any engine option set by the --engine parameter. "
                       "Runs complete (non-dynamic) PageRank for a fixed "
                       "number of iterations. Also overrides the iterations "
                       "option in the engine");
  clopts.attach_option("use_delta", USE_DELTA_CACHE,
                       "Use the delta cache to reduce time in gather.");
  std::string saveprefix;
  clopts.attach_option("saveprefix", saveprefix,
                       "If set, will save the resultant pagerank to a "
                       "sequence of files with prefix saveprefix");

  if(!clopts.parse(argc, argv)) {
    dc.cout() << "Error in parsing command line arguments." << std::endl;
    return EXIT_FAILURE;
  }


  // Enable gather caching in the engine
  clopts.get_engine_args().set_option("use_cache", USE_DELTA_CACHE);

  if (ITERATIONS) {
    // make sure this is the synchronous engine
    dc.cout() << "--iterations set. Forcing Synchronous engine, and running "
              << "for " << ITERATIONS << " iterations." << std::endl;
    clopts.get_engine_args().set_option("type", "synchronous");
    clopts.get_engine_args().set_option("max_iterations", ITERATIONS);
    clopts.get_engine_args().set_option("sched_allv", true);
  }

  // Build the graph ----------------------------------------------------------
  graph_type graph(dc, clopts);
  if(powerlaw > 0) { // make a synthetic graph
    dc.cout() << "Loading synthetic Powerlaw graph." << std::endl;
    graph.load_synthetic_powerlaw(powerlaw, false, 2.1, 100000000);
  }
  else if (graph_dir.length() > 0) { // Load the graph from a file
    dc.cout() << "Loading graph in format: "<< format << std::endl;
    graph.load_format(graph_dir, format);
  }
  else {
    dc.cout() << "graph or powerlaw option must be specified" << std::endl;
    clopts.print_description();
    return 0;
  }
  // must call finalize before querying the graph
  graph.finalize();
  dc.cout() << "#vertices: " << graph.num_vertices()
            << " #edges:" << graph.num_edges() << std::endl;

  // Initialize the vertex data
  graph.transform_vertices(init_vertex);

  // Running The Engine -------------------------------------------------------
  graphlab::omni_engine<pagerank> engine(dc, graph, exec_type, clopts);
  engine.signal_all();
  engine.start();
  const double runtime = engine.elapsed_seconds();
  dc.cout() << "Finished Running engine in " << runtime
            << " seconds." << std::endl;


  const double total_rank = graph.map_reduce_vertices<double>(map_rank);
  std::cout << "Total rank: " << total_rank << std::endl;

  // Save the final graph -----------------------------------------------------
  if (saveprefix != "") {
    graph.save(saveprefix, pagerank_writer(),
               false,    // do not gzip
               true,     // save vertices
               false);   // do not save edges
  }

  // this interferes with TOTAL TIME print out
  //double totalpr = graph.map_reduce_vertices<double>(pagerank_sum);
  //std::cout << "Totalpr = " << totalpr << "\n";

  // Tear-down communication layer and quit -----------------------------------
  graphlab::mpi_tools::finalize();
  dc.cout() << "TOTAL TIME (sec): " << total_timer.current_time() << std::endl;
  return EXIT_SUCCESS;
} // End of main
コード例 #25
0
int main(int argc, char** argv) {
  global_logger().set_log_level(LOG_INFO);
  global_logger().set_log_to_console(true);
  ///! Initialize control plain using mpi
  graphlab::mpi_tools::init(argc, argv);
  graphlab::distributed_control dc;

  // Parse command line options -----------------------------------------------
  const std::string description = 
    "\n=========================================================================\n"
    "The fast Collapsed Variational Bayes Alg for the LDA model implements\n" 
    "a highly asynchronous version of parallel CVB0 in which document\n"
    "and word counts are maintained in an eventually consistent\n"
    "manner.\n"
    "\n"
    "The standard usage is: \n"
    "\t./fast_cvb0_lda --dictionary dictionary.txt --matrix doc_word_count.tsv\n"
    "where dictionary.txt contains: \n"
    "\taaa \n\taaai \n\tabalone \n\t   ... \n\n"
    "and doc_word_count.tsv is formatted <docid> <wordid> <count>:\n"
    "\t0\t0\t3\n"
    "\t0\t5\t1\n"
    "\t ...\n\n"
    "To learn more about the NLP package and its applications visit\n\n"
    "\t\t http://graphlab.org \n\n"
    "Additional Options";
  graphlab::command_line_options clopts(description);
  std::string matrix_dir; 
  std::string dictionary_fname;
  clopts.attach_option("dictionary", &dictionary_fname, dictionary_fname,
                       "The file containing the list of unique words");
  clopts.add_positional("dictionary");
  clopts.attach_option("matrix", &matrix_dir, matrix_dir,
                       "The directory or file containing the matrix data.");
  clopts.add_positional("matrix");
  clopts.attach_option("ntopics", &NTOPICS, NTOPICS,
                       "Number of topics to use.");
  clopts.attach_option("alpha", &ALPHA, ALPHA,
                       "The document hyper-prior");
  clopts.attach_option("beta", &BETA, BETA,                       
                       "The word hyper-prior");
  clopts.attach_option("topk", &TOPK, TOPK,
                       "The number of words to report");
  clopts.attach_option("interval", &INTERVAL, INTERVAL,
                       "statistics reporting interval");
  clopts.attach_option("max_count", &MAX_COUNT, MAX_COUNT,
                       "The maximum number of occurences of a word in a document.");
  if(!clopts.parse(argc, argv)) {
    graphlab::mpi_tools::finalize();
    return clopts.is_set("help")? EXIT_SUCCESS : EXIT_FAILURE;
  }

  if(dictionary_fname.empty()) {
    logstream(LOG_ERROR) << "No dictionary file was provided." << std::endl;
    return EXIT_FAILURE;
  }

  if(matrix_dir.empty()) {
    logstream(LOG_ERROR) << "No matrix file was provided." << std::endl;
    return EXIT_FAILURE;
  }

  ///! Initialize global variables
  GLOBAL_TOPIC_COUNT.resize(NTOPICS);
  bool success = load_dictionary(dictionary_fname); 
  if(!success) {
    logstream(LOG_ERROR) << "Error loading dictionary." << std::endl;
    return EXIT_FAILURE;
  }
  
  ///! load the graph
  graph_type graph(dc, clopts);  
  success = load_and_initialize_graph(dc, graph, matrix_dir);
  if(!success) {
    logstream(LOG_ERROR) << "Error loading graph." << std::endl;
    return EXIT_FAILURE;
  }


  
  engine_type engine(dc, graph, clopts, "asynchronous");
  ///! Add an aggregator
  success = 
    engine.add_vertex_aggregator<topk_type>
    ("topk", topk_type::map, topk_type::finalize) &&
    engine.aggregate_periodic("topk", INTERVAL);
  ASSERT_TRUE(success);
  success = 
    engine.add_vertex_aggregator<factor_type>
    ("global_counts", global_counts_agg::map, global_counts_agg::finalize) &&
    engine.aggregate_periodic("global_counts", 5);
  ASSERT_TRUE(success);


  ///! schedule only documents
  dc.cout() << "Running The Collapsed Gibbs Sampler" << std::endl;
  engine.map_reduce_vertices<graphlab::empty>(signal_only::docs);
  graphlab::timer timer;
  engine.start();  
  const double runtime = timer.current_time();
    dc.cout() 
    << "----------------------------------------------------------" << std::endl
    << "Final Runtime (seconds):   " << runtime 
    << std::endl
    << "Updates executed: " << engine.num_updates() << std::endl
    << "Update Rate (updates/second): " 
    << engine.num_updates() / runtime << std::endl;



  graphlab::mpi_tools::finalize();
  return EXIT_SUCCESS;


} // end of main
コード例 #26
0
log_level_setter::~log_level_setter() {
  global_logger().set_log_level(prev_level);
}
コード例 #27
0
ファイル: stitch_main.cpp プロジェクト: jerrylam/GraphLab
int main(int argc, char** argv) 
{
    
    ///////////////////////////////////////////////////////
    // Set up Graphlab
    global_logger().set_log_level(LOG_INFO);
    global_logger().set_log_to_console(true);

    ///! Initialize control plain using mpi
    graphlab::mpi_tools::init(argc, argv);
    graphlab::distributed_control dc;

    ///////////////////////////////////////////////////////
    // Set up OpenCV
    cv::setBreakOnError(true);

    ///////////////////////////////////////////////////////
    // Graphlab parse input
    const std::string description = "Image Stitching";
    graphlab::command_line_options clopts(description);

    string img_dir; 
    string graph_path;
    string output_dir = "stitch_output";

    clopts.attach_option("img", img_dir,
                         "The directory containing the images");
    clopts.add_positional("img");
    clopts.attach_option("graph", graph_path,
                         "The path to the adjacency list file (could be the prefix in case of multiple files)");
    clopts.add_positional("graph");
    clopts.attach_option("output", output_dir,
                         "The directory in which to save the output");
    clopts.attach_option("verbose", opts.verbose,
                         "Verbosity of Printing: 0 (default, no printing) or 1 (lots).");
    clopts.attach_option("work_megapix", opts.work_megapix,
                         "Resolution for image registration step. The default is 0.6 Mpx.");

    if(!clopts.parse(argc, argv)) 
    {
        graphlab::mpi_tools::finalize();
        return clopts.is_set("help")? EXIT_SUCCESS : EXIT_FAILURE;
    }
    
    if(img_dir.empty()) 
    {
        logstream(LOG_ERROR) << "No image directory was provided." << std::endl;
        return EXIT_FAILURE;
    }
    
    if(graph_path.empty()) 
    {
        logstream(LOG_ERROR) << "No adjacency file provided." << std::endl;
        return EXIT_FAILURE;
    }
    
    if (opts.work_megapix < 0 || opts.work_megapix > 0)
    {
        logstream(LOG_ERROR) << "Inappropriate value for work_megapix." << std::endl;
        return EXIT_FAILURE;
    }
    
    
    // display settings  
    dc.cout() 
    << "ncpus:          " << clopts.get_ncpus() << std::endl
    << "scheduler:      " << clopts.get_scheduler_type() << std::endl
    << "img_dir:        " << img_dir << std::endl
    << "graph_path:     " << graph_path << std::endl
    << "work_megapix:   " << opts.work_megapix << std::endl
    << "verbose:        " << opts.verbose << std::endl;
    

    
    ///////////////////////////////////////////////////////
    // Graphlab Graph
    graph_type graph(dc, clopts);
        
    // load the graph
    //graph.load(img_dir, vertex_loader);
    vertex_loader(dc, graph, img_dir);
    graph.load(graph_path, edge_loader);
    graph.finalize();
    
    ///////////////////////////////////////////////////////
    // Computer features in parallel
    graph.transform_vertices(compute_features);

    ///////////////////////////////////////////////////////
    // Match features in parallel
    graph.transform_edges(match_features);

    
    ///////////////////////////////////////////////////////
    // Graphlab Engine
    engine_type engine(dc, graph, clopts);

    
    ///////////////////////////////////////////////////////
    // Run everything
    engine.signal_all();
    graphlab::timer timer;
    engine.start();  
    const double runtime = timer.current_time();
    dc.cout() 
    << "----------------------------------------------------------" << std::endl
    << "Final Runtime (seconds):   " << runtime 
    << std::endl
    << "Updates executed: " << engine.num_updates() << std::endl
    << "Update Rate (updates/second): " 
    << engine.num_updates() / runtime << std::endl;
    
//    int retval = parseCmdArgs(argc, argv);
//    if (retval)
//        return retval;
//    
//    // Check if have enough images
//    int num_images = static_cast<int>(img_names.size());
//    if (num_images < 2)
//    {
//        LOGLN("Need more images");
//        return -1;
//    }
//    
//    double work_scale = 1, seam_scale = 1, compose_scale = 1;
//    bool is_work_scale_set = false, is_seam_scale_set = false, is_compose_scale_set = false;
    
//    LOGLN("Finding features...");
    
}
コード例 #28
0
ファイル: pylambda_worker.cpp プロジェクト: Fredfav/SFrame
/** The main function to be called from the python ctypes library to
 *  create a pylambda worker process.
 *
 *  Different error routes produce different error codes of 101 and
 *  above.
 */
int EXPORT pylambda_worker_main(const std::string& root_path,
                                const std::string& server_address, int loglevel) {

  /** Set up the debug configuration.
   *
   *  By default, all LOG_ERROR and LOG_FATAL messages are sent to
   *  stderr, and all messages above loglevel are sent to stdout.
   *
   *  If GRAPHLAB_LAMBDA_WORKER_LOG_FILE is set and is non-empty, then
   *  all log messages are sent to the file instead of the stdout and
   *  stderr.  In this case, the only errors logged to stderr/stdout
   *  concern opening the log file.
   *
   *  If GRAPHLAB_LAMBDA_WORKER_DEBUG_MODE is set, then the default
   *  log level is set to LOG_DEBUG.  If a log file is set, then all
   *  log messages are sent there, otherwise they are sent to stderr.
   */
  boost::optional<std::string> debug_mode_str = graphlab::getenv_str("GRAPHLAB_LAMBDA_WORKER_DEBUG_MODE");
  boost::optional<std::string> debug_mode_file_str = graphlab::getenv_str("GRAPHLAB_LAMBDA_WORKER_LOG_FILE");

  std::string log_file_string = debug_mode_file_str ? *debug_mode_file_str :  "";
  bool log_to_file = (!log_file_string.empty());

  bool debug_mode = (bool)(debug_mode_str);

  global_logger().set_log_level(loglevel);
  global_logger().set_log_to_console(true);

  // Logging using the LOG_DEBUG_WITH_PID macro requires this_pid to be set.
  size_t this_pid = get_my_pid();
  global_logger().set_pid(this_pid);

  // Set up the logging to file if needed.
  if(log_to_file) {
    // Set up the logging to the file, with any errors being fully logged.
    global_logger().set_log_to_console(true, true);
    global_logger().set_log_file(log_file_string);
    LOG_DEBUG_WITH_PID("Logging lambda worker logs to " << log_file_string);
    global_logger().set_log_to_console(false);
  }

  // Now, set the log mode for debug
  if(debug_mode) {
    global_logger().set_log_level(LOG_DEBUG);
    if(!log_to_file) {
      // Set logging to console, with everything logged to stderr.
      global_logger().set_log_to_console(true, true);
    }
  }

  // Log the basic information about parameters.
  size_t parent_pid = get_parent_pid();

  LOG_DEBUG_WITH_PID("root_path = '" << root_path << "'");
  LOG_DEBUG_WITH_PID("server_address = '" << server_address << "'");
  LOG_DEBUG_WITH_PID("parend pid = " << parent_pid);

  size_t _last_line = __LINE__;
#define __TRACK do { _last_line = __LINE__; } while(0)  
  try {

    LOG_DEBUG_WITH_PID("Library function entered successfully.");

    if(server_address == "debug") {
      logstream(LOG_INFO) << "Exiting dry run." << std::endl;
      return 1;
    }

    __TRACK; boost::optional<std::string> disable_shm = graphlab::getenv_str("GRAPHLAB_DISABLE_LAMBDA_SHM");
    bool use_shm = true;
    if(disable_shm && *disable_shm == "1") {
      use_shm = false;
      __TRACK; LOG_DEBUG_WITH_PID("shm disabled.");
    }

    __TRACK; graphlab::shmipc::server shm_comm_server;
    bool has_shm = false;
    
    try { 
      __TRACK; has_shm = use_shm ? shm_comm_server.bind() : false;
    } catch (const std::string& error) {
      logstream(LOG_ERROR) << "Internal PyLambda Error binding SHM server: "
                           << error << "; disabling SHM." << std::endl;
      has_shm = false;      
    } catch (const std::exception& error) {
      logstream(LOG_ERROR) << "Internal PyLambda Error binding SHM server: "
                           << error.what() << "; disabling SHM." << std::endl;
      has_shm = false;      
    } catch (...) {
      logstream(LOG_ERROR) << "Unknown internal PyLambda Error binding SHM server; disabling SHM."
                           << std::endl;
      has_shm = false;      
    }
    
    __TRACK; LOG_DEBUG_WITH_PID("shm_comm_server bind: has_shm=" << has_shm);

    // construct the server
    __TRACK; cppipc::comm_server server(std::vector<std::string>(), "", server_address);

    __TRACK; server.register_type<graphlab::lambda::lambda_evaluator_interface>([&](){
        if (has_shm) {
          __TRACK; auto n = new graphlab::lambda::pylambda_evaluator(&shm_comm_server);
          __TRACK; LOG_DEBUG_WITH_PID("creation of pylambda_evaluator with SHM complete.");
          __TRACK; return n;
        } else {
          __TRACK; auto n = new graphlab::lambda::pylambda_evaluator();
          __TRACK; LOG_DEBUG_WITH_PID("creation of pylambda_evaluator without SHM complete.");
          __TRACK; return n;
        }
      });
    
    __TRACK; server.register_type<graphlab::lambda::graph_lambda_evaluator_interface>([&](){
        __TRACK; auto n = new graphlab::lambda::graph_pylambda_evaluator();
        __TRACK; LOG_DEBUG_WITH_PID("creation of graph_pylambda_evaluator complete.");
        __TRACK; return n;
      });
    
    __TRACK; LOG_DEBUG_WITH_PID("Starting server.");
    __TRACK; server.start();

    __TRACK; wait_for_parent_exit(parent_pid);

    return 0;

    /** Any exceptions happening?  If so, propegate back what's going
     *  on through the error codes.
     */
  } catch (const std::string& error) {
    logstream(LOG_ERROR) << "Internal PyLambda Error: " << error
                         << "; last successful line =" << _last_line  << std::endl;
    return _last_line;
  } catch (const std::exception& error) {
    logstream(LOG_ERROR) << "PyLambda C++ Error: " << error.what()
                         << "; last successful line =" << _last_line << std::endl;
    return _last_line;
  } catch (...) {
    logstream(LOG_ERROR) << "Unknown PyLambda Error"
                         << "; last successful line =" << _last_line << std::endl;
    return _last_line;
  }
}
コード例 #29
0
ファイル: sssp.cpp プロジェクト: YosubShin/PowerGraph
int main(int argc, char** argv) {
    // Initialize control plain using mpi
    graphlab::mpi_tools::init(argc, argv);
    graphlab::distributed_control dc;
    global_logger().set_log_level(LOG_INFO);

    // Parse command line options -----------------------------------------------
    graphlab::command_line_options
    clopts("Single Source Shortest Path Algorithm.");
    std::string graph_dir;
    std::string format = "adj";
    std::string exec_type = "synchronous";
    size_t powerlaw = 0;
    std::vector<unsigned int> sources;
    bool max_degree_source = false;
    clopts.attach_option("graph", graph_dir,
                         "The graph file.  If none is provided "
                         "then a toy graph will be created");
    clopts.add_positional("graph");
    clopts.attach_option("format", format,
                         "graph format");
    clopts.attach_option("source", sources,
                         "The source vertices");
    clopts.attach_option("max_degree_source", max_degree_source,
                         "Add the vertex with maximum degree as a source");

    clopts.add_positional("source");

    clopts.attach_option("directed", DIRECTED_SSSP,
                         "Treat edges as directed.");

    clopts.attach_option("engine", exec_type,
                         "The engine type synchronous or asynchronous");


    clopts.attach_option("powerlaw", powerlaw,
                         "Generate a synthetic powerlaw out-degree graph. ");
    std::string saveprefix;
    clopts.attach_option("saveprefix", saveprefix,
                         "If set, will save the resultant pagerank to a "
                         "sequence of files with prefix saveprefix");

    if(!clopts.parse(argc, argv)) {
        dc.cout() << "Error in parsing command line arguments." << std::endl;
        return EXIT_FAILURE;
    }

    graphlab::timer load_timer;

    // Build the graph ----------------------------------------------------------
    graph_type graph(dc, clopts);
    if(powerlaw > 0) { // make a synthetic graph
        dc.cout() << "Loading synthetic Powerlaw graph." << std::endl;
        graph.load_synthetic_powerlaw(powerlaw, false, 2, 100000000);
    } else if (graph_dir.length() > 0) { // Load the graph from a file
        dc.cout() << "Loading graph in format: "<< format << std::endl;
        graph.load_format(graph_dir, format);
    } else {
        dc.cout() << "graph or powerlaw option must be specified" << std::endl;
        clopts.print_description();
        return EXIT_FAILURE;
    }
    // must call finalize before querying the graph
    graph.finalize();
    dc.cout() << "#vertices:  " << graph.num_vertices() << std::endl
              << "#edges:     " << graph.num_edges() << std::endl;

    double load_elapsed_secs = load_timer.current_time();
    std::cout << "Load: " << load_elapsed_secs << " seconds." << std::endl;

    if(sources.empty()) {
        if (max_degree_source == false) {
            dc.cout()
                    << "No source vertex provided. Adding vertex 0 as source"
                    << std::endl;
            sources.push_back(0);
        }
    }

    if (max_degree_source) {
        max_deg_vertex_reducer v = graph.map_reduce_vertices<max_deg_vertex_reducer>(find_max_deg_vertex);
        dc.cout()
                << "No source vertex provided.  Using highest degree vertex " << v.vid << " as source."
                << std::endl;
        sources.push_back(v.vid);
    }



    // Running The Engine -------------------------------------------------------
    graphlab::omni_engine<sssp> engine(dc, graph, exec_type, clopts);



    // Signal all the vertices in the source set
    for(size_t i = 0; i < sources.size(); ++i) {
        engine.signal(sources[i], min_distance_type(0));
    }

    engine.start();
    const float runtime = engine.elapsed_seconds();
    dc.cout() << "Finished Running engine in " << runtime
              << " seconds." << std::endl;


    // Save the final graph -----------------------------------------------------
    if (saveprefix != "") {
        graph.save(saveprefix, shortest_path_writer(),
                   false,    // do not gzip
                   true,     // save vertices
                   false);   // do not save edges
    }

    // Tear-down communication layer and quit -----------------------------------
    graphlab::mpi_tools::finalize();

    const std::string output_filename = "/home/yosub_shin_0/output.csv";
    std::ofstream ofs;
    ofs.open(output_filename.c_str(), std::ios::out | std::ios::app);
    if (!ofs.is_open()) {
        std::cout << "Failed to open output file.\n";
        return EXIT_FAILURE;
    }
    std::string ingress_method = "";
    clopts.get_graph_args().get_option("ingress", ingress_method);

    // algorithm, partitioning_strategy, num_iterations, loading_time, partitioning_time, computation_time, total_time
    ofs << "sssp," << ingress_method << "," << sources.size() << "," << load_elapsed_secs << ",0," << runtime << "," << (load_elapsed_secs + runtime) << std::endl;

    ofs.close();

    return EXIT_SUCCESS;
} // End of main
コード例 #30
0
void MaterialCollectionItem::slot_import_disney()
{
#ifdef APPLESEED_WITH_DISNEY_MATERIAL
    QString filepath =
        get_open_filename(
            0,
            "Import...",
            "Disney Material (*.dmt);;All Files (*.*)",
            m_editor_context.m_settings,
            SETTINGS_FILE_DIALOG_PROJECTS);

    if (!filepath.isEmpty())
    {
        filepath = QDir::toNativeSeparators(filepath);

        const bf::path root_path(Application::get_root_path());
        const bf::path schema_file_path = root_path / "schemas" / "settings.xsd";

        SettingsFileReader reader(global_logger());
        ParamArray parameters;
        const bool success =
            reader.read(
                filepath.toStdString().c_str(),
                schema_file_path.string().c_str(),
                parameters);

        if (!success)
        {
            show_error_message_box(
                "Importing Error",
                "Failed to import the Disney Material file " + filepath.toStdString());
            return;
        }

        string name = parameters.get("__name");
        const string model = parameters.get("__model");
        parameters.strings().remove("__name");
        parameters.strings().remove("__model");

        if (model != "disney_material")
        {
            show_error_message_box(
                "Importing Error",
                "Material model " + model + " is not supported.");
            return;
        }

        // If there is already a material with the same name, rename the imported material.
        for (const_each<MaterialContainer> i = m_parent.materials(); i; ++i)
        {
            if (strcmp(i->get_name(), name.c_str()) == 0)
            {
                name = make_unique_name(name, m_parent.materials());
                break;
            }
        }

        auto_release_ptr<Material> material =
            DisneyMaterialFactory().create(name.c_str(), parameters);
        Material* material_ptr = material.get();

        add_item(material_ptr);

        EntityTraits<Material>::insert_entity(material, m_parent);
        m_editor_context.m_project_builder.notify_project_modification();

        m_editor_context.m_project_explorer.select_entity(material_ptr->get_uid());
    }
#endif
}