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; } } }
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); } } }
void operator() (const blocked_range<int>& range) const { double di, dj; int i, j; double tarw = 1.0; double pixpitch = tarw/(double)width; unsigned char pa = 0; vector mainvector = m; //color *Color = c; color *Color = (color*)malloc(sizeof(color)); //color *diffuse = (color*)malloc(sizeof(color)); color diffuse; for (i = range.begin(); i != range.end(); i++) for (j = 0; j < height; j++) { Color->g = 0; diffuse.g = 0; di = (double)i; dj = (double)j; vector side; side.x = mainvector.y; side.y = -mainvector.x; side.z = 0.0; vector up; cross(up, mainvector, side); normalize(side, (di - (double)width/2.0)*pixpitch); normalize(up, (dj - (double)height/2.0)*pixpitch); vector ray; ray.x = Model.cameratarget.x + side.x + up.x - Model.camera.x; ray.y = Model.cameratarget.y + side.y + up.y - Model.camera.y; ray.z = Model.cameratarget.z + side.z + up.z - Model.camera.z; vector tempray; tempray.x = ray.x; tempray.y = ray.y; tempray.z = ray.z; raytrace( Color, Model.camera, ray, -1, 0, -1); if (Color->g < DIFFUSECOLORTHRESHOLD) { diffusetrace(&diffuse, Model.camera, tempray, -1, 0 , -1); Color->g += diffuse.g; } //Color->g += diffuse.g; if (Color->g >1) Color -> g = 1; pa = (unsigned char)(Color->g*255); //unsigned char pa = Color->g*255; memcpy(&pictureArray[i][j],&pa,sizeof(unsigned char)); } printf("processing %d - %d x %d \n", range.begin(), range.end(), height ); }
void operator_cp( const blocked_range<size_t>& r ) { char *pData = NULL; double value; CartesianProductIterator iter(m_ControlGridArray, r.begin()); CartesianProductIterator end(m_ControlGridArray, r.end()); for( size_t index=r.begin(); index!=r.end(); ++index, iter++ ){ value = m_params.objectiveFunction(*iter); if (value > m_value_of_max) { m_value_of_max = value; m_argmax = *iter; } } }
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); } }
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); } }
void operator()( const blocked_range<int*>& r ) { int temp = value; for( int* a=r.begin(); a!=r.end(); ++a ) { temp += *a; } value = temp; }
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; } }
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); } } } } }
// 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(); };
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]; } }
void operator()( const blocked_range<int>& range ) const { for( int i=range.begin(); i!=range.end(); ++i ) { (*proc)(tiles[i],ImgRef1,ImgRef2,FeatMat); } }
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; }
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); } }
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); } } }
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 ); } }
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]; } } }
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; } }
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; } }
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]; }
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; }
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 ); } }
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; }
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; } } }
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; } }
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; }
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); } } }
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); } } }
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); } }
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; } }