VectorClock::values_t HappensBeforeBase::incomparable_after(const index_t i1,
                                                            const index_t i2) const
{
   VectorClock::values_t Incomparable{};
   for (int j = i1 + 1; j < i2; ++j)
   {
      if (!happens_before(i1, j))
      {
         Incomparable.insert(j);
      }
   }
   DEBUGF("\t" << outputname(), "incomparable_after", "[" << i1 << "]", " = " << Incomparable << "\n");
   return Incomparable;
}
VectorClock::indices_t HappensBeforeBase::covering(const index_t i, const instruction_t& instr,
                                                   VectorClock C) const
{
   const auto tid = boost::apply_visitor(program_model::get_tid(), instr);
   thread_transitive_reduction(i, tid, C);
   C[tid] = 0; // exclude instr.tid-dependencies
   VectorClock::indices_t Covering{};
   VectorClock::value_t j = 0;
   // in every loop-iteration an entry in C is set to 0.
   while (j = max_element(C), j > 0)
   {
      Covering.insert(j);
      transitive_reduction(j, C);
      const auto tid_j = boost::apply_visitor(program_model::get_tid(), mE[j].instr());
      C[tid_j] = 0;
   }
   DEBUGF("\t" << outputname(), "covering", "[" << i << "], " << instr, " = " << Covering << "\n");
   return Covering;
}
VectorClock::values_t HappensBeforeBase::front(const VectorClock::indices_t& subseq) const
{
   VectorClock::values_t Front{};
   if (!subseq.empty())
   {
      VectorClock first_seen(mE.nr_threads());
      VectorClock last_seen(mE.nr_threads());
      for (const auto& i : subseq)
      {
         const auto tid = boost::apply_visitor(program_model::get_tid(), mE[i].instr());
         const VectorClock& C = (*this)[i];
         if (first_seen[tid] == 0)
         {
            auto seen_before = utils::algo::find_if_with_index(
               C.cbegin(), C.cend(), [&first_seen, &last_seen](const auto& tid_, const auto& val) {
                  return last_seen[tid_] > 0 && first_seen[tid_] <= val && val <= last_seen[tid_];
               });
            if (seen_before != C.cend())
            {
               DEBUG(tabs() << "\t\t" << i << " notin Front\n");
            }
            else
            {
               DEBUG(tabs() << "\t\t" << i << " in Front\n");
               Front.insert(i);
            }
            first_seen[tid] = i;
         }
         else
         {
            DEBUG(tabs() << "\t\t" << i << " notin Front : not first of " << tid << "\n");
            /// @invariant last_seen[tid] == C[tid]
            /// (i.e. subsequence of Transitions by tid in subseq
            /// does not skip Transitions by tid).
            assert(last_seen[tid] == C[tid]);
         }
         last_seen[tid] = i;
      }
   }
   DEBUGF("\t" << outputname(), "front", subseq, " = " << Front << "\n");
   return Front;
}
Beispiel #4
0
int main(int argc, char* argv[])
{
  
	if(argc < 2)
		return -1;
	std::string fullname(argv[1]);

	if(fullname.find(".amc") == std::string::npos)
		return -1;
	std::string outputname(fullname.substr(0,fullname.find('.')));

	outputname += ".ann";
	AMCParser parser;
	parser.loadMocapData(fullname);
	parser.writeToFile(outputname);

	if(argc > 2  && argc % 2 == 0)
	{
		std::vector<std::pair<std::size_t,std::size_t>> sequence;
		for(std::size_t i = 2; i < argc; i+=2)
		{
			std::stringstream ss;
			std::pair<std::size_t,std::size_t> seg;

			ss << argv[i];
			ss << " ";
			ss << argv[i+1];

			ss >> seg.first;
  			ss >> seg.second;
			sequence.push_back(seg);
		}

		std::ifstream reader(outputname,std::ios::binary|std::ios::in);
		std::size_t rows,cols;
		reader.read((char*)&rows,sizeof(rows));
		reader.read((char*)&cols,sizeof(cols));

		std::vector<std::vector<double>> data(rows,std::vector<double>(cols));

		for(std::size_t i = 0; i < cols; i++)
			for(std::size_t j = 0; j < rows; j++)
			{
				reader.read((char*)&data[j][i],sizeof(double));
			}
	
		reader.close();
		for(std::size_t i = 0; i < sequence.size(); i++)
		{
			std::stringstream ss;
			std::string filenameout;
			ss << sequence[i].first << "_" << sequence[i].second;
			ss >> filenameout;
			filenameout = outputname.substr(0,outputname.find('.')) + "_" + filenameout + ".ann";
			
			std::size_t subrows = ceil((sequence[i].second - sequence[i].first)/4.0);
			std::size_t subcols = cols;

			std::ofstream writer(filenameout ,std::ios::binary|std::ios::out);

			writer.write((char*)&subrows, sizeof(subrows));
			writer.write((char*)&subcols, sizeof(subcols));
		
			for(std::size_t j = 0; j < cols; j++)
			{
				for(std::size_t k = sequence[i].first; k < sequence[i].second; k+=4)
				{
 					writer.write((char*)&data[k][j],sizeof(double));
 				}
 			}
			writer.close();
		}
	}
 /**
  @brief Always returns true.
  */
 bool Source::condition(const execution&, SufficientSet&, const Thread::tid_t&)
 {
     DEBUGF(outputname(), "condition", "", " = true\n");
     return true;
 }