コード例 #1
0
ファイル: simple.hpp プロジェクト: Fadis/harps
 /*!
  * 楽譜を読んでオーディオデータを生成し、指定された出力先に出力します。
  */
   void operator() () {
     tbb::parallel_for ( tbb::blocked_range< unsigned int > ( 0, track_count, 1 ),
                    TrackRunner ( readers, buffers ) );
     BufferType sum;
     Buffer< float >::SampleType *sum_raw = sum.get();
     unsigned int sample_index;
     for ( sample_index = 0; sample_index != SAMPLE_COUNT; sample_index++ )
       sum_raw[ sample_index ] = 0.0;
     unsigned int track_index;
     for ( track_index = 0; track_index != track_count; track_index++ ) {
       if ( buffers[ track_index ] ) {
         Buffer< float >::SampleType *buffer_raw = buffers[ track_index ]->get();
         for ( sample_index = 0; sample_index != SAMPLE_COUNT; sample_index++ )
           sum_raw[ sample_index ] += buffer_raw[ sample_index ];
       }
     }
     BufferType nlevel;
     Buffer< float >::SampleType *nlevel_raw = nlevel.get();
     for ( sample_index = 0; sample_index != SAMPLE_COUNT; sample_index++ ) {
       normalizer.setValue ( sum_raw[ sample_index ] );
       nlevel_raw[ sample_index ] = normalizer.getAmp();
     }
     reduceNormalizingNoize ( nlevel );
     for ( sample_index = 0; sample_index != SAMPLE_COUNT; sample_index++ )
       sum_raw[ sample_index ] /= nlevel_raw[ sample_index ];
     output ( sum/*, SAMPLE_COUNT*/ );
   }
コード例 #2
0
void MomentumEstimator::addObservables(PropertySetType& plist, BufferType& collectables)
{
  if (hdf5_out)
  {
    myIndex=collectables.size();
    collectables.add(nofK.begin(),nofK.end());
    collectables.add(compQ.begin(),compQ.end());
  }
  else
  {
    myIndex=plist.size();
    for (int i=0; i<nofK.size(); i++)
    {
      std::stringstream sstr;
      sstr << "nofk_" <<i;
      int id=plist.add(sstr.str());
    }
    for (int i=0; i<Q.size(); i++)
    {
      std::stringstream sstr;
      sstr << "Q_" <<i;
      int id=plist.add(sstr.str());
    }
  }
}
コード例 #3
0
void CoulombPBCAATemp::copyToBuffer(ParticleSet& P, BufferType& buffer)
{
  if(is_active)
  {
    buffer.put(SR2.begin(),SR2.end());
    buffer.put(Value);
  }
}
コード例 #4
0
 LocalECPotential::Return_t 
   LocalECPotential::updateBuffer(ParticleSet& P, BufferType& buffer) 
   {
     NewValue=Value=evaluateForPbyP(P);
     buffer.put(PPart.begin(),PPart.end());
     buffer.put(Value);
     return Value;
   }
コード例 #5
0
ファイル: CoulombPBCAB.cpp プロジェクト: jyamu/qmc
/** The functions for PbyP move for reptation */
CoulombPBCAB::Return_t
CoulombPBCAB::updateBuffer(ParticleSet& P, BufferType& buffer)
{
  Value=evaluateForPyP(P);
  buffer.put(SRpart.begin(),SRpart.end());
  buffer.put(LRpart.begin(),LRpart.end());
  buffer.put(Value);
  return Value;
}
コード例 #6
0
 LocalECPotential::Return_t 
   LocalECPotential::registerData(ParticleSet& P, BufferType& buffer) 
   {
     PPart.resize(P.getTotalNum());
     NewValue=Value=evaluateForPbyP(P);
     buffer.add(PPart.begin(),PPart.end());
     buffer.add(Value);
     return Value;
   }
コード例 #7
0
int CLinuxSerialPort::Read(BufferType &Buffer, int Number)
{
    BufferType ReadBuffer(Number, 0);
    int NumRead = read(m_FileDescriptor, ReadBuffer.data(), ReadBuffer.size());
    if(0<NumRead)
    {
        Buffer.insert(Buffer.end(), ReadBuffer.begin(), ReadBuffer.begin() + NumRead);
    }
    return NumRead;
}
コード例 #8
0
    void sessionEvent( BufferType const & buffer, TypeId const & typeId, KeyType const & keyType)
    {
      m_typeId  = typeId;
      m_keyType = keyType;

      m_buffer.clear();
      m_buffer.reserve(buffer.size());
      m_buffer.insert(m_buffer.end(),buffer.begin(),buffer.end());

      std::cout << "SpotSessionListenerWorker: [" << m_workerName << "] has been received an event." << std::endl;
    }
コード例 #9
0
CoulombPBCAATemp::Return_t
CoulombPBCAATemp::updateBuffer(ParticleSet& P, BufferType& buffer)
{
  if(is_active)
  {
    Value=evaluateForPbyP(P);
    buffer.put(SR2.begin(),SR2.end());
    buffer.put(Value);
  }
  return Value;
}
コード例 #10
0
      bool UccSession::classifyMessage (BufferType& buff, TypeId& type, KeyType& key)
      {
        bool found = AbsSessionType::classifyMessage(buff, type, key);
        if ((!found) && (!m_buffer.empty()))
        {
          SizeType parsedSize = 0;
          SizeType structureSize = 0;
          gvr::utils::Json json;
          unsigned char flag = 0;
          switch (IUccClassifyMessage::parseToStructure(m_buffer,parsedSize,structureSize,flag,json))
          {
          case IClassifyMessageType::Integrity::CComplete:
          case IClassifyMessageType::Integrity::CUnknown:
            {
              if (parsedSize)
              {
                if (m_buffer.size() > parsedSize)
                {
                  buff.reserve(parsedSize);
                  buff.assign(m_buffer.begin(),m_buffer.begin()+(parsedSize));

                  SizeType remainingSize = (m_buffer.size()-parsedSize);
                  BufferType remainingBuffer;
                  remainingBuffer.reserve(remainingSize);
                  remainingBuffer.assign(m_buffer.begin()+(parsedSize),m_buffer.end());
                  m_buffer.swap(remainingBuffer);
                }
                else
                {
                  m_buffer.swap(buff);
                  m_buffer.clear();
                }
                type = UccMessageAny::GetTypeId();
                key = UccMessageAny::CDefaultKey;
                found = true;
              }
              else
              {
                m_buffer.clear();
              }
            }
            break;
          case IClassifyMessageType::Integrity::CIncomplete:
            break;
          default:
            {
              m_buffer.clear();
            }
            break;
          }
        }
        return found;
      }
コード例 #11
0
ファイル: CoulombPBCAB.cpp プロジェクト: jyamu/qmc
CoulombPBCAB::Return_t
CoulombPBCAB::registerData(ParticleSet& P, BufferType& buffer)
{
  P.SK->DoUpdate=true;
  SRpart.resize(NptclB);
  LRpart.resize(NptclB);
  Value=evaluateForPyP(P);
  buffer.add(SRpart.begin(),SRpart.end());
  buffer.add(LRpart.begin(),LRpart.end());
  buffer.add(Value);
  return Value;
}
コード例 #12
0
   Impl( BufferType& buffer, 
         const IPnPort& _destination )
      throw (SocketException) :
      bytesLeft( buffer.size() ),
      curByte( buffer.begin() ),
      destination( _destination ),
      state( BufferSender::ERROR )  {
      // take control of the data
      setBuffer( buff );
      connect();

   }
コード例 #13
0
ファイル: ParticlesBase.hpp プロジェクト: CodeLemon/picongpu
    void fillGaps()
    {
        AreaMapping<AREA, MappingDesc> mapper(this->cellDescription);

        __cudaKernel(kernelFillGaps)
            (mapper.getGridDim(), TileSize)
            (particlesBuffer->getDeviceParticleBox(), mapper);

        __cudaKernel(kernelFillGapsLastFrame)
            (mapper.getGridDim(), TileSize)
            (particlesBuffer->getDeviceParticleBox(), mapper);
    }
コード例 #14
0
ファイル: Chat.cpp プロジェクト: Noxalus/YAPOG
  BufferType                Chat::GetBufHistory ()
  {
    BufferType bufftosend;

    std::cout << history_.Count () << std::endl;
    bufftosend.Add("History :\r\n");
    for (size_t i = 0; i < history_.Count () - 1; i++)
      bufftosend.Add(history_[i] + "\r\n");
    bufftosend.Add(history_[history_.Count () - 1]);

    return bufftosend;
  }
コード例 #15
0
ファイル: Chat.cpp プロジェクト: Noxalus/YAPOG
  void								      Chat::SetBuf (String b)
  {
    BufferType* tmp = new BufferType;
    entry_ = b;
    String w;
    std::stringstream ss (entry_);

    while (ss >> w)
      tmp->Add (w);

    buffer_ = *tmp;
  }
コード例 #16
0
void EnergyDensityEstimator::addObservables(PropertySetType& plist, BufferType& collectables)
{
  myIndex=collectables.size();
  //allocate space for energy density outside of any spacegrid
  outside_buffer_offset=collectables.size();
  int nvalues=(int)nEDValues;
  vector<RealType> tmp(nvalues);
  collectables.add(tmp.begin(),tmp.end());
  //allocate space for spacegrids
  for(int i=0; i<spacegrids.size(); i++)
  {
    spacegrids[i]->allocate_buffer_space(collectables);
  }
}
コード例 #17
0
CoulombPBCAATemp::Return_t
CoulombPBCAATemp::registerData(ParticleSet& P, BufferType& buffer)
{
  if(is_active)
  {
    P.SK->DoUpdate=true;
    SR2.resize(NumCenters,NumCenters);
    dSR.resize(NumCenters);
    del_eikr.resize(P.SK->KLists.numk);
    Value=evaluateForPbyP(P);
    buffer.add(SR2.begin(),SR2.end());
    buffer.add(Value);
  }
  return Value;
}
bool SpotMessageVgdProcessPackageResponse::parse (BufferType const & buff)
{
  if(buff.size() < CMessageSize)  return false; // message too short

  // In this message the work is just parse the header + ACK code.
  return AbsSpotMessageWithAppCatCmdID::parse(buff); // Length and AckCode are get by this method.
}
コード例 #19
0
void FD3D12DynamicRHI::UnlockBuffer(FRHICommandListImmediate* RHICmdList, BufferType* Buffer)
{
	FD3D12LockedResource& LockedData = Buffer->LockedData;
	check(LockedData.bLocked == true);

	// Determine whether the buffer is dynamic or not.
	const bool bIsDynamic = (Buffer->GetUsage() & BUF_AnyDynamic) ? true : false;

	if (bIsDynamic)
	{
		// If the Buffer is dynamic, its upload heap memory can always stay mapped. Don't do anything.
	}
	else
	{
		if (LockedData.bLockedForReadOnly)
		{
			//Nothing to do, just release the locked data at the end of the function
		}
		else
		{
			// Copy the contents of the temporary memory buffer allocated for writing into the Buffer.
			BufferType* CurrentBuffer = Buffer;

			// Update all of the resources in the LDA chain
			while (CurrentBuffer)
			{
				// If we are on the render thread, queue up the copy on the RHIThread so it happens at the correct time.
				if (ShouldDeferBufferLockOperation(RHICmdList))
				{
					new (RHICmdList->AllocCommand<FRHICommandUpdateBuffer>()) FRHICommandUpdateBuffer(&CurrentBuffer->ResourceLocation, LockedData.ResourceLocation, LockedData.LockedOffset, LockedData.LockedPitch);
				}
				else
				{
					UpdateBuffer(CurrentBuffer->ResourceLocation.GetResource(),
						CurrentBuffer->ResourceLocation.GetOffsetFromBaseOfResource() + LockedData.LockedOffset,
						LockedData.ResourceLocation.GetResource(),
						LockedData.ResourceLocation.GetOffsetFromBaseOfResource(),
						LockedData.LockedPitch);
				}

				CurrentBuffer = CurrentBuffer->GetNextObject();
			}
		}
	}

	LockedData.Reset();
}
コード例 #20
0
/** copy data that are required to evaluate ratios from the buffer
* @param P active ParticleSet
* @param buf anonymous buffer from which the data will be copied.
*
* This function lets the OrbitalBase objects get the minimal data
* that are required to evaluate the ratio from the buffer.
* Only the data registered by dumToBuffer will be available.
*/
void TrialWaveFunction::dumpFromBuffer(ParticleSet& P, BufferType& buf)
{
  buf.rewind(BufferCursor);
  vector<OrbitalBase*>::iterator it(Z.begin());
  vector<OrbitalBase*>::iterator it_end(Z.end());
  for (; it!=it_end; ++it)
    (*it)->dumpFromBuffer(P,buf);
}
コード例 #21
0
ファイル: main.cpp プロジェクト: franklindg/ApeEngine
void DataSetter::SetData(void* data, size_t elementSize, size_t offset, size_t numElements)
{
	m_ElementSize = elementSize;
	m_Offset = offset;
	m_NumElements = numElements;

	unsigned char* first = (unsigned char*)data + (offset * numElements);
	unsigned char* last = first + (numElements * elementSize);
	m_Data.assign(first, last);
}
コード例 #22
0
void BufferSender::setBuffer( BufferType& buffer ) 
{
   MC2_ASSERT( m_impl->state == READY ||
               m_impl->state == DONE );
   MC2_ASSERT( buffer.size() != 0 );

   m_impl->setBuffer( buffer );
   m_impl->state = SENDING;
   resetTimeout();
}
コード例 #23
0
void QueuedPacketReceiver::enqueuePacket()
{
   if ( getState() != IDLE ) {
      return;
   }

   BufferType buffer;
   getBuffer( buffer );
   uint32 dataSize = buffer.size();

   if ( dataSize > 0 ) { 
      mc2dbg4 << "[QueuedPacketReceiver] got buffer with size: " 
             << dataSize << endl;
      m_packetQueue.
         enqueue( Packet::makePacket( buffer.release(), dataSize ));
   } else {
      mc2dbg2 << "[QueuedPacketReceiver] buffer empty!" << endl;
   }
}
コード例 #24
0
 /** calculate the averages and reset to zero
  *\param record a container class for storing scalar records (name,value)
  *\param wgtinv the inverse weight
  */
 void LocalEnergyEstimator::report(RecordListType& record, RealType wgtinv, BufferType& msg) {
   msg.get(elocal.begin(),elocal.end());
   register int ir=LocalEnergyIndex;
   b_average =  elocal[ENERGY_INDEX]*wgtinv;
   b_variance = elocal[ENERGY_SQ_INDEX]*wgtinv-b_average*b_average;
   record[ir++] = b_average;
   record[ir++] = b_variance;
   record[ir++] = elocal[POTENTIAL_INDEX]*wgtinv;
   for(int i=0, ii=LE_MAX; i<SizeOfHamiltonians; i++,ii++) {
     record[ir++] = elocal[ii]*wgtinv;
   }
   reset();
 }
コード例 #25
0
bool SpotMessageHardwareInfo::parse (BufferType const & buff)
{
  if(buff.size() <= CHeaderSize)  return false; // message too short

  if( buff[CMessageItemQtyOffset] == 0 )
  {
    return true; // This request has no item codes, so this is a request for ALL available items in SPOT.
  }

  bool blRet = AbsSpotMessageWithAppCatCmdID::parse(buff);

  if( !blRet ) return false; // malformed header

  BufferType::const_iterator itDataBegining( buff.begin() + CMessageItemDataOffset );

  m_ItemVector.assign(itDataBegining, itDataBegining + buff[CMessageItemQtyOffset]);

  std::cout << "SpotMessageHardwareInfo::parse() - Length: " << size() << " bytes.\n";
  char* pcBuffer = new char[3 * size() + 2];
  std::cout << "\nMessage Data: " << Utils::dumpBuffer(pcBuffer, &buff.front(), size()) << std::endl << std::endl;
  delete[] pcBuffer;

  return true;
}
コード例 #26
0
ファイル: ParticlesBase.hpp プロジェクト: CodeLemon/picongpu
    void shiftParticles()
    {
        StrideMapping<AREA, DIM3, MappingDesc> mapper(this->cellDescription);
        ParticlesBoxType pBox = particlesBuffer->getDeviceParticleBox();

        __startTransaction(__getTransactionEvent());
        do
        {
            __cudaKernel(kernelShiftParticles)
                (mapper.getGridDim(), TileSize)
                (pBox, mapper);
        }
        while (mapper.next());

        __setTransactionEvent(__endTransaction());

    }
コード例 #27
0
 static void call(grid<Real> const & g, BufferType & buffer)
 {
     hpx::util::high_resolution_timer timer;
     Real * data = new Real[g.ny_ * g.nz_];
     buffer = BufferType(data, g.ny_ * g.nz_, BufferType::take);
     typename BufferType::value_type * src = buffer.data();
     for(std::size_t z = 0; z != g.nz_; ++z)
     {
         for(std::size_t y = 0; y != g.ny_; ++y)
         {
             *src = g(1, y, z);
             ++src;
         }
     }
     double elapsed = timer.elapsed();
     profiling::data().time_pack_x(elapsed);
     profiling::data().time_pack(elapsed);
 }
コード例 #28
0
    /**  add the local energy, variance and all the Hamiltonian components to the scalar record container
     *@param record storage of scalar records (name,value)
     */
  void 
  MultipleEnergyEstimator::add2Record(RecordNamedProperty<RealType>& record, BufferType& msg) {
    if(ediff_name.size()) {
      FirstColumnIndex = record.add(ediff_name[0].c_str());
      for(int i=1; i<ediff_name.size(); i++) record.add(ediff_name[i].c_str());
      for(int i=0; i<esum_name.size(); i++) record.add(esum_name(i).c_str());
    } else {
      FirstColumnIndex = record.add(esum_name(0).c_str());
      for(int i=1; i<esum_name.size(); i++) record.add(esum_name(i).c_str());
    }
    //for(int i=0; i<elocal_name.size(); i++) record.add(elocal_name(i).c_str());

    msg.add(esum.begin(),esum.end());

    //FirstColumnIndex = record.add(esum_name(0).c_str());
    //for(int i=1; i<esum_name.size(); i++) record.add(esum_name(i).c_str());
    //for(int i=0; i<ediff_name.size(); i++) record.add(ediff_name[i].c_str());
    //for(int i=0; i<elocal_name.size(); i++) record.add(elocal_name(i).c_str());
  }
コード例 #29
0
ファイル: CoulombPBCAB.cpp プロジェクト: jyamu/qmc
void CoulombPBCAB::copyToBuffer(ParticleSet& P, BufferType& buffer)
{
  buffer.put(SRpart.begin(),SRpart.end());
  buffer.put(LRpart.begin(),LRpart.end());
  buffer.put(Value);
}
コード例 #30
0
 void LocalECPotential::copyToBuffer(ParticleSet& P, BufferType& buffer) 
 {
   buffer.put(PPart.begin(),PPart.end());
   buffer.put(Value);
 }