Exemplo n.º 1
0
void RunFileFinder()
{
	PluginSys::Plugin * m_filefinder = (PluginSys::Plugin*)SINGLETON(MusicMng).GetFileFinder();
	m_filefinder->Run();

	SINGLETON(MusicMng).end_load_music_list();
}
Exemplo n.º 2
0
boolean findEOPD_impl(bitset currentEopdVertices, bitset currentEopdFaces, int eopdExtension, bitset remainingFaces, EDGE *lastExtendedEdge){
    //first check whether this is a covering eOPD
    if(IS_NOT_EMPTY(INTERSECTION(currentEopdFaces, remainingFaces))){
        printFaceTupleFaces(currentEopdFaces);
        return TRUE;
    }
    
    //otherwise try extending the eOPD
    EDGE *extension = lastExtendedEdge->next;
    
    if(INTERSECTION(currentEopdVertices, neighbourhood[extension->next->end]) ==
            extension->vertices){
            //face to the right of extension is addable
            if(findEOPD_impl(UNION(currentEopdVertices, faceSets[extension->rightface]),
                    UNION(currentEopdFaces, SINGLETON(extension->rightface)),
                    eopdExtension, remainingFaces, extension)){
                return TRUE;
            }
    }
    
    extension = lastExtendedEdge->inverse->prev->inverse;
    
    if(INTERSECTION(currentEopdVertices, neighbourhood[extension->next->end]) ==
            extension->vertices){
            //face to the right of extension is addable
            if(findEOPD_impl(UNION(currentEopdVertices, faceSets[extension->rightface]),
                    UNION(currentEopdFaces, SINGLETON(extension->rightface)),
                    eopdExtension, remainingFaces, extension)){
                return TRUE;
            }
    }
    
    return FALSE;
}
Exemplo n.º 3
0
void CNFMgr::doRenamingPosXor(const ASTNode& varphi)
{
    CNFInfo* x = info[varphi];

    //########################################
    // step 1, calc new variable
    //########################################

    ostringstream oss;
    oss << "cnf" << "{" << varphi.GetNodeNum() << "}";
    ASTNode psi = bm->CreateSymbol(oss.str().c_str(),0,0);

    //########################################
    // step 2, add defs
    //########################################

    //     ClauseList* cl1;
    //     cl1 = SINGLETON(bm->CreateNode(NOT, psi));
    //     ClauseList* cl2 = PRODUCT(*(info[varphi]->clausespos), *cl1);
    //     defs->insert(defs->end(), cl2->begin(), cl2->end());
    //     DELETE(info[varphi]->clausespos);
    //     DELETE(cl1);
    //     delete cl2;

    //########################################
    // step 3, update info[varphi]
    //########################################

    x->clausespos = SINGLETON(psi);
    x->clausesneg = SINGLETON(bm->CreateNode(NOT, psi));
    setWasRenamedPos(*x);
}//End of doRenamingPos
Exemplo n.º 4
0
extern "C" MAIN_API bool PLUGIN_INI_FUNC_DEFAAULT_NAME(PluginSys::Plugin * p)
{
	STRING name = p->name();
	name += L".cfg";
	Config config(name);

	STRING fl = config.Get(PLUGIN_CONTAINER_CONFIG_FILE_LIST_KEY);
	STRING nl = config.Get(PLUGIN_CONTAINER_CONFIG_NAME_LIST_KEY);
	g_pc = new PluginSys::PluginContainer(fl, nl);
	g_pc->AddFather(p);

	// load fps
	STRING fps = config.Get(PLUGIN_MAIN_FPS_CONFIG_NAME);
	u32 ufps = boost::lexical_cast<u32>(fps.c_str());
	SINGLETON(God).SetFps(ufps);

	// load filefinder
	STRING filefinder_filename = config.Get(PLUGIN_MAIN_FILEFINDER_FILENAME_CONFIG_NAME);
	STRING filefinder_name = config.Get(PLUGIN_MAIN_FILEFINDER_NAME_CONFIG_NAME);
	SINGLETON(God).SetPluginName(FILE_FINDER_PLUGIN_TYPE, filefinder_filename, filefinder_name);

	// load musicengine
	STRING musicengine_filename = config.Get(PLUGIN_MAIN_MUSICENGINE_FILENAME_CONFIG_NAME);
	STRING musicengine_name = config.Get(PLUGIN_MAIN_MUSICENGINE_NAME_CONFIG_NAME);
	SINGLETON(God).SetPluginName(MUSIC_ENGINE_PLUGIN_TYPE, musicengine_filename, musicengine_name);

	g_pc->Ini();

	g_Plugin = p;

	return true;
}
Exemplo n.º 5
0
Arquivo: eopd.c Projeto: nvcleemp/eopd
boolean findEOPD(bitset tuple){
    int i, j;
    //first we check the stored OPD's
    for(i = 0; i < eopdCount; i++){
        bitset intersectionOpd = INTERSECTION(tuple, opdFaces[i]);
        bitset intersectionExtensions = INTERSECTION(tuple, extensionFaces[i]);
        if((IS_NOT_EMPTY(intersectionOpd) && IS_NOT_EMPTY(intersectionExtensions)) ||
                (HAS_MORE_THAN_ONE_ELEMENT(intersectionOpd))){
            numberOfTuplesCoveredByStoredOpd++;
            return TRUE;
        }
    }
    
    //then we try to find a new eOPD
    for(i = 0; i < nf; i++){
        if(CONTAINS(tuple, i)){
            //try to find a eOPD with face i as extension
            bitset remainingFaces = MINUS(tuple, i);
            //we use each edge once as a possible shared edge 
            EDGE *sharedEdge = facestart[i];
            for(j = 0; j < 3; j++){
                //construct initial eopd
                int neighbouringFace = sharedEdge->inverse->rightface;
                bitset currentEopdVertices = faceSets[neighbouringFace];
                bitset currentEopdFaces = UNION(SINGLETON(i), SINGLETON(neighbouringFace));
                if(findEOPD_impl(currentEopdVertices, currentEopdFaces, i, remainingFaces, sharedEdge->inverse)){
                    return TRUE;
                }
                sharedEdge = sharedEdge->next->inverse;
            }
        }
    }
    return FALSE;
}
Exemplo n.º 6
0
Arquivo: eopd.c Projeto: nvcleemp/eopd
void constructInitialEopds(){
    int i;
    
    greedyExtendOpdAndStore(faceSets[0], SINGLETON(0));
    
    bitset coveredFaces = UNION(opdFaces[eopdCount-1], extensionFaces[eopdCount-1]);
    
    for(i = nf -1; i > 0; i--){
        if(!CONTAINS(coveredFaces, i)){
            greedyExtendOpdAndStore(faceSets[i], SINGLETON(i));
            ADD_ALL(coveredFaces, opdFaces[eopdCount-1]);
            ADD_ALL(coveredFaces, extensionFaces[eopdCount-1]);
        }
    }
}
Exemplo n.º 7
0
void UIMng::heartbeat(double elapsed)
{
	SINGLETON(UIScript).heartbeat(elapsed);

	zmq_heartbeat();
	CEGUI::System::getSingleton().injectTimePulse((float)elapsed);
}
Exemplo n.º 8
0
void CNFMgr::convertFormulaToCNFPosFALSE(const ASTNode& varphi,
        ClauseList* defs)
{
    ASTNode dummy_false_var =
        bm->CreateNode(NOT, dummy_true_var);
    info[varphi]->clausespos = SINGLETON(dummy_false_var);
} //End of convertFormulaToCNFPosFALSE()
Exemplo n.º 9
0
void CNFMgr::doRenamingNeg(const ASTNode& varphi, ClauseList* defs)
{
    CNFInfo* x = info[varphi];

    //########################################
    // step 2, calc new variable
    //########################################

    ostringstream oss;
    oss << "cnf" << "{" << varphi.GetNodeNum() << "}";
    ASTNode psi = bm->CreateSymbol(oss.str().c_str(),0,0);

    //########################################
    // step 3, add defs
    //########################################

    ASTNode* copy = ASTNodeToASTNodePtr(psi);
    ClauseList* cl = info[varphi]->clausesneg;
    cl->appendToAllClauses(copy);
    defs->insert(cl);
    delete cl;

    //########################################
    // step 4, update info[varphi]
    //########################################

    x->clausesneg = SINGLETON(bm->CreateNode(NOT, psi));
    setWasRenamedNeg(*x);
} //End of doRenamingNeg()
Exemplo n.º 10
0
 bool operator() ( const TypeSet::KeyType &key, const TypeSet::ValueType &val )
 {
     int type = SINGLETON( GI::PropertyTypeSet ).GetType( key );
     long lkey = (long) key;
     if( lkey > PEXTEND_BEGIN && lkey < PEXTEND_END &&
         IS_DYNAMIC(type) )
     {
         m_ps[&key] = &val;
     }
     return false;
 }
Exemplo n.º 11
0
GtUword gt_clustered_set_union_find_cluster_num(GtClusteredSet *cs,
                                                      GtUword e,
                                                      GT_UNUSED GtError *err
                                                      )
{
  gt_assert(cs);
  GtClusteredSetUF *cs_uf = (GtClusteredSetUF*) cs;
  if (SINGLETON(e))
    return CLUSTERNIL;
  else
    return cs_uf->cluster_elems[e].cluster_num;
}
Exemplo n.º 12
0
Arquivo: eopd.c Projeto: nvcleemp/eopd
boolean findUncoveredFaceTuple_impl(bitset tuple, bitset tupleVertices, int position, int size){
    if(size + (nf - position) < 4){
        //this tuple can't be completed to a 4-tuple
        return FALSE;
    }
    if(size < 3){
        //just extend and continue
        int i;
        for(i = position; i < nf - 3 + size; i++){
            if(IS_EMPTY(INTERSECTION(tupleVertices, faceSets[i]))){
                if(findUncoveredFaceTuple_impl(UNION(tuple, SINGLETON(i)),
                    UNION(tupleVertices, faceSets[i]), i+1, size+1)){
                    return TRUE;
                }
            }
        }
    } else if(size == 3){
        //search for eOPD and if none found: go to 4-tuple
        numberOfChecked3Tuples++;
        if(findEOPD(tuple)){
            return FALSE;
        }
        //no eOPD found: extending tuple
        int i;
        for(i = position; i < nf; i++){
            if(IS_EMPTY(INTERSECTION(tupleVertices, faceSets[i]))){
                if(findUncoveredFaceTuple_impl(UNION(tuple, SINGLETON(i)),
                    UNION(tupleVertices, faceSets[i]), i+1, size+1)){
                    return TRUE;
                }
            }
        }
    } else {// size == 4
        numberOfChecked4Tuples++;
        //search for eOPD
        return !findEOPD(tuple);
    }
    //if we get here then all tuples extending the current tuple were covered
    return FALSE;
}
Exemplo n.º 13
0
ASTNode* CNFMgr::doRenameITE(const ASTNode& varphi, ClauseList* defs)
{
    ASTNode psi;

    //########################################
    // step 1, old "RepLit" code
    //########################################

    ostringstream oss;
    oss << "cnf" << "{" << varphi.GetNodeNum() << "}";
    psi = bm->CreateSymbol(oss.str().c_str(),varphi.GetIndexWidth(),varphi.GetValueWidth());


    //########################################
    // step 3, recurse over children
    //########################################

    convertFormulaToCNF(varphi[0], defs);
    convertTermForCNF(varphi[1], defs);
    ASTNode t1 = *(info[varphi[1]]->termforcnf);
    convertTermForCNF(varphi[2], defs);
    ASTNode t2 = *(info[varphi[2]]->termforcnf);

    //########################################
    // step 4, add def clauses
    //########################################

    ClauseList* cl1 = SINGLETON(bm->CreateNode(EQ, psi, t1));
    ClauseList* cl2 = ClauseList::PRODUCT(*(info[varphi[0]]->clausesneg), *cl1);
    DELETE(cl1);
    defs->insert(cl2);

    ClauseList* cl3 = SINGLETON(bm->CreateNode(EQ, psi, t2));
    ClauseList* cl4 = ClauseList::PRODUCT(*(info[varphi[0]]->clausespos), *cl3);
    DELETE(cl3);
    defs->insert(cl4);

    return ASTNodeToASTNodePtr(psi);
}//End of doRenameITE()
Exemplo n.º 14
0
void MusicMng::start_load_music_list()
{
	LOG_ENTER;

	LOG_TRACE("start find thread");

	SINGLETON(God).SetStauts(God::GS_FIND);

	// 启动thread
	boost::thread fd(boost::bind(RunFileFinder));

	LOG_LEAVE;
}
Exemplo n.º 15
0
void UIMng::ini_cegui_system()
{
	LOG_ENTER;

	CEGUI::LuaScriptModule& scriptmod(CEGUI::LuaScriptModule::create());

	CEGUI::System::getSingleton().setScriptingModule(&scriptmod);

	SINGLETON(UIScript).ini();

	CEGUI::System::getSingleton().executeScriptFile("ini_cegui_system.lua");

	LOG_LEAVE;
}
Exemplo n.º 16
0
/*
 * Count the total number of nonzeros in factors L and U,  and in the 
 * symmetrically reduced L. 
 */
void
countnz(const int n, int *xprune, int *nnzL, int *nnzU, GlobalLU_t *Glu)
{
    register int nsuper, fsupc, i, j, nnzL0, jlen, irep;
    register int nnzsup = 0;
    register int *xsup, *xsup_end, *xlsub, *xlsub_end, *supno;
	
    xsup      = Glu->xsup;
    xsup_end  = Glu->xsup_end;
    xlsub     = Glu->xlsub;
    xlsub_end = Glu->xlsub_end;
    supno     = Glu->supno;
    *nnzU     = Glu->nextu;
    nnzL0     = 0;
    *nnzL     = 0;
    nsuper    = supno[n];

    if ( n <= 0 ) return;

    /* 
     * For each supernode ...
     */
    for (i = 0; i <= nsuper; i++) {
	fsupc = xsup[i];
	jlen = xlsub_end[fsupc] - xlsub[fsupc];
	nnzsup += jlen * (xsup_end[i] - fsupc);
			  
	for (j = fsupc; j < xsup_end[i]; j++) {
	    *nnzL += jlen;
	    *nnzU += j - fsupc + 1;
	    jlen--;
	}
	irep = SUPER_REP(i);
	if ( SINGLETON(supno[irep]) )
	    nnzL0 += xprune[irep] - xlsub_end[irep];
	else 
	    nnzL0 += xprune[irep] - xlsub[irep];
    }

#if ( PRNTlevel==1 )
    printf(".. # supernodes = %d\n", nsuper+1);
    printf(".. # edges in symm-reduced L = %d\n", nnzL0);
    if ( Glu->dynamic_snode_bound )
      printf(".. # NZ in LUSUP %d, dynamic bound %d, utilization %.2f\n",
	     nnzsup, Glu->nextlu, (float)nnzsup/Glu->nextlu);
    else
      printf(".. # NNZ in LUSUP %d, static bound %d, utilization %.2f\n",
	     nnzsup, Glu->nzlumax, (float)nnzsup/Glu->nzlumax);
#endif
}
Exemplo n.º 17
0
boolean findEOPD(bitset tuple){
    int i, j;
    
    for(i = 0; i < nf; i++){
        if(CONTAINS(tuple, i)){
            //try to find a eOPD with face i as extension
            bitset remainingFaces = MINUS(tuple, i);
            //we use each edge once as a possible shared edge 
            EDGE *sharedEdge = facestart[i];
            for(j = 0; j < 3; j++){
                //construct initial eopd
                int neighbouringFace = sharedEdge->inverse->rightface;
                bitset currentEopdVertices = faceSets[neighbouringFace];
                bitset currentEopdFaces = UNION(SINGLETON(i), SINGLETON(neighbouringFace));
                if(findEOPD_impl(currentEopdVertices, currentEopdFaces, i, remainingFaces, sharedEdge->inverse)){
                    return TRUE;
                }
                sharedEdge = sharedEdge->next->inverse;
            }
        }
    }
    return FALSE;
}
Exemplo n.º 18
0
void CNFMgr::convertFormulaToCNFPosPred(const ASTNode& varphi,
                                        ClauseList* defs)
{
    ASTVec psis;

    ASTVec::const_iterator it = varphi.GetChildren().begin();
    for (; it != varphi.GetChildren().end(); it++)
    {
        convertTermForCNF(*it, defs);
        psis.push_back(*(info[*it]->termforcnf));
    }

    info[varphi]->clausespos =
        SINGLETON(bm->CreateNode(varphi.GetKind(), psis));
} //End of convertFormulaToCNFPosPred()
Exemplo n.º 19
0
void seg_allocator::discard()
{
    _last_succ = 0;
    IFGUARD(_pgcreatemutex);
    page* p = _last;
    _last = 0;
    for( ; p; )
    {
        p->spage->~ssegpage();
        operator delete (p->spage);
        
        page* pp = p;
        p = p->prev;
        SINGLETON( chunk_allocator<page> ).free(pp);
    }

    _nseg = 0;
}
Exemplo n.º 20
0
void UIMng::zmq_heartbeat()
{
	void * zmq_socket = SINGLETON(God).GetZeromqSocket();

	zmq_msg_t zmsg;
	zmq_msg_init(&zmsg);
	s32 rc;
	ui::uimsg msg;
	while(1)
	{
		rc = zmq_recv(zmq_socket, &zmsg, ZMQ_NOBLOCK);
		if (rc < 0) 
		{
			break;
		}
		msg.ParseFromArray(zmq_msg_data(&zmsg), zmq_msg_size(&zmsg));
		handle_zmq_msg(msg);
	}
	zmq_msg_close(&zmsg);
}
Exemplo n.º 21
0
void MusicMng::load_file_finder()
{
	LOG_ENTER;

	STRING filename, name;
	SINGLETON(God).GetPluginName(FILE_FINDER_PLUGIN_TYPE, filename, name);

	PluginSys::Plugin * filefinder = new PluginSys::Plugin(filename, name);

	if (!filefinder->IsOK())
	{
		LOG_ERROR("m_filefinder Is not OK");
		SAFE_DELETE(filefinder);
	}

	filefinder->Ini();

	m_filefinder = filefinder;

	LOG_LEAVE;
}
Exemplo n.º 22
0
void MusicMng::ini_music_engine()
{
	LOG_ENTER;

	STRING filename, name;
	SINGLETON(God).GetPluginName(MUSIC_ENGINE_PLUGIN_TYPE, filename, name);

	PluginSys::Plugin * musicengine = new PluginSys::Plugin(filename, name);

	if (!musicengine->IsOK())
	{
		LOG_ERROR("m_musicengine Is not OK");
		SAFE_DELETE(musicengine);
	}

	musicengine->Ini();

	m_musicengine = musicengine;

	LOG_LEAVE;
}
Exemplo n.º 23
0
ClauseList* CNFMgr::convertToCNF(const ASTNode& varphi)
{
    bm->GetRunTimes()->start(RunTimes::CNFConversion);
    scanFormula(varphi, true, false);
    ClauseList* defs = SINGLETON(dummy_true_var);
    convertFormulaToCNF(varphi, defs);
    ClauseList* top = info[varphi]->clausespos;
    defs->insertAtFront(top);

    cleanup(varphi);
    bm->GetRunTimes()->stop(RunTimes::CNFConversion);
    if (bm->UserFlags.stats_flag)
    {
        cerr << "\nPrinting: After CNF conversion: " << endl;
        cerr << "Number of clauses:" << defs->size() << endl;
//         PrintClauseList(cout, *defs);
        cerr << "Number of xor-clauses:" << clausesxor->size() << endl;
//         PrintClauseList(cout, *clausesxor);
    }

    return defs;
}//End of convertToCNF()
Exemplo n.º 24
0
Arquivo: eopd.c Projeto: nvcleemp/eopd
boolean findUncoveredFaceTuple(){
    //reset counter for eOPD's
    eopdCount = 0;
    
    //start by constructing some eOPD's to exclude many tuples
    constructInitialEopds();
    
    boolean result = FALSE;
    int i;
    for(i = 0; i < nf - 3; i++){
        result = findUncoveredFaceTuple_impl(SINGLETON(i), faceSets[i], i + 1, 1);
        if(result){
            break;
        }
    }
    
    if(eopdCount > maximumOpdCount){
        maximumOpdCount = eopdCount;
    }

    return result;
}
Exemplo n.º 25
0
opcd seg_allocator::load( binstream& bin, void* dynarray_ald )
{
    opcd e;
    discard();

    dynarray<load_data>& ald = *(dynarray<load_data>*)dynarray_ald;
    
    bin >> _segsize;
    
    page* p=0;
    for( ; ; )
    {
        page* n = SINGLETON( chunk_allocator<page> ).alloc();
        n->prev = p;
        n->spage = ssegpage::create( _pgcreatemutex.is_set(), _segsize );

        _last = n;
        if(!n->spage)  return ersNOT_ENOUGH_MEM "cannot create ssegpage";

        ++_nseg;

        void* base;
        int diff;

        e = n->spage->read_from_stream( bin, &base, &diff );
        if( e == ersMISMATCHED )  return e;
        else if(e)  break;

        load_data* pld = ald.add();
        pld->base = base;
        pld->diff = diff;
    }

    std::sort( ald.begin(), ald.end() );

    return 0;
}
Exemplo n.º 26
0
GtClusteredSetIterator*
gt_clustered_set_union_find_iterator_new(GtClusteredSet *cs,
                                         GtUword c,
                                         GT_UNUSED GtError *err)
{
  gt_assert(cs);
  GtClusteredSetUF *cs_uf = (GtClusteredSetUF*) cs;
  GtClusteredSetIterator *cs_i = gt_calloc(1, sizeof (GtClusteredSetIterator));
  GtUword i = 0, j = 0;
  if (SINGLETON(c)) {
    cs_i->length = (GtUword) 1;
    cs_i->curpos = (GtUword) 0;
    cs_i->elems = gt_calloc(1, sizeof (GtUword));
    cs_i->elems[j] = c;
  }
  else {
    if (CINFO(c)->cluster_size > 0) {
      GtClusteredSetUFClusterInfo *cluster_info;
      cluster_info = CINFO(c);
      cs_i->length = cluster_info->cluster_size;
      cs_i->curpos = (GtUword) 0;
      cs_i->elems = gt_calloc(cluster_info->cluster_size,
                              sizeof (GtUword));
      i = cluster_info->first_elem;

      do {
        cs_i->elems[j] = i;
        j++;
      } while ((i = cs_uf->cluster_elems[i].next_elem) < cs_uf->num_of_elems);

    } else {
      gt_free(cs_i);
      return NULL;
    }
  }
  return cs_i;
}
Exemplo n.º 27
0
void UIMng::create_cegui_system()
{
	LOG_ENTER;

	void * pD3DDevice = SINGLETON(Render).GetDevice();

	// 创建cegui
	CEGUI::Direct3D9Renderer& renderer(CEGUI::Direct3D9Renderer::create((LPDIRECT3DDEVICE9)pD3DDevice));
	LOG_TRACE("Create Direct3D9Renderer ok");

	CEGUI::DefaultResourceProvider* rp = new CEGUI::DefaultResourceProvider();
	CEGUI::System::create(renderer, rp);
	LOG_TRACE("Create System ok");

	// 设置资源
	rp->setResourceGroupDirectory("schemes", "ui/schemes/");
	rp->setResourceGroupDirectory("imagesets", "ui/imagesets/");
	rp->setResourceGroupDirectory("fonts", "ui/fonts/");
	rp->setResourceGroupDirectory("layouts", "ui/layouts/");
	rp->setResourceGroupDirectory("looknfeels", "ui/looknfeel/");
	rp->setResourceGroupDirectory("lua_scripts", "ui/lua_scripts/");
	rp->setResourceGroupDirectory("schemas", "ui/xml_schemas/");   
	rp->setResourceGroupDirectory("animations", "ui/animations/"); 

	CEGUI::Imageset::setDefaultResourceGroup("imagesets");
	CEGUI::Font::setDefaultResourceGroup("fonts");
	CEGUI::Scheme::setDefaultResourceGroup("schemes");
	CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
	CEGUI::WindowManager::setDefaultResourceGroup("layouts");
	CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
	CEGUI::AnimationManager::setDefaultResourceGroup("animations");
	LOG_TRACE("setDefaultResourceGroup ok");

	CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

	LOG_LEAVE;
}
Exemplo n.º 28
0
seg_allocator::HEADER* seg_allocator::alloc( uints count, uints chunk )
{
    uints size = count*chunk + REDHDRSIZE;
    if( size >= _segsize/2 )
    {
        HEADER* hdr;
        hdr = (HEADER*) ssegpage::alloc_big(size);
        if(!hdr)
            throw ersEXCEPTION "not enough memory";

        hdr->_count = count;
        //hdr->_size = size - sizeof(HEADER);
        return hdr;
    }
    else
    {
//        COMM_SEGPAGE_LOCK;

        if(!_last_succ)
            _last_succ = _last;
        page* pc = _last_succ;
        if(pc)
        {
            //fast find in unlocked ssegpage
            for( page* pf = pc; ; )
            {
#ifdef _DEBUG
                long turn_on_to_check = 0;
                if( turn_on_to_check )
                {
                    ssegpage::SEGLOCK glck(*pc->spage);
                    pc->spage->check_state();
                }
#endif

                bool tst = false;

                {
                    uints avsize;
                    ssegpage::SEGLOCK glck( *pc->spage, true, &avsize );

                    if( glck.locked()  &&  avsize >= size )
                    {
                        tst = true;

                        HEADER* hdr = (HEADER*) pc->spage->alloc(size);
                        if(hdr)
                        {
                            hdr->_count = count;

                            //expecting atomic write
                            _last_succ = pc;

                            //CLAIM( _pages[i]->check_state(), 0 );
                            return hdr;
                        }
                    }
                }

                pc = pc->prev;
                if(!pc)  pc = _last;
                if( pc == pf )
                    break;
            }
        }

        page* pn = SINGLETON( chunk_allocator<page> ).alloc();
        pn->spage = ssegpage::create( _pgcreatemutex.is_set(), _segsize );

        // allocate the memory
        HEADER* hdr;
        hdr = (HEADER*) pn->spage->alloc(size);
        if(!hdr)
            throw ersEXCEPTION "not enough memory";

        hdr->_count = count;

        {
            IFGUARD(_pgcreatemutex);
            ++_nseg;

            pn->prev = _last;
            _last = pn;
            _last_succ = pn;
        }

        return hdr;
    }
}
Exemplo n.º 29
0
int gt_clustered_set_union_find_merge_clusters(GtClusteredSet *cs,
                                               GtUword e1,
                                               GtUword e2,
                                               GtError *err)
{
  gt_assert(cs);
  int had_err = 0;
  GtClusteredSetUFClusterInfo *cluster_info_c1 = NULL;
  GtClusteredSetUFClusterInfo *cluster_info_c2 = NULL;
  GtUword target = 0, source = 0, c1 = 0, c2 = 0;
  GtClusteredSetUF *cs_uf = (GtClusteredSetUF*) cs;
  if (e1 == e2) {
    gt_error_set(err, "expected "GT_WU" to be unequal "GT_WU"", e1, e2 );
    had_err = -1;
  }

  if (e1 >= cs_uf->num_of_elems || e2 >= cs_uf->num_of_elems) {
    gt_error_set(err, ""GT_WU" and "GT_WU" must not be larger than "GT_WU"",
                 e1, e2, cs_uf->num_of_elems);
    had_err = -1;
  }

  if (!had_err) {
    if (SINGLETON(e1)) {
       /* printf(""GT_WU" is singleton\n", e1); */
      if (SINGLETON(e2)) {
        /* printf(""GT_WU" is singleton\n", e2);*/
        gt_clustered_set_union_find_make_new_cluster(cs_uf, e1, e2, err);
        gt_bittab_set_bit(cs_uf->in_cluster, e2);
      }
      else {
        c2 = cs_uf->cluster_elems[e2].cluster_num;
        CHECKCLUSTER(c2);
        gt_clustered_set_union_find_append_elem(cs_uf, c2, e1, err);
      }
      gt_bittab_set_bit(cs_uf->in_cluster, e1);
    }
    else {
      c1 = cs_uf->cluster_elems[e1].cluster_num;
      CHECKCLUSTER(c1);
      if (SINGLETON(e2)) {
        gt_clustered_set_union_find_append_elem(cs_uf, c1, e2, err);
        gt_bittab_set_bit(cs_uf->in_cluster, e2);
      }
      else {
        c2 = cs_uf->cluster_elems[e2].cluster_num;
        CHECKCLUSTER(c2);
        cluster_info_c1 = CINFO(c1);
        cluster_info_c2 = CINFO(c2);
        if (cluster_info_c1->cluster_size > cluster_info_c2->cluster_size) {
          target = c1;
          source = c2;
        }
        else {
          target = c1;
          source = c2;
        }
        if (target != source)
          gt_clustered_set_union_find_join_clusters(cs_uf, target, source, err);
      }
    }
  }
  return had_err;
}
Exemplo n.º 30
0
void
pxgstrf_super_bnd_dfs(
		      const int  pnum, /* process number */
		      const int  m,    /* number of rows in the matrix */
		      const int  n,    /* number of columns in the matrix */
		      const int  jcol, /* first column of the H-supernode */
		      const int  w,    /* size of the H-supernode */
		      SuperMatrix *A,  /* original matrix */
		      int        *perm_r,   /* in */
		      int        *iperm_r,  /* in; inverse of perm_r */
		      int        *xprune,   /* in */
		      int        *ispruned, /* in */
		      int        *marker,   /* modified */
		      int        *parent,   /* working array */
		      int        *xplore,   /* working array */
		      pxgstrf_shared_t *pxgstrf_shared /* modified */	      
		      )
{
/*
 * -- SuperLU MT routine (version 1.0) --
 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
 * and Lawrence Berkeley National Lab.
 * August 15, 1997
 *
 * Purpose
 * =======
 *
 * Performs a symbolic structure prediction on a supernode in the Householder
 * matrix H, with jcol being the leading column.
 *
 */
    GlobalLU_t *Glu = pxgstrf_shared->Glu; /* modified */	      
    register int krep, chperm, chrep, kchild;
    register int invp_rep; /* "krep" numbered in the original A */
    register int krow, kperm, xdfs, maxdfs, kpar;
    register int fsupc, k, jj, found;
    register int nrow;  /* union of the nonzero rows in a supernode */
    NCPformat    *Astore;
    int          *asub, *xa_begin, *xa_end;
    int          *xsup, *xsup_end, *supno, *lsub, *xlsub, *xlsub_end;

    /* Initialize pointers */
    xsup       = Glu->xsup;
    xsup_end   = Glu->xsup_end;
    supno      = Glu->supno;
    lsub       = Glu->lsub;
    xlsub      = Glu->xlsub;
    xlsub_end  = Glu->xlsub_end;
    Astore   = A->Store;
    asub     = Astore->rowind;
    xa_begin = Astore->colbeg;
    xa_end   = Astore->colend;
    nrow = 0;
    found = n + jcol;

    /* For each column in the H-supernode */
    for (jj = jcol; jj < jcol + w; ++jj) {

      /* For each nonz in A[*,jj] do dfs */
      for (k = xa_begin[jj]; k < xa_end[jj]; ++k) {
	  krow = asub[k];
	  
	  /* krow was visited before, go to the next nonzero. */
	  if ( marker[krow] == found ) continue;
	  
  	  /* For each unmarked nbr krow of jj ...   */
	  kperm = perm_r[krow];
	  
	  if ( kperm == EMPTY ) { /* krow is in L */
	      marker[krow] = found;
	      ++nrow;
	  } else {
	      /* krow is in U: if its supernode-rep krep has been explored,
		               skip the search.       */
	      krep = SUPER_REP( supno[kperm] );
	      invp_rep = iperm_r[krep];
		  
	      /* Perform dfs starting at krep */
              if ( marker[invp_rep] != found ) {
		  marker[invp_rep] = found;
		  parent[krep] = EMPTY;
		  if ( ispruned[krep] ) {
		      if ( SINGLETON( supno[krep] ) )
			  xdfs = xlsub_end[krep];
		      else xdfs = xlsub[krep];
		      maxdfs = xprune[krep];
		  } else {
		      fsupc = SUPER_FSUPC( supno[krep] );
		      xdfs = xlsub[fsupc] + krep-fsupc+1;
		      maxdfs = xlsub_end[fsupc];
		  }

		  do {
		      /* For each unmarked kchild of krep ... */
		      while ( xdfs < maxdfs ) {
			  kchild = lsub[xdfs];
			  xdfs++;
			  if (marker[kchild] != found) { /* Not reached yet */
			      chperm = perm_r[kchild];
			      
			      if ( chperm == EMPTY ) { /* kchild is in L */
				  marker[kchild] = found;
				  ++nrow;
			      } else {
				  /* kchild is in U: 
				   *   chrep = its supernode-rep. If its rep
				   *   has been explored, skip the search.
				   */
				  chrep = SUPER_REP( supno[chperm] );
				  invp_rep = iperm_r[chrep];
				  
				  /* Continue dfs at snode-rep of kchild */
				  if ( marker[invp_rep] != found ) {
				      marker[invp_rep] = found;
				      xplore[krep] = xdfs;
				      xplore[m + krep] = maxdfs;
				      parent[chrep] = krep;
				      krep = chrep;/* Go deeper down G(L^t) */
				      xdfs = xlsub[krep];     
				      maxdfs = xprune[krep];
				      if ( ispruned[krep] ) {
					  if ( SINGLETON( supno[krep] ) )
					      xdfs = xlsub_end[krep];
					  else xdfs = xlsub[krep];
					  maxdfs = xprune[krep];
				      } else {
					  fsupc = SUPER_FSUPC(supno[krep]);
					  xdfs = xlsub[fsupc] + krep-fsupc+1;
					  maxdfs = xlsub_end[fsupc];
				      }
				  } /* if */
			      } /* else */
			  } /* if... */
		      } /* while xdfs < maxdfs */
		      
		      /* krow has no more unexplored nbrs:
		       *    Place snode-rep krep in postorder dfs, if this 
		       *    segment is seen for the first time. Note that
		       *    the "repfnz[krep]" may change later.
		       *    Backtrack dfs to its parent.
		       */
		      kpar = parent[krep]; /* Pop stack, mimic recursion */
		      if ( kpar == EMPTY ) break; /* dfs done */
		      krep = kpar;
		      xdfs = xplore[krep];
		      maxdfs = xplore[m+krep];
		  } while ( kpar != EMPTY ); /* do-while - until empty stack */
	      } /* if */
	  } /* else */
      } /* for each nonz in A[*,jj] */
    } /* for jj ... */

    DynamicSetMap(pnum, jcol, nrow * w, pxgstrf_shared);
    
/*    for (i = 1; i < w; ++i) Glu->map_in_sup[jcol + i] = -i;*/
    
#if ( DEBUGlevel>=1 )
    printf("(%d) pxgstrf_super_bnd_dfs(): jcol= %d, w= %d, nrow= %d\n",
	   pnum, jcol, w, nrow);
#endif
}