Exemplo n.º 1
0
void Port::acquireInputBuffer (BufferProvider &provider, nframes_t len)
{
  int numConnections = dependencies().count();
  switch (numConnections) {
    case 0:
      if (type() == AudioPort) {
        // Use silence
        m_buffer = provider.zeroAudioBuffer();
        return;
      }
      break;
    case 1:
    {
      // Use the other port's buffer
      // type should match due to validation on connect
      Port *other = static_cast<Port *>( *(dependencies().begin()) );
      m_buffer = other->buffer();
      break;
    }
    default:
      qFatal("Internal mixing is not yet supported");
      return;
  }

  if (!m_buffer) {
    // Return internal port
    m_buffer = provider.acquire(type(), len);
    updateBufferValue();
  }
}
Exemplo n.º 2
0
void MapListExtractInner::takeControl( )
{
  if (freeARCs() > 0){
    if (arcer.takeControl()){
      SMList<Map>* smo = 
	new  SMList<Map>(theList.getGroup(),
			      arcer.getData(),
			      Text("Inner automorphisms from ") + Name(theList)
			      ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "RandomAutomorphisms",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();	
      
      adminTerminate();
      return;
    }
    else
      usedOneARC();
  }
}
TEST_F(DocumentSourceMatchTest, TextSearchShouldRequireWholeDocumentAndTextScore) {
    auto match = DocumentSourceMatch::create(fromjson("{$text: {$search: 'hello'} }"), getExpCtx());
    DepsTracker dependencies(DepsTracker::MetadataAvailable::kTextScore);
    ASSERT_EQUALS(DepsTracker::State::EXHAUSTIVE_FIELDS, match->getDependencies(&dependencies));
    ASSERT_EQUALS(true, dependencies.needWholeDocument);
    ASSERT_EQUALS(true, dependencies.getNeedsMetadata(DepsTracker::MetadataType::TEXT_SCORE));
}
Exemplo n.º 4
0
void SMListExtractProperPowerInFree::takeControl( )
{
  if ( freeARCs() > 0 ) {
    if ( arcer.takeControl() ){
      SMList<Word>* smo = 
	new  SMList<Word>(theList.getGroup(),
			  arcer.getData(),
			  Text("Proper powers from") + Name(theList) 
			  ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "WEnumerator",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();
      adminTerminate();
      return;
    } else 
      usedOneARC();
  }
}
Exemplo n.º 5
0
int
main (void)
{
    matrix_t            r = read_matrix ();
    matrix_t            mayw;
    matrix_t            mustw;
    dm_copy(&r, &mayw);
    dm_copy(&r, &mustw);
    printf ("matrix:\n");
    dm_print (stdout, &r);
    // nub
    dm_sort_rows (&r, &mayw, &mustw, &max_row_first);
    dm_nub_rows (&r, &mayw, &mustw, &eq_rows, NULL);
    // optimize
    dm_optimize (&r, &mayw, &mustw);
    // sort again
    dm_sort_rows (&r, &mayw, &mustw, &max_row_first);

    printf ("matrix:\n");
    dm_print (stdout, &r);
    printf ("state mapping:\n");
    state_mapping (&r);
    printf ("transition mapping:\n");
    transition_mapping (&r);
    printf ("dependencies:\n");
    dependencies (&r);

    return 0;
}
Exemplo n.º 6
0
void SGListExtractOfRank::takeControl( )
{
  if (freeARCs() > 0){
    int min = getParameters().getValue("minRank");
    int max = getParameters().getValue("maxRank");
    
    if (arcer.takeControl()){
      SMList<Subgroup>* smo = 
	new  SMList<Subgroup>(theList.getGroup(),
			      arcer.getData(),
			      Text("Subgroups of rank from ") +
			      Text(Chars(min)+Chars(" to ")+Chars(max)+
				   Chars(" in ")) + 
			      Name(theList)
			      ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "SGEnumerator",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();	
    
      adminTerminate();
      return;
    }
    else
      usedOneARC();
  }
}
Exemplo n.º 7
0
//
// Reclaim all unused buckets.
//
void DependencyContext::expunge_stale_entries() {
  assert_locked_or_safepoint(CodeCache_lock);
  if (!has_stale_entries()) {
    assert(!find_stale_entries(), "inconsistent info");
    return;
  }
  nmethodBucket* first = dependencies();
  nmethodBucket* last = NULL;
  int removed = 0;
  for (nmethodBucket* b = first; b != NULL;) {
    assert(b->count() >= 0, "bucket count: %d", b->count());
    nmethodBucket* next = b->next();
    if (b->count() == 0) {
      if (last == NULL) {
        first = next;
      } else {
        last->set_next(next);
      }
      removed++;
      delete b;
      // last stays the same.
    } else {
      last = b;
    }
    b = next;
  }
  set_dependencies(first);
  set_has_stale_entries(false);
  if (UsePerfData && removed > 0) {
    _perf_total_buckets_deallocated_count->inc(removed);
    _perf_total_buckets_stale_count->dec(removed);
  }
}
Exemplo n.º 8
0
void SGListExtractNormal::takeControl( )
{
  if (freeARCs() > 0){
    if (arcer.takeControl()){
      SMList<Subgroup>* smo = 
	new  SMList<Subgroup>(theList.getGroup(),
			      arcer.getData(),
			      Text("Normal subgroups in ") + Name(theList)
			      ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "SGEnumerator",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();	
      
      adminTerminate();
      return;
    }
    else
      usedOneARC();
  }
}
Exemplo n.º 9
0
//
// Add an nmethod to the dependency context.
// It's possible that an nmethod has multiple dependencies on a klass
// so a count is kept for each bucket to guarantee that creation and
// deletion of dependencies is consistent.
//
void DependencyContext::add_dependent_nmethod(nmethod* nm, bool expunge) {
  assert_lock_strong(CodeCache_lock);
  for (nmethodBucket* b = dependencies(); b != NULL; b = b->next()) {
    if (nm == b->get_nmethod()) {
      b->increment();
      return;
    }
  }
  set_dependencies(new nmethodBucket(nm, dependencies()));
  if (UsePerfData) {
    _perf_total_buckets_allocated_count->inc();
  }
  if (expunge) {
    // Remove stale entries from the list.
    expunge_stale_entries();
  }
}
Exemplo n.º 10
0
void DependencyContext::wipe() {
  assert_locked_or_safepoint(CodeCache_lock);
  nmethodBucket* b = dependencies();
  set_dependencies(NULL);
  set_has_stale_entries(false);
  while (b != NULL) {
    nmethodBucket* next = b->next();
    delete b;
    b = next;
  }
}
Exemplo n.º 11
0
bool DependencyContext::is_dependent_nmethod(nmethod* nm) {
  for (nmethodBucket* b = dependencies(); b != NULL; b = b->next()) {
    if (nm == b->get_nmethod()) {
#ifdef ASSERT
      int count = b->count();
      assert(count >= 0, "count shouldn't be negative: %d", count);
#endif
      return true;
    }
  }
  return false;
}
Exemplo n.º 12
0
    void send_to_flash(const std::wstring& data)
    {
        if (!clock_loaded_) {
            core::frame_producer_dependencies dependencies(
                channel_->frame_factory(), channels_, channel_->video_format_desc(), producer_registry_, cg_registry_);
            cg_registry_
                ->get_or_create_proxy(channel_, dependencies, core::cg_proxy::DEFAULT_LAYER, L"hawrysklocka/clock")
                ->add(0, L"hawrysklocka/clock", true, L"", data);
            clock_loaded_ = true;
        } else {
            cg_registry_->get_proxy(channel_, core::cg_proxy::DEFAULT_LAYER)->update(0, data);
        }

        CASPAR_LOG(info) << L"CLK: Clockdata sent: " << data;
    }
Exemplo n.º 13
0
void DependencyContext::print_dependent_nmethods(bool verbose) {
  int idx = 0;
  for (nmethodBucket* b = dependencies(); b != NULL; b = b->next()) {
    nmethod* nm = b->get_nmethod();
    tty->print("[%d] count=%d { ", idx++, b->count());
    if (!verbose) {
      nm->print_on(tty, "nmethod");
      tty->print_cr(" } ");
    } else {
      nm->print();
      nm->print_dependencies();
      tty->print_cr("--- } ");
    }
  }
}
Exemplo n.º 14
0
void PluginListWidgetItemDelegate::slotAboutClicked()
{
	auto const index = focusedIndex();
	auto const model = index.model();

	auto info = QString{};
	info += tr("Plugin name: %1").arg(model->data(index, PluginModel::NameRole).toString()) + "\n";

	auto pluginMetadata = model->data(index, PluginModel::MetadataRole).value<PluginMetadata>();
	info += tr("Author: %1").arg(pluginMetadata.author()) + "\n";
	info += tr("Version: %1").arg(pluginMetadata.version()) + "\n";
	info += tr("Description: %1").arg(pluginMetadata.description()) + "\n";
	info += tr("Dependencies: %1").arg(pluginMetadata.dependencies().join(", ")) + "\n";
	info += tr("Provides: %1").arg(pluginMetadata.provides());

	MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-information")), tr("Plugin information"), info, QMessageBox::Ok, itemView());
}
// Add a new class loader data node to the list.  Assign the newly created
// ClassLoaderData into the java/lang/ClassLoader object as a hidden field
ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous, TRAPS) {
  // We need to allocate all the oops for the ClassLoaderData before allocating the
  // actual ClassLoaderData object.
  ClassLoaderData::Dependencies dependencies(CHECK_NULL);

  No_Safepoint_Verifier no_safepoints; // we mustn't GC until we've installed the
                                       // ClassLoaderData in the graph since the CLD
                                       // contains unhandled oops

  ClassLoaderData* cld = new ClassLoaderData(loader, is_anonymous, dependencies);


  if (!is_anonymous) {
    ClassLoaderData** cld_addr = java_lang_ClassLoader::loader_data_addr(loader());
    // First, Atomically set it
    ClassLoaderData* old = (ClassLoaderData*) Atomic::cmpxchg_ptr(cld, cld_addr, NULL);
    if (old != NULL) {
      delete cld;
      // Returns the data.
      return old;
    }
  }

  // We won the race, and therefore the task of adding the data to the list of
  // class loader data
  ClassLoaderData** list_head = &_head;
  ClassLoaderData* next = _head;

  do {
    cld->set_next(next);
    ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next);
    if (exchanged == next) {
      if (TraceClassLoaderData) {
        ResourceMark rm;
        tty->print("[ClassLoaderData: ");
        tty->print("create class loader data " INTPTR_FORMAT, p2i(cld));
        tty->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
                   cld->loader_name());
        tty->print_cr("]");
      }
      return cld;
    }
    next = exchanged;
  } while (true);

}
Exemplo n.º 16
0
DependenciesSolvingResult ComponentInstaller::tryToInstall(const QStringList &componentNames)
{
    deleteComponents();

    // Add existed componens to resolve componens for install
    IComponentDependenciesPtr dependencies(createDependencies());
    for (IComponent *comp : m_existedComponents)
        dependencies->addComponent(comp);

    QList<IComponent *> discoveredComponents = discoverComponents();

    // Select components to install from the all discovered components
    QList<IComponent *> toInstall;
    for (IComponent *comp : discoveredComponents) {
        dependencies->addComponent(comp);
        if (componentNames.contains(comp->name()))
            toInstall.push_back(comp);
    }

    // Find all parents for components to install
    DependenciesSolvingResult result = dependencies->completeListWithChildren(toInstall);
    if (!result.orphans().isEmpty()) {
        qDeleteAll(toInstall);
        return result;
    }

    // Return only components that have to be installed
    for (IComponent *comp : result.ordered()) {
        if (toInstall.contains(comp))
            continue;

        if (discoveredComponents.contains(comp))
            toInstall.push_back(comp);
    }

    // Delete unused components
    for (IComponent *comp : discoveredComponents) {
        if (!toInstall.contains(comp))
            delete comp;
    }

    m_componentsToInstall = toInstall;

    return DependenciesSolvingResult(m_componentsToInstall);
}
Exemplo n.º 17
0
//
// Remove an nmethod dependency from the context.
// Decrement count of the nmethod in the dependency list and, optionally, remove
// the bucket completely when the count goes to 0.  This method must find
// a corresponding bucket otherwise there's a bug in the recording of dependencies.
// Can be called concurrently by parallel GC threads.
//
void DependencyContext::remove_dependent_nmethod(nmethod* nm, bool expunge) {
  assert_locked_or_safepoint(CodeCache_lock);
  nmethodBucket* first = dependencies();
  nmethodBucket* last = NULL;
  for (nmethodBucket* b = first; b != NULL; b = b->next()) {
    if (nm == b->get_nmethod()) {
      int val = b->decrement();
      guarantee(val >= 0, "Underflow: %d", val);
      if (val == 0) {
        if (expunge) {
          if (last == NULL) {
            set_dependencies(b->next());
          } else {
            last->set_next(b->next());
          }
          delete b;
          if (UsePerfData) {
            _perf_total_buckets_deallocated_count->inc();
          }
        } else {
          // Mark the context as having stale entries, since it is not safe to
          // expunge the list right now.
          set_has_stale_entries(true);
          if (UsePerfData) {
            _perf_total_buckets_stale_count->inc();
            _perf_total_buckets_stale_acc_count->inc();
          }
        }
      }
      if (expunge) {
        // Remove stale entries from the list.
        expunge_stale_entries();
      }
      return;
    }
    last = b;
  }
#ifdef ASSERT
  tty->print_raw_cr("### can't find dependent nmethod");
  nm->print();
#endif // ASSERT
  ShouldNotReachHere();
}
Exemplo n.º 18
0
//
// Walk the list of dependent nmethods searching for nmethods which
// are dependent on the changes that were passed in and mark them for
// deoptimization.  Returns the number of nmethods found.
//
int DependencyContext::mark_dependent_nmethods(DepChange& changes) {
  int found = 0;
  for (nmethodBucket* b = dependencies(); b != NULL; b = b->next()) {
    nmethod* nm = b->get_nmethod();
    // since dependencies aren't removed until an nmethod becomes a zombie,
    // the dependency list may contain nmethods which aren't alive.
    if (b->count() > 0 && nm->is_alive() && !nm->is_marked_for_deoptimization() && nm->check_dependency_on(changes)) {
      if (TraceDependencies) {
        ResourceMark rm;
        tty->print_cr("Marked for deoptimization");
        changes.print();
        nm->print();
        nm->print_dependencies();
      }
      changes.mark_for_deoptimization(nm);
      found++;
    }
  }
  return found;
}
Exemplo n.º 19
0
package* load_package(std::string path)
{
  extract_archive(path, std::string("./temp/"));

  package* pkg = new package;

  std::ifstream description("./temp/DESCRIPTION");
  std::getline(description, pkg->description);

  // licencja może być wielolinijkowa, póki co nie jest to obsługiwane
  std::ifstream licence("./temp/LICENCE");
  std::getline(licence, pkg->licence);
  
  std::ifstream version("./temp/VERSION");
  std::getline(version, pkg->version);
  
  std::ifstream name("./temp/NAME");
  std::getline(name, pkg->name);
  
  std::ifstream dependencies("./temp/DEPENDENCIES");
  std::string dep;
  while(std::getline(dependencies, dep))
    pkg->dependencies.push_back(dep);
  
  std::ifstream files("./temp/INSTALL");
  std::string ins;
  while(std::getline(files, ins))
  {
    std::string::iterator eq_sign = std::find(ins.begin(), ins.end(), '=');
    std::string::iterator eq_sign_min1 = eq_sign - 1;
    std::string::iterator eq_sign_plus2 = eq_sign + 2;
    std::string file = std::string(ins.begin(), eq_sign_min1);
    
    std::string destination = std::string(eq_sign_plus2, ins.end());
    pkg->files.push_back(make_pair(file, destination));
  }

  return pkg;
}
Exemplo n.º 20
0
//
// Invalidate all dependencies in the context
int DependencyContext::remove_all_dependents() {
  assert_locked_or_safepoint(CodeCache_lock);
  nmethodBucket* b = dependencies();
  set_dependencies(NULL);
  int marked = 0;
  int removed = 0;
  while (b != NULL) {
    nmethod* nm = b->get_nmethod();
    if (b->count() > 0 && nm->is_alive() && !nm->is_marked_for_deoptimization()) {
      nm->mark_for_deoptimization();
      marked++;
    }
    nmethodBucket* next = b->next();
    removed++;
    delete b;
    b = next;
  }
  set_has_stale_entries(false);
  if (UsePerfData && removed > 0) {
    _perf_total_buckets_deallocated_count->inc(removed);
  }
  return marked;
}
Exemplo n.º 21
0
void
AnalysisScheduler::runAnalysisWithDependencies(Analysis *analysis,
                                               Program *program)
{
 // First, run the dependencies recursively.
    std::vector<Analysis *> &deps = dependencies(analysis);
    std::vector<Analysis *>::iterator d;
    for (d = deps.begin(); d != deps.end(); ++d)
    {
        TimingPerformance timer("Run of dependency "
                              + (*d)->identifier() + ":");
        runAnalysisWithDependencies(*d, program);
    }

 // Finally, run the argument analysis itself, if necessary.
    std::pair<Analysis *, Program *> entry = std::make_pair(analysis, program);
    if (p_impl->runHistory.find(entry) == p_impl->runHistory.end())
    {
        TimingPerformance timer("Run of analysis "
                              + analysis->identifier() + ":");
        analysis->run(program);
    }
}
bool BinaryDependenciesLdd::findDependencies(const QString& binaryFilePath)
{
  Console::info(2) << " searching dependencies for " << binaryFilePath;

  LddWrapper ldd;
  if(!ldd.execFindDependencies(binaryFilePath)){
    setLastError(ldd.lastError());
    return false;
  }

  LddDependenciesParser parser;
  if( !parser.parse( ldd.readAllStandardOutputString() ) ){
    const QString msg = tr("Parsing ldd output for file '%1' failed.").arg(binaryFilePath);
    auto error = mdtErrorNewQ(msg, Mdt::Error::Critical, this);
    setLastError(error);
    return false;
  }

  auto list = parser.rawDependencies();
  fillAndSetDependencies(list);
  if(!mNotFoundDependencies.isEmpty()){
    const QString msg = tr("Some dependencies have not been found for file '%1': %2")
                        .arg( binaryFilePath, stringRecordListToStringNameList(mNotFoundDependencies).join(", ") );
    auto error = mdtErrorNewQ(msg, Mdt::Error::Critical, this);
    setLastError(error);
    return false;
  }

  if(Console::level() >= 3){
    Console::info(3) << "  found dependencies:";
    for(const auto & library : dependencies() ){
      Console::info(3) << "   " << library.libraryName().fullName();
    }
  }

  return true;
}
Exemplo n.º 23
0
// Compute the dependencies of a given event.  Returns a list of (thread,kind,event) triples.
vector<Tuple<int,int,history_t>> event_dependencies(const vector<vector<Array<const history_t>>>& event_sorted_history, const int direction, const int thread, const int kind, const history_t source) {
  vector<Tuple<int,int,history_t>> deps;
  for (const auto kind_event : dependencies(direction,time_kind_t(kind),source.event)) {
    const int dep_kind = kind_event.x;
    const event_t dep_event = kind_event.y;
    // Search for event in each thread
    bool found = false;
    for (const int t : range((int)event_sorted_history.size())) {
      const auto& sorted_events = event_sorted_history.at(t).at(dep_kind);
      for (const int i : range(find_event(sorted_events,dep_event),sorted_events.size())) {
        const history_t& event = sorted_events[i];
        if (event.event != dep_event)
          break;
        GEODE_ASSERT(!found || dep_kind==compute_kind);
        found = true;
        deps.push_back(tuple(t,dep_kind,event));
      }
    }
    if (!found) {
      int count = 0;
      for (const int t : range((int)event_sorted_history.size())) {
        const auto& events = event_sorted_history[t].at(dep_kind);
        for (const int i : range(max(0,events.size()-1)))
          if (events[i].event > events[i+1].event)
            THROW(RuntimeError,"event_dependencies: order failure: thread %d, kind %d, i %d (%d), events %lld %lld",t,dep_kind,i,events.size(),events[i].event,events[i+1].event);
        for (auto& e : events)
          if (e.event==dep_event)
            count++;
      }
      THROW(RuntimeError,"event_dependencies: dependency not found, direction = %d, count %d, source = %d %s %s, dependency = %s %s",
        direction,count,
        thread,time_kind_names().at(kind),str_event(source.event),
        time_kind_names().at(dep_kind),str_event(dep_event));
    }
  }
  return deps;
}
Exemplo n.º 24
0
dogen::formatters::artefact stitch_formatter::
format(const artefact_formatter_interface& stock_formatter, const context& ctx,
    const yarn::element& e) const {
    const auto al(stock_formatter.archetype_location());
    const auto needs_guard(is_header(stock_formatter.inclusion_support_type()));
    const auto id(e.name().id());

    assistant a(ctx, al, needs_guard, id);
    const auto& fp(a.artefact_properties().file_path());
    auto stitch_template(fp);
    stitch_template.replace_extension(stitch_extension);

    /*
     * If the template does not yet exist, we should just create an
     * empty artefact.
     *
     * This scenario happens when creating a new model or when adding
     * a new artefact formatter for the first time.
     */
    if (!boost::filesystem::exists(stitch_template)) {
        BOOST_LOG_SEV(lg, debug) << "Stitch template not found: "
                                 << fp.generic_string();

        dogen::formatters::artefact r;
        r.overwrite(a.artefact_properties().overwrite());
        return r;
    }

    /*
     * Since the template exists, we can instantiate it.
     */
    auto r(instantiator_.instantiate(stitch_template));
    r.overwrite(a.artefact_properties().overwrite());
    r.dependencies().push_back(stitch_template);
    return r;
}
Exemplo n.º 25
0
bool DependencyContext::find_stale_entries() {
  for (nmethodBucket* b = dependencies(); b != NULL; b = b->next()) {
    if (b->count() == 0)  return true;
  }
  return false;
}
Exemplo n.º 26
0
std::string tokenpaths::functors(const std::map<std::string,std::map<std::string,std::string> >& functors_of_words,const std::map<std::string,std::vector<lexicon> >& words_analyses,const unsigned int& id_index,std::string& related_semantics){
	std::set<std::string> functor_ids_of_words,functor_ids_of_dependencies;
	std::map<std::pair<std::string,std::string>,std::string> functor_dkey_id_of_dependencies;
	std::string functors;
	std::vector<std::pair<std::pair<std::string,std::string>,std::string> > functor_dkey_ids;

	for(auto&& word_functors:functors_of_words){
		std::set<query_result *> functor_dependencies;
		auto word_analyses=words_analyses.find(word_functors.first);
		for(auto&& word:word_analyses->second){
			if(word.dependencies!=NULL)	functor_dependencies.insert(word.dependencies);
		}
		for(auto&& functor:word_functors.second){
			auto&& functor_inserted=functor_ids_of_words.insert(functor.first);
			if(functor_inserted.second==true){
				functors+="{";
				functors+="\"functor id\":\""+functor.first+"\",";
				functors+="\"definition\":\""+functor.second+"\"";
				if(functor_dependencies.empty()==false){
					functors+=",\"dependencies\":[";
					for(auto&& dependency:functor_dependencies){
						functors+=dependencies(*dependency,functor_dkey_id_of_dependencies);
					}
					if(functors.back()==',') functors.pop_back();
					functors+="]";
				}
				functors+="},";
			}
		}
	}
	for(auto&& functor:functor_dkey_id_of_dependencies){
		//convert the map into a vector so that new elements can be added
		//to the end of it while iterating over itself
		functor_dkey_ids.push_back(functor);
	}
	unsigned int id=id_index;
	db *sqlite=db_factory::get_instance();
	for(unsigned int i=0;i<functor_dkey_ids.size();++i){
		auto functor=functor_dkey_ids[i];//keep this variable as copy, as reference it'd get invalidated due to the functor_dkey_ids.push_back() within the loop
		if(functor_ids_of_words.find(functor.second)==functor_ids_of_words.end()
			&&functor_ids_of_dependencies.find(functor.second)==functor_ids_of_dependencies.end()){
			functor_ids_of_dependencies.insert(functor.second);
			query_result *functor_def_entry=sqlite->exec_sql("SELECT * FROM FUNCTOR_DEFS WHERE FUNCTOR_ID = '"+functor.second+"';");
			if(functor_def_entry==NULL){
				throw std::runtime_error("No entries found for functor id "+functor.second+" in FUNCTOR_DEFS db table.");
			}
			const std::string functor_def=*functor_def_entry->field_value_at_row_position(0,"definition");
			functors+="{";
			functors+="\"functor id\":\""+functor.second+"\",";
			functors+="\"definition\":\""+transgraph::apply_json_escapes(functor_def)+"\"";
			query_result *functor_dependencies=lexer::dependencies_read_for_functor(functor.first.first);
			if(functor_dependencies!=NULL){
				functors+=",\"dependencies\":[";
				std::map<std::pair<std::string,std::string>,std::string> new_functor_dkeys_ids;
				functors+=dependencies(*functor_dependencies,new_functor_dkeys_ids);
				for(auto&& new_functor:new_functor_dkeys_ids){
					if(functor_ids_of_words.find(new_functor.second)==functor_ids_of_words.end()
						&&functor_ids_of_dependencies.find(new_functor.second)==functor_ids_of_dependencies.end()){
						functor_dkey_ids.push_back(new_functor);
					}
				}
				if(functors.back()==',') functors.pop_back();
				functors+="]";
			}
			functors+="},";
			++id;
			related_semantics+="{";
			related_semantics+="\"id\":\""+std::to_string(id)+"\",";
			related_semantics+="\"functor\":\""+functor.first.first+"\",";
			related_semantics+="\"d_key\":\""+functor.first.second+"\",";
			related_semantics+="\"functor id\":\""+functor.second+"\"";
			related_semantics+="},";
		}
	}
	return functors;
}
Exemplo n.º 27
0
	HResource Resources::loadInternal(const String& UUID, const Path& filePath, bool synchronous, bool loadDependencies, bool keepInternalReference)
	{
		HResource outputResource;

		bool alreadyLoading = false;
		bool loadInProgress = false;
		{
			// Check if resource is already being loaded on a worker thread
			Lock inProgressLock(mInProgressResourcesMutex);
			auto iterFind2 = mInProgressResources.find(UUID);
			if (iterFind2 != mInProgressResources.end())
			{
				LoadedResourceData& resData = iterFind2->second->resData;
				outputResource = resData.resource.lock();

				if (keepInternalReference)
				{
					resData.numInternalRefs++;
					outputResource.addInternalRef();
				}

				alreadyLoading = true;
				loadInProgress = true;
			}

			// Previously being loaded as async but now we want it synced, so we wait
			if (loadInProgress && synchronous)
				outputResource.blockUntilLoaded();

			if (!alreadyLoading)
			{
				Lock loadedLock(mLoadedResourceMutex);
				auto iterFind = mLoadedResources.find(UUID);
				if (iterFind != mLoadedResources.end()) // Resource is already loaded
				{
					LoadedResourceData& resData = iterFind->second;
					outputResource = resData.resource.lock();

					if (keepInternalReference)
					{
						resData.numInternalRefs++;
						outputResource.addInternalRef();
					}

					alreadyLoading = true;
				}
			}
		}

		// Not loaded and not in progress, start loading of new resource
		// (or if already loaded or in progress, load any dependencies)
		if (!alreadyLoading)
		{
			// Check if the handle already exists
			Lock lock(mLoadedResourceMutex);
			auto iterFind = mHandles.find(UUID);
			if (iterFind != mHandles.end())
				outputResource = iterFind->second.lock();
			else
			{
				outputResource = HResource(UUID);
				mHandles[UUID] = outputResource.getWeak();
			}			
		}

		// We have nowhere to load from, warn and complete load if a file path was provided,
		// otherwise pass through as we might just want to load from memory. 
		if (filePath.isEmpty())
		{
			if (!alreadyLoading)
			{
				LOGWRN_VERBOSE("Cannot load resource. Resource with UUID '" + UUID + "' doesn't exist.");

				// Complete the load as that the depedency counter is properly reduced, in case this 
				// is a dependency of some other resource.
				loadComplete(outputResource);
				return outputResource;
			}
		}
		else if (!FileSystem::isFile(filePath))
		{
			LOGWRN_VERBOSE("Cannot load resource. Specified file: " + filePath.toString() + " doesn't exist.");

			// Complete the load as that the depedency counter is properly reduced, in case this 
			// is a dependency of some other resource.
			loadComplete(outputResource);
			assert(!loadInProgress); // Resource already being loaded but we can't find its path now?

			return outputResource;
		}

		// Load dependency data if a file path is provided
		SPtr<SavedResourceData> savedResourceData;
		if (!filePath.isEmpty())
		{
			FileDecoder fs(filePath);
			savedResourceData = std::static_pointer_cast<SavedResourceData>(fs.decode());
		}

		// If already loading keep the old load operation active, otherwise create a new one
		if (!alreadyLoading)
		{
			{
				Lock lock(mInProgressResourcesMutex);

				ResourceLoadData* loadData = bs_new<ResourceLoadData>(outputResource.getWeak(), 0);
				mInProgressResources[UUID] = loadData;
				loadData->resData = outputResource.getWeak();

				if (keepInternalReference)
				{
					loadData->resData.numInternalRefs++;
					outputResource.addInternalRef();
				}

				loadData->remainingDependencies = 1;
				loadData->notifyImmediately = synchronous; // Make resource listener trigger before exit if loading synchronously

				// Register dependencies and count them so we know when the resource is fully loaded
				if (loadDependencies && savedResourceData != nullptr)
				{
					for (auto& dependency : savedResourceData->getDependencies())
					{
						if (dependency != UUID)
						{
							mDependantLoads[dependency].push_back(loadData);
							loadData->remainingDependencies++;
						}
					}
				}
			}

			if (loadDependencies && savedResourceData != nullptr)
			{
				const Vector<String>& dependencyUUIDs = savedResourceData->getDependencies();
				UINT32 numDependencies = (UINT32)dependencyUUIDs.size();
				Vector<HResource> dependencies(numDependencies);

				for (UINT32 i = 0; i < numDependencies; i++)
					dependencies[i] = loadFromUUID(dependencyUUIDs[i], !synchronous, true, false);

				// Keep dependencies alive until the parent is done loading
				{
					Lock lock(mInProgressResourcesMutex);

					// At this point the resource is guaranteed to still be in-progress, so it's safe to update its dependency list
					mInProgressResources[UUID]->dependencies = dependencies;
				}
			}
		}
		else if (loadDependencies && savedResourceData != nullptr) // Queue dependencies in case they aren't already loaded
		{
			const Vector<String>& dependencies = savedResourceData->getDependencies();
			if (!dependencies.empty())
			{
				{
					Lock lock(mInProgressResourcesMutex);

					ResourceLoadData* loadData = nullptr;

					auto iterFind = mInProgressResources.find(UUID);
					if (iterFind == mInProgressResources.end()) // Fully loaded
					{
						loadData = bs_new<ResourceLoadData>(outputResource.getWeak(), 0);
						loadData->resData = outputResource.getWeak();
						loadData->remainingDependencies = 0;
						loadData->notifyImmediately = synchronous; // Make resource listener trigger before exit if loading synchronously

						mInProgressResources[UUID] = loadData;
					}
					else
					{
						loadData = iterFind->second;
					}

					// Register dependencies and count them so we know when the resource is fully loaded
					for (auto& dependency : dependencies)
					{
						if (dependency != UUID)
						{
							bool registerDependency = true;

							auto iterFind2 = mDependantLoads.find(dependency);
							if (iterFind2 != mDependantLoads.end())
							{
								Vector<ResourceLoadData*>& dependantData = iterFind2->second;
								auto iterFind3 = std::find_if(dependantData.begin(), dependantData.end(),
									[&](ResourceLoadData* x)
								{
									return x->resData.resource.getUUID() == outputResource.getUUID();
								});

								registerDependency = iterFind3 == dependantData.end();
							}

							if (registerDependency)
							{
								mDependantLoads[dependency].push_back(loadData);
								loadData->remainingDependencies++;
								loadData->dependencies.push_back(_getResourceHandle(dependency));
							}
						}
					}
				}

				for (auto& dependency : dependencies)
					loadFromUUID(dependency, !synchronous, true, false);
			}
		}

		// Actually start the file read operation if not already loaded or in progress
		if (!alreadyLoading && !filePath.isEmpty())
		{
			// Synchronous or the resource doesn't support async, read the file immediately
			if (synchronous || !savedResourceData->allowAsyncLoading())
			{
				loadCallback(filePath, outputResource);
			}
			else // Asynchronous, read the file on a worker thread
			{
				String fileName = filePath.getFilename();
				String taskName = "Resource load: " + fileName;

				SPtr<Task> task = Task::create(taskName, std::bind(&Resources::loadCallback, this, filePath, outputResource));
				TaskScheduler::instance().addTask(task);
			}
		}
		else // File already loaded or in progress
		{
			// Complete the load unless its in progress in which case we wait for its worker thread to complete it.
			// In case file is already loaded this will only decrement dependency count in case this resource is a dependency.
			if (!loadInProgress)
				loadComplete(outputResource);
			else
			{
				// In case loading finished in the meantime we cannot be sure at what point ::loadComplete was triggered,
				// so trigger it manually so that the dependency count is properly decremented in case this resource
				// is a dependency.
				Lock lock(mLoadedResourceMutex);
				auto iterFind = mLoadedResources.find(UUID);
				if (iterFind != mLoadedResources.end())
					loadComplete(outputResource);
			}
		}

		return outputResource;
	}
Exemplo n.º 28
0
    void jacobi(
        crs_matrix<double> const & A
      , std::vector<double> const & b
      , std::size_t iterations
      , std::size_t block_size
    )
    {
        typedef std::vector<double> vector_type;

        boost::shared_ptr<vector_type> dst(new vector_type(b));
        boost::shared_ptr<vector_type> src(new vector_type(b));

        std::vector<range> block_ranges;
        // pre-computing ranges for the different blocks
        for(std::size_t i = 0; i < dst->size(); i += block_size)
        {
            block_ranges.push_back(
                range(i, std::min<std::size_t>(dst->size(), i + block_size)));
        }

        // pre-computing dependencies
        std::vector<std::vector<std::size_t> > dependencies(block_ranges.size());
        for(std::size_t b = 0; b < block_ranges.size(); ++b)
        {
            for(std::size_t i = block_ranges[b].begin(); i < block_ranges[b].end(); ++i)
            {
                std::size_t begin = A.row_begin(i);
                std::size_t end = A.row_end(i);
                
                for(std::size_t ii = begin; ii < end; ++ii)
                {
                    std::size_t idx = A.indices[ii];
                    for(std::size_t j = 0; j < block_ranges.size(); ++j)
                    {
                        if(block_ranges[j].begin() <= idx && idx < block_ranges[j].end())
                        {
                            if(std::find(dependencies[b].begin(), dependencies[b].end(), j) == dependencies[b].end())
                            {
                                dependencies[b].push_back(j);
                            }
                            break;
                        }
                    }
                }
            }
        }

        typedef std::vector<hpx::shared_future<void> > future_vector;
        boost::shared_ptr<future_vector> deps_dst(new future_vector(dependencies.size(), hpx::make_ready_future()));
        boost::shared_ptr<future_vector> deps_src(new future_vector(dependencies.size(), hpx::make_ready_future()));

        hpx::util::high_resolution_timer t;
        for(std::size_t iter = 0; iter < iterations; ++iter)
        {
            for(std::size_t block = 0; block < block_ranges.size(); ++block)
            {
                std::vector<std::size_t> const & deps(dependencies[block]);
                std::vector<hpx::shared_future<void> > trigger;
                trigger.reserve(deps.size());
                for (std::size_t dep : deps)
                {
                    trigger.push_back((*deps_src)[dep]);
                }                                                                                                                           
                
                (*deps_dst)[block]
                    = hpx::when_all(boost::move(trigger)).then(
                        hpx::launch::async,
                        hpx::util::bind(
                            jacobi_kernel_wrap
                          , block_ranges[block]
                          , boost::cref(A)
                          , boost::ref(*dst)
                          , boost::cref(*src)
                          , boost::cref(b)
                        )
                    );
            }
            std::swap(dst, src);
            std::swap(deps_dst, deps_src);
        }

        hpx::wait_all(*deps_dst);
        hpx::wait_all(*deps_src);

        double time_elapsed = t.elapsed();
        std::cout << dst->size() << " "
            << ((double(dst->size() * iterations)/1e6)/time_elapsed) << " MLUPS/s\n" 
            << std::flush;
    }
Exemplo n.º 29
0
string getDBStructure()
{
	return "----------------------------------------------------------------------\n\
--\n\
--	MOPSLinux package system\n\
--	Database creation script\n\
--	$Id: dbstruct.cpp,v 1.3 2007/11/02 20:19:45 i27249 Exp $\n\
--\n\
----------------------------------------------------------------------\n\
\n\
create table packages (\n\
	package_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	package_name TEXT NOT NULL,\n\
	package_version TEXT NOT NULL,\n\
	package_arch TEXT NOT NULL,\n\
	package_build TEXT NULL,\n\
	package_compressed_size TEXT NOT NULL,\n\
	package_installed_size TEXT NOT NULL,\n\
	package_short_description TEXT NULL,\n\
	package_description TEXT NULL, \n\
	package_changelog TEXT NULL,\n\
	package_packager TEXT NULL,\n\
	package_packager_email TEXT NULL,\n\
	package_installed INTEGER NOT NULL,\n\
	package_configexist INTEGER NOT NULL,\n\
	package_action INTEGER NOT NULL,\n\
	package_md5 TEXT NOT NULL,\n\
	package_filename TEXT NOT NULL,\n\
	package_betarelease TEXT NOT NULL,\n\
	package_installed_by_dependency INTEGER NOT NULL DEFAULT '0',\n\
	package_type INTEGER NOT NULL DEFAULT '0'\n\
);\n\
create index ppname on packages (package_id, package_name, package_version, package_action, package_installed, package_md5);\n\
\n\
create table files (\n\
	file_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	file_name TEXT NOT NULL,\n\
	file_type INTEGER NOT NULL,\n\
	packages_package_id INTEGER NOT NULL\n\
);\n\
create index pname on files (file_name, packages_package_id);\n\
\n\
create table conflicts (\n\
	conflict_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	conflict_file_name TEXT NOT NULL,\n\
	backup_file TEXT NOT NULL,\n\
	conflicted_package_id INTEGER NOT NULL\n\
);\n\
\n\
create table locations (\n\
	location_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	packages_package_id INTEGER NOT NULL,\n\
	server_url TEXT NOT NULL,\n\
	location_path TEXT NOT NULL\n\
);\n\
create index locpid on locations(packages_package_id, location_path, server_url);\n\
create table tags (\n\
	tags_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	tags_name TEXT NOT NULL\n\
);\n\
create index ptag on tags (tags_id, tags_name);\n\
\n\
create table tags_links (\n\
	tags_link_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	packages_package_id INTEGER NOT NULL,\n\
	tags_tag_id INTEGER NOT NULL\n\
);\n\
create index ptaglink on tags_links (packages_package_id, tags_tag_id);\n\
\n\
create table dependencies (\n\
	dependency_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
	packages_package_id INTEGER NOT NULL,\n\
	dependency_condition INTEGER NOT NULL DEFAULT '1',\n\
	dependency_type INTEGER NOT NULL DEFAULT '1',\n\
	dependency_package_name TEXT NOT NULL,\n\
	dependency_package_version TEXT NULL,\n\
	dependency_build_only INTEGER NOT NULL DEFAULT '0' \
);\n\
\n\
create index pdeps on dependencies (packages_package_id, dependency_id, dependency_package_name, dependency_package_version, dependency_condition);\n\
\n\
-- INTERNATIONAL SUPPORT\n\
\n\
--create table descriptions (\n\
--	description_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
--	packages_package_id INTEGER NOT NULL,\n\
--	description_language TEXT NOT NULL,\n\
--	description_text TEXT NOT NULL,\n\
--	short_description_text TEXT NOT NULL\n\
--);\n\
\n\
--create table changelogs (\n\
--	changelog_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
--	packages_package_id INTEGER NOT NULL,\n\
--	changelog_language TEXT NOT NULL,\n\
--	changelog_text TEXT NOT NULL\n\
--);\n\
\n\
-- RATING SYSTEM - SUPPORT FOR FUTURE\n\
--create table ratings (\n\
--	rating_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,\n\
--	rating_value INTEGER NOT NULL,\n\
--	packages_package_name TEXT NOT NULL\n\
--);\n\
";
}
Exemplo n.º 30
0
 void ParanoidSolver::postConstraints(void) {
   provides(*this,install_,provides_,virtuals_);
   dependencies(*this,install_,deps_);
   conflicts(*this,install_,conflicts_);
 }