Пример #1
0
 void operator()( const tbb::blocked_range<size_t>& r) const
 {
     for( std::size_t i = r.begin(), e = r.end(); i != e; ++i)
         std::for_each( view_.row_begin(i), view_.row_end(i), f_);
 }
Пример #2
0
 void operator()( const tbb::blocked_range<int> &r ) const {
     for (int i = r.begin(); i != r.end(); ++i) {
         sums.local() +=  1 ;
     }
 }
Пример #3
0
 void operator()(const tbb::blocked_range<size_t>& r) {
    pReduce_->operator()(r.begin(), r.end());
 }
Пример #4
0
 void operator()( const tbb::blocked_range<size_t>& r ) const 
 {
     int begin = (int)r.begin();            //! capture lower range number for this chunk
     int end = (int)r.end();                //! capture upper range number for this chunk
     UpdateState(m_source, m_dest, begin, end);
 }
Пример #5
0
 void operator()( const tbb::blocked_range<int>& range ) const {
     Universe::Rectangle area(0, range.begin(), u_.UniverseWidth-1, range.size());
     u_.UpdateStress(area);
 }
Пример #6
0
void
SoftBody::MeshProcessor::operator ()(const tbb::blocked_range<uint32_t> r) const
{
    mBody.updateMesh(r.begin(), r.end());
}
Пример #7
0
	void ParallelParticleSystemUpdate::operator() (const tbb::blocked_range<int>& r) const
	{
		float currentTime = eagle.getTimer()->getPassedTimeSeconds();

		float frameTime = *m_particleEmitter->m_frameTime;
		float frictionEffect = 1.0f - (1.0f - m_particleEmitter->m_frictionFactor) * (frameTime);
		float aliveParticleAlphaDecrement = m_particleEmitter->m_alphaDecrement * (frameTime);
		float deadParticleAlphaDecrement = (m_particleEmitter->m_alphaDecrement + m_particleEmitter->m_removalAlphaDecrement) * (frameTime);

		for(int i = r.begin(); i != r.end(); ++i)
		{
			if(!m_particleList[i].enabled)
			{
				continue;
			}

			m_particleEmitter->aliveParticleCount++;

			//float lv = sqrt(m_particleList[i].m_velocityX * m_particleList[i].m_velocityX + m_particleList[i].m_velocityY * m_particleList[i].m_velocityY);
			/*float theta = atan2(m_particleList[i].m_velocityY, m_particleList[i].m_velocityX) + ((float)(math.random(0, 2) - 1)) * particleEmitter->m_noise;
			m_particleList[i].m_velocityX = cos(theta) * lv;
			m_particleList[i].m_velocityY = sin(theta) * lv;*/

			m_particleList[i].velocityX += ((float)(math.random(0, 2) - 1)) * m_particleEmitter->m_noise;
			m_particleList[i].velocityY += ((float)(math.random(0, 2) - 1)) * m_particleEmitter->m_noise;

			m_particleList[i].x += m_particleList[i].velocityX * (frameTime);
			m_particleList[i].y += m_particleList[i].velocityY * (frameTime);

			m_particleList[i].velocityX *= frictionEffect;
			m_particleList[i].velocityY *= frictionEffect;
			//m_particleList[i].z += m_particleList[i].speedZ;

			m_particleList[i].velocityX += m_particleList[i].accelerationX * (frameTime);
			m_particleList[i].velocityY += m_particleList[i].accelerationY * (frameTime);

			//colors[i].a = math.abs(colors[i].a);

			if(m_particleList[i].quickFade)
			{
				m_particleList[i].color.a -= deadParticleAlphaDecrement;
			}
			else
			{
				m_particleList[i].color.a -= aliveParticleAlphaDecrement;
			}

			//if((m_particleList[i].quickFade && m_particleList[i].color.a < 10) || m_particleList[i].color.a < 10)

			if(m_particleList[i].color.a < EAGLE_PARTICLE_SYSTEM_MINIMUM_PARTICLE_ALPHA)
			{
				m_particleList[i].enabled = 0;
				m_particleList[i].color.a = 0;

				m_particleEmitter->m_inactiveParticleListTopIndex++;

				m_particleEmitter->m_inactiveParticleList[m_particleEmitter->m_inactiveParticleListTopIndex] = i;

				continue;
			}
			else if(currentTime - m_particleList[i].creationTime > m_particleEmitter->m_lifespan)
			{
				m_particleList[i].quickFade = 1;

				continue;
			}
			else
			{
				int deltaX = m_particleList[i].x - m_particleEmitter->m_position.x;
				int deltaY = m_particleList[i].y - m_particleEmitter->m_position.y;

				if((deltaX) * (deltaX) + (deltaY) * (deltaY) > m_particleEmitter->m_maximumDistance * m_particleEmitter->m_maximumDistance)
				{
					m_particleList[i].quickFade = 1;

					continue;
				}
			}
		}
	}
Пример #8
0
 void operator()(const tbb::blocked_range<size_t>& r) const {
   for (size_t i=r.begin();i!=r.end();++i)
     _tasks[i]();
 }
Пример #9
0
 void operator()(const tbb::blocked_range<size_t>& r) const
 {
   checkPoints(r.begin(), r.end());
 }
Пример #10
0
 void operator ()(const tbb::blocked_range<int>& range) const
 {
     body->operator()(Range(range.begin(), range.end()));
 }
 /** Increments counter once for each iteration in the iteration space. */
 void operator()( tbb::blocked_range<size_t>& range ) const {
     for( size_t i=range.begin(); i!=range.end(); ++i ) {
         typename C::mutex_type::ScopedLock lock(counter.mutex);
         counter.value = counter.value+1;
     }
 }
Пример #12
0
void DoLerpParallel(const tbb::blocked_range<size_t>& r, const std::tr1::function<void(void*, const void*, const void*, float, size_t)>& func, void* dest, const void* source1, const void* source2, float alpha)
{
	size_t offset = r.begin()*STRIDE;
	size_t size = r.size()*STRIDE;
	func(reinterpret_cast<s8*>(dest) + offset, reinterpret_cast<const s8*>(source1) + offset, reinterpret_cast<const s8*>(source2) + offset, alpha, size);
}
Пример #13
0
    void operator()(const tbb::blocked_range<size_t> &range) const {
	for (size_t i = range.begin(); i != range.end(); ++i) {
	    (*f)(p[i]);
	}
	//for_each(range.begin(), range.end(), *f);
    }
 void operator()( const tbb::blocked_range<int>& range ) const {
     for( int i=range.begin(); i!=range.end(); ++i )
         Op::apply(my_table,i);
 }
Пример #15
0
void DoShuffleParallel(const tbb::blocked_range<size_t>& r, const std::tr1::function<void(void*, const void*, size_t, const u8, const u8, const u8, const u8)>& func, void* dest, const void* source, const u8 red, const u8 green, const u8 blue, const u8 alpha)
{
	size_t offset = r.begin()*STRIDE;
	size_t size = r.size()*STRIDE;
	func(reinterpret_cast<s8*>(dest) + offset, reinterpret_cast<const s8*>(source) + offset, size, red, green, blue, alpha);
}
Пример #16
0
 /*
  * The actual work is implemented into operator(), but the method has a body const.
  * It means we cannot change object members. They can be passed as raw pointers,
  * or marked mutable.
  */
 void operator() (const tbb::blocked_range<int>& range) const {
     for (int i = range.begin(); i < range.end(); i++) {
         m_data[i] = i;
     }
 }
Пример #17
0
    void operator()( const tbb::blocked_range<int>& r) const
    {
        for( int j = r.begin(); j < r.end(); ++j)
        {
            image::const_image_view_t::x_iterator top_it( src_.row_begin( std::max( j - 1, 0)));
            image::const_image_view_t::x_iterator center_it( src_.row_begin( j));
            image::const_image_view_t::x_iterator bottom_it( src_.row_begin( std::min( j + 1, (int) src_.height() - 1)));
            image::image_view_t::x_iterator dst_it( dst_.row_begin( j));

            image::pixel_t acc;

            // first pixel
            for( int k = 0; k < 3; ++k)
            {
                acc[k]  = (*top_it)[k] * k_[0][0];
                acc[k] += (*top_it)[k] * k_[0][1];
                acc[k] += top_it[1][k] * k_[0][2];

                acc[k] += (*center_it)[k] * k_[1][0];
                acc[k] += (*center_it)[k] * k_[1][1];
                acc[k] += center_it[1][k] * k_[1][2];

                acc[k] += (*bottom_it)[k] * k_[2][0];
                acc[k] += (*bottom_it)[k] * k_[2][1];
                acc[k] += bottom_it[1][k] * k_[2][2];

                acc[k] /= inv_sum_weights_;
            }

            *dst_it++ = acc;
            ++top_it;
            ++center_it;
            ++bottom_it;

            // loop
            for( int i = 1, e = src_.width() - 1; i < e; ++i)
            {
                for( int k = 0; k < 3; ++k)
                {
                    acc[k]  = top_it[-1][k] * k_[0][0];
                    acc[k] += ( *top_it)[k] * k_[0][1];
                    acc[k] += top_it[ 1][k] * k_[0][2];

                    acc[k] += center_it[-1][k] * k_[1][0];
                    acc[k] += ( *center_it)[k] * k_[1][1];
                    acc[k] += center_it[ 1][k] * k_[1][2];

                    acc[k] += bottom_it[-1][k] * k_[2][0];
                    acc[k] += ( *bottom_it)[k] * k_[2][1];
                    acc[k] += bottom_it[ 1][k] * k_[2][2];

                    acc[k] /= inv_sum_weights_;
                }

                *dst_it++ = acc;
                ++top_it;
                ++center_it;
                ++bottom_it;
            }

            // last pixel
            for( int k = 0; k < 3; ++k)
            {
                acc[k]  = top_it[-1][k] * k_[0][0];
                acc[k] += ( *top_it)[k] * k_[0][1];
                acc[k] += ( *top_it)[k] * k_[0][2];

                acc[k] += center_it[-1][k] * k_[1][0];
                acc[k] += ( *center_it)[k] * k_[1][1];
                acc[k] += ( *center_it)[k] * k_[1][2];

                acc[k] += bottom_it[-1][k] * k_[2][0];
                acc[k] += ( *bottom_it)[k] * k_[2][1];
                acc[k] += ( *bottom_it)[k] * k_[2][2];

                acc[k] /= inv_sum_weights_;
            }

            *dst_it = acc;
        }
    }
Пример #18
0
 // Note: we use <int> here instead of <long> in order to test for Quad 407676
 void operator()( const tbb::blocked_range<int>& r ) const {
     for( tbb::blocked_range<int>::const_iterator i=r.begin(); i!=r.end(); ++i )
         ++Array[i];
 }
Пример #19
0
 /** Increments counter once for each iteration in the iteration space. */
 void operator()( tbb::blocked_range<size_t>& range ) const {
     for( size_t i=range.begin(); i!=range.end(); ++i ) {
         //! Every 8th access is a write access
         bool write = (i%8)==7;
         bool okay = true;
         bool lock_kept = true;
         if( (i/8)&1 ) {
             // Try implicit acquire and explicit release
             typename I::mutex_type::scoped_lock lock(invariant.mutex,write);
             if( write ) {
                 long my_value = invariant.value[0];
                 invariant.update();
                 if( i%16==7 ) {
                     lock_kept = lock.downgrade_to_reader();
                     if( !lock_kept )
                         my_value = invariant.value[0] - 1;
                     okay = invariant.value_is(my_value+1);
                 }
             } else {
                 okay = invariant.is_okay();
                 if( i%8==3 ) {
                     long my_value = invariant.value[0];
                     lock_kept = lock.upgrade_to_writer();
                     if( !lock_kept )
                         my_value = invariant.value[0];
                     invariant.update();
                     okay = invariant.value_is(my_value+1);
                 }
             }
             lock.release();
         } else {
             // Try explicit acquire and implicit release
             typename I::mutex_type::scoped_lock lock;
             lock.acquire(invariant.mutex,write);
             if( write ) {
                 long my_value = invariant.value[0];
                 invariant.update();
                 if( i%16==7 ) {
                     lock_kept = lock.downgrade_to_reader();
                     if( !lock_kept )
                         my_value = invariant.value[0] - 1;
                     okay = invariant.value_is(my_value+1);
                 }
             } else {
                 okay = invariant.is_okay();
                 if( i%8==3 ) {
                     long my_value = invariant.value[0];
                     lock_kept = lock.upgrade_to_writer();
                     if( !lock_kept )
                         my_value = invariant.value[0];
                     invariant.update();
                     okay = invariant.value_is(my_value+1);
                 }
             }
         }
         if( !okay ) {
             REPORT( "ERROR for %s at %ld: %s %s %s %s\n",invariant.mutex_name, long(i),
                          write?"write,":"read,", write?(i%16==7?"downgrade,":""):(i%8==3?"upgrade,":""),
                          lock_kept?"lock kept,":"lock not kept,", (i/8)&1?"imp/exp":"exp/imp" );
         }
     }
 }
Пример #20
0
 void operator()( const tbb::blocked_range<int>& y_range ) const {
     u_.UpdateVelocity(Universe::Rectangle(1,y_range.begin(),u_.UniverseWidth-1,y_range.size()));
 }
Пример #21
0
 void operator()( const tbb::blocked_range<size_t>& r) const
 {
     for( std::size_t i = r.begin(), e = r.end(); i != e; ++i)
         std::copy( src_.row_begin(i), src_.row_end(i), dst_.row_begin(i));
 }
Пример #22
0
		void operator() ( const tbb::blocked_range<int>& range ) const {
			for ( int i = range.begin(); i != range.end(); ++i ) {
				output[i] = (input[i-1]+input[i]+input[i+1])*(1/3.f);
			}
		}
Пример #23
0
 void operator()( const tbb::blocked_range<size_t> &r ) const
 {
     for( size_t x=r.begin(); x<r.end(); x++ ) {
         Body( x );
     }
 }
Пример #24
0
 void operator()(tbb::blocked_range<long> const & range) {
   for (auto i = range.begin(); i != range.end(); ++i) {
     auto const x = (i - 0.5) * delta;
     sum += 1.0 / (1.0 + x * x);
   }
 }
Пример #25
0
 void operator()( tbb::blocked_range<size_t>& range ) const {
     typename C::mutex_type::scoped_lock lock(counter.mutex);
     recurse_till( range.begin(), range.end() );
 }
Пример #26
0
 ValueType operator() ( const tbb::blocked_range<ValueType*>& r, ValueType value ) const {
     for ( ValueType* pv = r.begin(); pv != r.end(); ++pv )
         value += *pv;
     return value;
 }
 void operator()( const tbb::blocked_range<int> &r ) const {
     for (int i = r.begin(); i != r.end(); ++i) 
         test_helper<T>::sum( sums.local(), 1 );
 }
 /**
  * @brief operator () This is called from the TBB stye of code
  * @param r The range to compute the values
  */
 void operator()(const tbb::blocked_range<size_t>& r) const
 {
   generate(r.begin(), r.end());
 }
Пример #29
0
 void operator()(const tbb::blocked_range<int64_t>& r) const
 {
   compute(r.begin(), r.end());
 }