Пример #1
0
 /** The gather function computes XtX and Xy */
 gather_type gather(icontext_type& context, const vertex_type& vertex, 
                    edge_type& edge) const {
   if(edge.data().role == edge_data::TRAIN) {
     const vertex_type other_vertex = get_other_vertex(edge, vertex);
     return gather_type(other_vertex.data().factor, edge.data().obs);
   } else return gather_type();
 } // end of gather function
 gather_type gather(icontext_type& context, const vertex_type& vertex, edge_type& edge) const {
     if (context.iteration() == 0) {
         if (vertex.id() == edge.source().id()) {
             return gather_type(edge.target().id());
         } else {
             return gather_type(edge.source().id());
         }
     } else {
         return gather_type();
     }
 }
Пример #3
0
	binomial_operator(scatter_type scatter_ = scatter_type(),
					  gather_type gather_ = gather_type(),
					  selector_type selector_ = selector_type(),
					  function_type function_ = function_type()):
		scatter(scatter_),
		gather(gather_),
		selector(selector_),
		function(selector)
	{}
Пример #4
0
 void SynchronousEngine<algorithm_t>::executeApplys (){
     context_type context(*this, graph_);
     for (lvid_type vid = 0; vid < graph_.num_local_vertices(); vid++) {
         if (!active_superstep_[vid]) {
             continue;
         }
         auto &vprog = vertex_programs_[vid];
         vertex_type vertex(graph_.vertex(vid));
         const auto& accum = gather_accum_[vid];
         vprog.apply(context, vertex, accum);
         // clear gather accum array
         gather_accum_[vid] = gather_type();
     }
 }
Пример #5
0
      void graph_gather_apply<Graph,GatherType>::exec(const vertex_set& vset) {
        if (vset.lazy && !vset.is_complete_set)
          return;

        gather_accum.clear();
        // Allocate vertex locks and vertex programs
        vlocks.resize(graph.num_local_vertices());
        // Allocate gather accumulators and accumulator bitset
        gather_accum.resize(graph.num_local_vertices(), gather_type());
        has_gather_accum.resize(graph.num_local_vertices());
        has_gather_accum.clear();
        rmi.barrier();

        // Execute gather operations-------------------------------------------
        // Execute the gather operation for all vertices that are active
        // in this minor-step (active-minorstep bit set).
        // if (rmi.procid() == 0) std::cout << "Gathering..." << std::endl;
        run_synchronous(&graph_gather_apply::execute_gathers, vset);

        // Execute the gather operation for all vertices that are active
        // in this minor-step (active-minorstep bit set).
        // if (rmi.procid() == 0) std::cout << "Gathering..." << std::endl;
        run_synchronous(&graph_gather_apply::execute_scatters, vset);


        // Execute Apply Operations -------------------------------------------
        // Run the apply function on all active vertices
        // if (rmi.procid() == 0) std::cout << "Applying..." << std::endl;
        run_synchronous(&graph_gather_apply::execute_applys, vset);

        /**
         * Post conditions:
         *   1) any changes to the vertex data have been synchronized
         *      with all mirrors.
         *   2) all gather accumulators have been cleared
         */

        // Final barrier to ensure that all engines terminate at the same time
        rmi.full_barrier();
  } // end of start
Пример #6
0
    void SynchronousEngine<algorithm_t>::executeGathers (){
		// todo, how to get list of vertex ids to iterate?
		context_type context(*this, graph_);
		auto vetex_ids = graph_.vertex_ids;
		for(lvid_type vid : vetex_ids){
            if (!active_superstep_[vid]) {
                continue;
            }
            auto &vprog = vertex_programs_[vid];
            vertex_type vertex(graph_.vertex(vid));
            auto gather_dir = vprog.gather_edges(context, vertex);
            
            bool accum_is_set = false;
            gather_type accum = gather_type();
            if (gather_dir == IN_EDGES || gather_dir == ALL_EDGES){
                for(edge_type local_edge : vertex.in_edges()){
                    edge_type edge(local_edge);
                    if(accum_is_set) {
                        accum += vprog.gather(context, vertex, edge);
                    } else {
                        accum = vprog.gather(context, vertex, edge);
                        accum_is_set = true;
                    }
                }
            }
            
            if (gather_dir == OUT_EDGES || gather_dir == ALL_EDGES){
                for(edge_type local_edge : vertex.out_edges()){
                    edge_type edge(local_edge);
                    if(accum_is_set) {
                        accum += vprog.gather(context, vertex, edge);
                    } else {
                        accum = vprog.gather(context, vertex, edge);
                        accum_is_set = true;
                    }
                }
            }
            gather_accum_[vid] = accum;
		}
    }