int __system_property_add(const char *name, unsigned int namelen,
            const char *value, unsigned int valuelen)
{
    prop_area *pa = __system_property_area__;
    const prop_info *pi;

    if (namelen >= PROP_NAME_MAX)
        return -1;
    if (valuelen >= PROP_VALUE_MAX)
        return -1;
    if (namelen < 1)
        return -1;

    pi = find_property(root_node(), name, namelen, value, valuelen, true);
    if (!pi)
        return -1;

    // There is only a single mutator, but we want to make sure that
    // updates are visible to a reader waiting for the update.
    atomic_store_explicit(
        &pa->serial,
        atomic_load_explicit(&pa->serial, memory_order_relaxed) + 1,
        memory_order_release);
    __futex_wake(&pa->serial, INT32_MAX);
    return 0;
}
Exemple #2
0
int main(int argc, char** argv) {
    init_mpi(&argc, &argv);

    // disable log from caffe (disable glog entirely)
    FLAGS_minloglevel = 3;

    // Run tool or show usage.
    caffe::GlobalInit(&argc, &argv);

    int iters = FLAGS_iterations;
    string netdefs = FLAGS_model;
    Dtype lr = Dtype(FLAGS_lr);

    // at least iters in total
    // actuall number of workers is np - 1
    iters = (iters + np - 2) / (np - 1);

    if (pid == 0)
        iters *= (np - 1);

    auto net = init_net(netdefs);
    std::vector<Blob<Dtype>*> bottom_vec;

    // sync parameters
    broadcast_params(net);

    if (pid == 0)
        root_node(net, iters, lr);
    else
        worker_node(net, iters);

    return finish_mpi();
}
const prop_info *__system_property_find(const char *name)
{
    if (__predict_false(compat_mode)) {
        return __system_property_find_compat(name);
    }
    return find_property(root_node(), name, strlen(name), NULL, 0, false);
}
Exemple #4
0
static char *
gfs_refreshdir(void)
{
	char *e, *s;
	static int initialized = 0;
	struct timeval now, elapsed;

	if (!initialized) {
		if ((s = getenv("GFARM_DIRCACHE_TIMEOUT")) != NULL)
			gfarm_dircache_timeout.tv_sec = atoi(s);
		gfarm_dircache_timeout.tv_usec = 0;
		initialized = 1;
	}
	gettimeofday(&now, NULL);
	if (root == NULL) {
		e = root_node();
		if (e != NULL)
			return (e);
		return (gfs_cachedir(&now));
	}
	if (need_to_clear_cache)
		return (gfs_cachedir(&now));
	elapsed = now;
	gfarm_timeval_sub(&elapsed, &last_dircache);
	if (gfarm_timeval_cmp(&elapsed, &gfarm_dircache_timeout) >= 0)
		return (gfs_cachedir(&now));
	return (NULL);
}
Exemple #5
0
Ktree::Ktree() {

    ktree_node_counter = 0;
    
    KtreeNode root_node ('_', 0);
    ktree_node_list.push_back(root_node);

}
Exemple #6
0
/* here we mark that a DAO is needed soon */
void dag_network::maybe_send_dao(void)
{
    if(dao_needed && dag_bestparent != NULL) {
        if(!root_node()) {
            schedule_dao();
        }
        dao_needed = false;
    }
}
Exemple #7
0
///////////////////////////////////////////
//  child_rank(bp *b, i64 t)
//    returns d if t is the d-th child of the parent of t (d >= 1)
//            1 if t is the root
///////////////////////////////////////////
i64 child_rank(bp *b, i64 t)
{
    i64 r;
    if (t == root_node(b)) return 1;
    if (b->opt & OPT_DEGREE) {
        r = parent(b,t);
        return fast_degree(b,r,t,0)+1;
    } else {
        return naive_child_rank(b,t);
    }
}
    //--------------------------------------------------------------------------
    void
    WalkmeshFileXMLSerializer::importWalkmeshFile( Ogre::DataStreamPtr &stream
                                                  ,WalkmeshFile *pDest )
    {
        TiXmlDocument document;
        parse( stream, document );

        TiXmlNode *root_node( document.RootElement() );
        readHeader( root_node );
        TiXmlNode &node( *root_node );

        readVector( node, pDest->getTriangles(), "triangle" );
    }
//------------------------------------------------------------------------------
bool TreeModelWrapper::iter_nth_root_child_vfunc(int n, iterator& iter) const {
  // dprint("%s(n = %i), _tm->count() = %i   (as list=%i)\n", __FUNCTION__, n, _tm->count(), _show_as_list);
  bool ret = false;
  bec::NodeId root_node(_root_node_path);
  // Sets @a iter to be the child of at the root level using the given index.  The first
  // index is 0.  If @a n is too big, or if there are no children, @a iter is set
  // to an invalid iterator and false is returned.
  // See also iter_nth_child_vfunc().
  if (tm() && n >= 0 && n < (int)tm()->count_children(root_node)) {
    bec::NodeId node = tm()->get_child(root_node, n);
    init_gtktreeiter(iter.gobj(), node);
    ret = true;
    // dprint("%i = %s(n = %i, iter& -> '%s')\n", ret, __FUNCTION__, n, node.repr().c_str());
  }

  return ret;
}
int __system_property_add(const char *name, unsigned int namelen,
            const char *value, unsigned int valuelen)
{
    prop_area *pa = __system_property_area__;
    const prop_info *pi;

    if (namelen >= PROP_NAME_MAX)
        return -1;
    if (valuelen >= PROP_VALUE_MAX)
        return -1;
    if (namelen < 1)
        return -1;

    pi = find_property(root_node(), name, namelen, value, valuelen, true);
    if (!pi)
        return -1;

    pa->serial++;
    __futex_wake(&pa->serial, INT32_MAX);
    return 0;
}
bool prop_area::foreach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie) {
    return foreach_property(root_node(), propfn, cookie);
}
bool prop_area::add(const char *name, unsigned int namelen,
                    const char *value, unsigned int valuelen) {
    return find_property(root_node(), name, namelen, value, valuelen, true);
}
const prop_info *prop_area::find(const char *name) {
    return find_property(root_node(), name, strlen(name), nullptr, 0, false);
}
Exemple #14
0
T& root_node(treetree::tree<T>& tr) {
  treetree::subtree<T> sub(tr);
  return root_node(sub);
}