コード例 #1
0
	// Processing operator - in real life processes data for the range defined by 'r'
	//
	// This just calls TestThread.callback(r.begin(), r.end())
	// Designed to be called on any thread
	//
	void operator() (const blocked_range<int>& r ) const {
		// printf("operator() %d->%d\n", r.begin(), r.end());

		// Attach the current thread to the JVM, allowing access to the JVM environment through 'thrdEnv'
		JNIEnv *thrdEnv;
		jvm->AttachCurrentThread ((void **) &thrdEnv, NULL);

		// Get the TestThread instance as a jclass
		jclass cls = thrdEnv->GetObjectClass(testThread);
		if(cls==0) {
			fprintf(stderr, "GetObjectClass returned null\n");
			return;
		}

		// Get the method id for 'void TestThread.callback(int, int)'
		jmethodID mid = thrdEnv->GetMethodID(cls, "callback", "(II)V");
		if(mid==0) {
			fprintf(stderr, "GetMethodID returned null\n");
			return;
		}

		// Now call the actual method
		jint s = r.begin();
		jint e = r.end();
		thrdEnv->CallVoidMethod(testThread, mid, s, e );

		// And detach our thread
		jvm->DetachCurrentThread();
	};
コード例 #2
0
 void operator()( const blocked_range<MyString*> range ) const {
     for( MyString* p=range.begin(); p!=range.end(); ++p ) {
         StringTable::accessor a;
         table.insert( a, *p );
         a->second += 1;
     }
 }
コード例 #3
0
 void operator()( const blocked_range<int*>& r ) {
     int temp = value;
     for( int* a=r.begin(); a!=r.end(); ++a ) {
         temp += *a;
     }
     value = temp;
 }
コード例 #4
0
	void operator()( const blocked_range<int>& range ) const
	{
		for( int i=range.begin(); i!=range.end(); ++i )
		{
			(*proc)(tiles[i],ImgRef1,ImgRef2,FeatMat);
		}
	}
コード例 #5
0
 void operator() (const blocked_range<int>& range) const{
   int begin=range.begin();
   begin++;
   for ( int i = begin; i<=range.end(); ++i){
      input[i]=input[i-1]+input[i];
   }
 }
コード例 #6
0
ファイル: som.cpp プロジェクト: adiog/tbb
void
SOMap::epoch_update_range( SOM_element const &s, int epoch, int min_x, int min_y, double radius, double learning_rate, blocked_range<int> &r) {
    int min_xiter = (int)((double)min_x - radius);
    if(min_xiter < 0) min_xiter = 0;
    int max_xiter = (int)((double)min_x + radius);
    if(max_xiter > (int)my_map.size()-1) max_xiter = (int)my_map.size()-1;
    for(int xx = r.begin(); xx <= r.end(); ++xx) {
        double xrsq = (xx-min_x)*(xx-min_x);
        double ysq = radius*radius - xrsq;  // max extent of y influence
        double yd;
        if(ysq > 0) {
            yd = sqrt(ysq);
            int lb = (int)(min_y - yd);
            int ub = (int)(min_y + yd);
            for(int yy = lb; yy < ub; ++yy) {
                if(yy >= 0 && yy < (int)my_map[xx].size()) {
                    // [xx, yy] is in the range of the update.
                    double my_rsq = xrsq + (yy-min_y)*(yy-min_y);  // distance from BMU squared
                    double theta = exp(-(radius*radius) /(2.0* my_rsq)); 
                    add_fraction_of_difference(my_map[xx][yy], s, theta * learning_rate);
                }
            }
        }
    }
}
コード例 #7
0
ファイル: maximizer.cpp プロジェクト: Twizanex/bellman
  void operator_2( const blocked_range<size_t>& r ) {   
	double value;
	IntVector indexArray(m_lenArray.size());
	DoubleVector argArray(m_lenArray.size());	
    Index1DToArray(r.begin(), m_lenArray, indexArray);

	int nStride0 = m_ControlGridArray[0].strides()[0];
	const char *pBegin0 = (const char*) (m_ControlGridArray[0].array().data());
	const char *pEnd0 = pBegin0 + (nStride0 * m_lenArray[0]);
	const char *pData0 = pBegin0 + (nStride0 * indexArray[0]);
	int nStride1 = m_ControlGridArray[1].strides()[0];
	const char *pBegin1 = (const char*) (m_ControlGridArray[1].array().data());
	const char *pEnd1 = pBegin1 + (nStride1 * m_lenArray[1]);
	const char *pData1 = pBegin1 + (nStride1 * indexArray[1]);
	
    for( size_t index=r.begin(); index!=r.end(); ++index ){
      argArray[0] = * (double*) pData0;
	  argArray[1] = * (double*) pData1;

  	  value = m_params.objectiveFunction(argArray);	  
      if (value > m_value_of_max) {
        m_value_of_max = value;
		m_argmax = argArray;
      }

	  pData1 += nStride1;
	  if (pData1 == pEnd1) {
	    pData1 = pBegin1;
	    pData0 += nStride0;
	  }	  
    }
  }
コード例 #8
0
ファイル: P1_Collatz.cpp プロジェクト: stefan0x53/sparrow
    void operator() (const blocked_range<uint64>& r)
    {
        const size_t size = v.size();
        const size_t size2 = 2*size;
        for ( uint64 i=r.begin(); i<r.end(); ++i )
        {
            int len = 1;
            uint64 n = i;
            while ( n != 1 )
            {
                if ( n % 2 == 0 )
                {
                    n = n/2;
                    if ( n<size2 )
                    {
                        len += v[size_t(n - size)];
                        break;
                    }
                }
                else
                    n = 3*n + 1;

                ++len;
            }
            updateResult(res, i, len);
        }
    }
コード例 #9
0
ファイル: P1_Collatz.cpp プロジェクト: stefan0x53/sparrow
    void operator() (const blocked_range<uint64>& r)
    {
        const size_t size = v.size();
        for ( uint64 i=r.begin(); i<r.end(); ++i )
        {
            int len = 1;
            uint64 n = i;
            while ( n != 1 )
            {
                if ( n % 2 == 0 )
                {
                    n = n/2;
                    if ( n<size )
                    {
                        // TODO: Remove if here
                        const short len1 = -v[size_t(n)];
                        if ( len1 > 0 )
                        {
                            len += len1;
                            break;
                        }
                    }
                }
                else
                    n = 3*n + 1;

                ++len;
            }
            updateResult(res, i, len);
        }
    }
コード例 #10
0
                void operator()(const blocked_range<int>& r) const {
                	char tempChar = ciChar;
                	for(int i = r.begin(); i!= r.end(); i++) {
                        	tempChar = tempChar ^ getBit((&list[i]),loop); 	
                        }
				cyText[loop] = tempChar;
  	           
                 }
コード例 #11
0
ファイル: raytracer.cpp プロジェクト: rxtsolar/rtanimate
void Render::operator()(const blocked_range<int>& r) const
{
	for (int j = r.begin(); j != r.end(); j++) {
		for (int i = 0; i < rt->cam.pw; i++) {
			rt->getPixel(i, j);
		}
	}
}
コード例 #12
0
ファイル: pnp_ransac.cpp プロジェクト: RoboWGT/robo_groovy
 void operator()( const blocked_range<size_t>& r ) const {
     for( size_t i=r.begin(); i!=r.end(); ++i )
     {
     	Iterate(*object_points, *image_points, *camera_matrix, *dist_coeffs,
     	        *resultRvec, *resultTvec, max_dist, min_inlier_num,
     	        inliers, use_extrinsic_guess, rvecInit, tvecInit, *rng, ResultsMutex);
     }
 }
コード例 #13
0
 void operator() (const blocked_range<int>& range) const 
 {
     for (int i = range.begin(); i < range.end(); i++) {
         int sum = 0; 
         for (int j = 0; j < rep; j++) 
             sum += func(j);
         v[i] = sum;
     }
 }
コード例 #14
0
ファイル: shortpath.cpp プロジェクト: YoonJungsik/Kinect
 void operator() (blocked_range<size_t>& r) const {
     utility::FastRandom my_random((unsigned int)r.begin());
     for (size_t i=r.begin(); i!=r.end(); ++i) {
         for (size_t j=0; j<i; ++j) {
             if (die_toss(i, j, my_random))
                 edges[i].push_back(j);
         }
     }
 }
コード例 #15
0
			void operator()( const blocked_range<size_t> &r ) const
			{
				Imath::Rand32 rand;
				for( size_t i=r.begin(); i!=r.end(); ++i )
				{
					std::string s = lexical_cast<std::string>( rand.nexti() % 1000 );
					InternedString ss( s );
				}
			}
コード例 #16
0
ファイル: Fibonacci.cpp プロジェクト: artog/Raytracer
 void operator()( const blocked_range<int> &r, Tag tag) {
     for( int k = r.begin(); k < r.end(); ++k ) {
         // Code performs an "exclusive" scan, which outputs a value *before* updating the product.
         // For an "inclusive" scan, output the value after the update.
         if( tag.is_final_scan() )
             output[k] = product.v[0][1];
         product = product * Matrix1110;
     }
 }
コード例 #17
0
ファイル: radix.tbb.cpp プロジェクト: Goon83/parallel-sort
		void operator()(const blocked_range<uint>& r) const {
			for(uint i=r.begin(); i!=r.end(); ++i) {
				uint base_index = c->bucket_accum[i];

				for(uint elem=0; elem < c->buckets[i].size(); ++elem) {
					(*(c->arr))[base_index + elem] = c->buckets[i][elem];
				}
			}
		}
コード例 #18
0
void operator() (blocked_range<size_t>&r)const
{
double *vA,*vB,*vR;
vA=vectA;
vB=vectB;
vR=resultVect;
for(size_t count=r.begin();count!=r.end();count++)
vR[count]=vA[count]*vB[count];
}
コード例 #19
0
ファイル: minind.cpp プロジェクト: mindis/cpp-learn
  void operator()(blocked_range<size_t>&r) {
    const float *a = array;
    for (size_t i = r.begin();  i != r.end(); ++i) {
      float value = array[i];
      if (value < value_of_min) {
	value_of_min = value;
	ind_of_min = i;
      }
    }
  }
コード例 #20
0
 void operator()(const blocked_range<size_t>& r)
 {
     double rectWidth = * my_rects;
     double x;
     for(size_t i = r.begin(); i != r.end(); ++i)
     {
         x = (i + 0.5) * rectWidth;
         partialHeight += 4.0 / (1.0 + x * x );
     }
 }
コード例 #21
0
ファイル: reduce.cpp プロジェクト: MagnusTiberius/code
  void operator() (blocked_range<size_t> const& r)
  {
    float* arr = m_arr;
    float  sum = m_sum;
    size_t end = r.end();
    for (size_t i=r.begin(); i!=end; ++i)
      sum += Foo(arr[i]);

    m_sum = sum;
  }
コード例 #22
0
 void operator()(const blocked_range<long long>& range, Tag) 
 {
   long long tmp = this->reduced_result;
   for (size_t i = range.begin(); i != range.end(); i++) {
     tmp = op(tmp, inputData[ i ]);
     if (Tag::is_final_scan()) 
       results[i] = tmp;
   }
   this->reduced_result = tmp;
 }
コード例 #23
0
ファイル: test_openmp.cpp プロジェクト: Zer0code/LoLUpdater
    void operator()( const blocked_range<int>& range ) const {
        for( int i=range.begin(); i!=range.end(); ++i ) {
            int start = i<n ? 0 : i-n+1;
            int finish = i<m ? i+1 : m; 
            T sum = 0;
#pragma omp parallel for reduction(+:sum)
            for( int j=start; j<finish; ++j ) 
                sum += my_a[j]*my_b[i-j];
            my_c[i] = sum;
        }
    }
コード例 #24
0
 void operator() (const blocked_range<int>& currpass) const{
     char passmatch[9];
     int found;
     for ( int i = currpass.begin(); i!=currpass.end(); ++i){
         PassTbb::genpass(i,passmatch);
         found=PassTbb::test(arg, passmatch);
         if(found==0) {
             printf("found: %s\n",passmatch);
         }
     }
 }
コード例 #25
0
ファイル: TBBCode.cpp プロジェクト: Chalenko/PCM
		void operator()(const blocked_range<int>& r) const{
			int begin = r.begin(), end = r.end();
			for (int i = begin; i < end; i++){
				for (int j = 0; j < src2w; j++){
					const double *vec1, *vec2;
					vec1 = &(A[i*src1w]);
					vec2 = &(B[j*src1w]);
					dst[i * src2w + j] = TBBSclMlt(vec1, vec2, src1w);
				}
			}
		}
コード例 #26
0
ファイル: time_tbbq_sizes.cpp プロジェクト: Agobin/chapel
    void operator() (const blocked_range<size_t>&r) const
    {
        size_t begin = r.begin();
        size_t end = r.end();

        for (size_t i = begin; i < end; i++) {
            void * tmp = tbballoc.allocate(1);
            memset(tmp, 1, objsize);
            cq.push(tmp);
        }
    }
コード例 #27
0
 void operator()(const blocked_range<int>& r, Tag)
 {
     T temp = reduced_result;
     for (int i = r.begin(); i < r.end(); i++)
     {
         temp += x[i];
         if (Tag::is_final_scan())
             y[i] = temp;
     }
     reduced_result = temp;
 }
コード例 #28
0
 void operator()( const blocked_range<size_t>& r, size_t thdId ) const {
   //RecordMem(thdId, &ctr, READ);
   //RecordMem(thdId, &ctr, WRITE);
   ctr++;
   float *a = my_a;
   for( size_t i=r.begin(); i!=r.end(); ++i ) { 
     a[i] = sqrt(a[i]);
     a[i] += 23;
     a[i] *= 34;
     a[i] -= 234;
   }
 }
コード例 #29
0
ファイル: radix.tbb.cpp プロジェクト: Goon83/parallel-sort
		void operator()(const blocked_range<uint>& r) const {
			for(uint i = 0; i < c->arr->size(); ++i) {
				uint elem = (*(c->arr))[i];
				uint bucket = GET_BUCKET_NUM(elem, c->mask, c->g, c->round);

				for(uint b=r.begin(); b!=r.end(); ++b)
					if (b == bucket) {
						c->buckets[bucket].push_back(elem);	
						break;
					}
			}
		}
コード例 #30
0
			void operator()( const blocked_range<size_t> &r ) const
			{
				for( size_t i=r.begin(); i!=r.end(); ++i )
				{
					int value = int(i) % 500;
					ConstObjectPtr r = m_cache.get( ComputationParams(value) );
					ConstIntDataPtr k = runTimeCast< const IntData >(r);
					// can't use boost unit test assertions from threads
					assert( k.get() );
					assert( k->readable() == value );
				}
			}