• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parallel_for函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parallel_for函数的典型用法代码示例。如果您正苦于以下问题:C++ parallel_for函数的具体用法?C++ parallel_for怎么用?C++ parallel_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parallel_for函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ViewDefaultConstruct

 ViewDefaultConstruct( type * pointer , size_t capacity )
   : m_ptr( pointer )
 {
   Kokkos::RangePolicy< ExecSpace > range( 0 , capacity );
   parallel_for( range , *this );
   ExecSpace::fence();
 }
开发者ID:rainiscold,项目名称:trilinos,代码行数:7,代码来源:task_view.hpp


示例2: createEquivalentISPC

  int GhostBlockBrickedVolume::setRegion(
      // points to the first voxel to be copied. The voxels at 'source' MUST
      // have dimensions 'regionSize', must be organized in 3D-array order, and
      // must have the same voxel type as the volume.
      const void *source,
      // coordinates of the lower, left, front corner of the target region
      const vec3i &regionCoords,
      // size of the region that we're writing to, MUST be the same as the
      // dimensions of source[][][]
                                    const vec3i &regionSize)
  {
    // Create the equivalent ISPC volume container and allocate memory for voxel
    // data.
    if (ispcEquivalent == nullptr)
      createEquivalentISPC();

    /*! \todo check if we still need this 'computevoxelrange' - in
        theory we need this only if the app is allowed to query these
        values, and they're not being set in sharedstructuredvolume,
        either, so should we actually set them at all!? */
    // Compute the voxel value range for unsigned byte voxels if none was
    // previously specified.
    Assert2(source,"nullptr source in GhostBlockBrickedVolume::setRegion()");

#ifndef OSPRAY_VOLUME_VOXELRANGE_IN_APP
    if (findParam("voxelRange") == NULL) {
      // Compute the voxel value range for float voxels if none was
      // previously specified.
      const size_t numVoxelsInRegion
        = (size_t)regionSize.x *
        + (size_t)regionSize.y *
        + (size_t)regionSize.z;
      if (voxelType == "uchar")
        computeVoxelRange((unsigned char *)source, numVoxelsInRegion);
      else if (voxelType == "ushort")
        computeVoxelRange((unsigned short *)source, numVoxelsInRegion);
      else if (voxelType == "float")
        computeVoxelRange((float *)source, numVoxelsInRegion);
      else if (voxelType == "double")
        computeVoxelRange((double *) source, numVoxelsInRegion);
      else {
        throw std::runtime_error("invalid voxelType in "
                                 "GhostBlockBrickedVolume::setRegion()");
      }
    }
#endif
    // Copy voxel data into the volume.
    const int NTASKS = regionSize.y * regionSize.z;

    parallel_for(NTASKS, [&](int taskIndex){
        ispc::GBBV_setRegion(ispcEquivalent,
                             source,
                             (const ispc::vec3i &)regionCoords,
                             (const ispc::vec3i &)regionSize,
                             taskIndex);
    });

    return true;
  }
开发者ID:JasonWinston,项目名称:OSPRay,代码行数:59,代码来源:GhostBlockBrickedVolume.cpp


示例3: apply

  static void apply( const value_type&   alpha ,
		     const vector_type & x ,
		     const value_type &  beta ,
                     const vector_type & y )
  {
    const size_t row_count = x.dimension_0() ;
    parallel_for( row_count , Update(alpha,x,beta,y) );
  }
开发者ID:00liujj,项目名称:trilinos,代码行数:8,代码来源:Kokkos_Multiply.hpp


示例4: ISPCLaunch

 __dllexport void ISPCLaunch(void** taskPtr, void* func, void* data, int count) 
 {      
   parallel_for(size_t(0), size_t(count),[&] (const range<size_t>& r) {
       const size_t threadIndex = tbb::task_arena::current_thread_index();
       const size_t threadCount = tbb::task_scheduler_init::default_num_threads();
       for (size_t i=r.begin(); i<r.end(); i++) ((TaskFuncType)func)(data,threadIndex,threadCount,i,count);
     });
 }
开发者ID:davenso,项目名称:embree,代码行数:8,代码来源:tasksys.cpp


示例5: parallel_for

void parallel_for(loop_by_eager_binary_splitting<control_by_prediction>& lpalgo,
                  const Loop_complexity_measure_fct& loop_compl_fct,
                  Number lo, Number hi, const Body& body) {
  auto loop_cutoff_fct = [] (Number lo, Number hi) {
    todo();
    return false;
  };
  parallel_for(lpalgo, loop_cutoff_fct, loop_compl_fct, lo, hi, body);
}
开发者ID:deepsea-inria,项目名称:predict,代码行数:9,代码来源:granularity.cpp


示例6: axpby

void axpby( const ConstScalarType & alpha ,
            const ConstVectorType & X ,
            const ConstScalarType & beta ,
            const      VectorType & Y )
{
  typedef AXPBY< ConstScalarType , ConstVectorType , VectorType > functor ;

  parallel_for( Y.dimension_0() , functor( alpha , X , beta , Y ) );
}
开发者ID:ArchRobison,项目名称:kokkos,代码行数:9,代码来源:PerfTestBlasKernels.hpp


示例7: sample_primary_rays

void sample_primary_rays(const Camera &camera,
                         const BufferView<CameraSample> &samples,
                         BufferView<Ray> rays,
                         BufferView<RayDifferential> ray_differentials,
                         bool use_gpu) {
    parallel_for(primary_ray_sampler{
        camera, samples.begin(), rays.begin(), ray_differentials.begin()},
        samples.size(), use_gpu);
}
开发者ID:mtlong,项目名称:redner,代码行数:9,代码来源:camera.cpp


示例8: Multiply

 Multiply( const matrix_type & A ,
           const size_type nrow ,
           const size_type , // ncol ,
           const vector_type & x ,
           const vector_type & y )
   : m_A( A ), m_x( x ), m_y( y )
 {
   parallel_for( nrow , *this );
 }
开发者ID:gitter-badger,项目名称:quinoa,代码行数:9,代码来源:SparseLinearSystem.hpp


示例9: testThreadedGet

	void testThreadedGet()
	{

		Cache cache( get, hash, 10000, new ObjectPool(10000) );
		
		parallel_for( blocked_range<size_t>( 0, 10000 ), GetFromCache( cache ) );

		BOOST_CHECK_EQUAL( size_t(500), cache.cachedComputations() );
	}
开发者ID:Shockspot,项目名称:cortex,代码行数:9,代码来源:ComputationCacheTest.cpp


示例10: ISPCLaunch

 extern "C" __dllexport void ISPCLaunch(void** taskPtr, void* func, void* data, int count)
 {
   parallel_for(0, count,[&] (const range<int>& r) {
       const int threadIndex = (int) TaskScheduler::threadIndex();
       const int threadCount = (int) TaskScheduler::threadCount();
       for (int i=r.begin(); i<r.end(); i++)
         ((ISPCTaskFunc)func)(data,threadIndex,threadCount,i,count);
     });
 }
开发者ID:karimnaaji,项目名称:aobaker,代码行数:9,代码来源:tasksys.cpp


示例11: put_all_files

void put_all_files(leveldb::DB* db, const std::vector<std::string>& files,
                   int concurrency) {
  auto errors = parallel_for(concurrency, serial_read_files, files, db);

  for (bool err : errors)
    if (err) {
      std::cerr << "Errors occured!" << std::endl;
      std::exit(1);
    }
}
开发者ID:Alex223124,项目名称:COS513-Finance,代码行数:10,代码来源:leveldb_feeder.cpp


示例12: dmdvmult

// dense matrix by dense vector multiplication: d := m * v
// r: # rows in m; c # columns in m
static
void dmdvmult(long r, long c, const float* m, const float* v, float* d) {
  auto outer_loop_compl_fct = [c] (long lo, long hi) {
    return (hi - lo) * c;
  };
  parallel_for(outerlp, outer_loop_compl_fct, 0l, r, [&] (long i) {
    const float* row_i = &m[i*c];
    d[i] = ddotprod(innerlp, r, 0.0f, row_i, v);
  });
}
开发者ID:deepsea-inria,项目名称:predict,代码行数:12,代码来源:granularity.cpp


示例13: parallel_for

 void NativeCurvesISA::commit_helper()
 {
   if (native_curves.size() != curves.size()) 
   {
     native_curves = APIBuffer<unsigned>(scene->device,curves.size(),sizeof(unsigned int),true);
     parallel_for(size_t(0), curves.size(), size_t(1024), [&] ( const range<size_t> r) {
         for (size_t i=r.begin(); i<r.end(); i++) {
           if (curves[i]+3 >= numVertices()) native_curves[i] = 0xFFFFFFF0; // invalid curves stay invalid this way
           else                              native_curves[i] = unsigned(4*i);
         }
       });
   }
   
   if (native_vertices.size() != vertices.size())
     native_vertices.resize(vertices.size());
   
   parallel_for(vertices.size(), [&] ( const size_t i ) {
       
       if (native_vertices[i].size() != 4*curves.size())
         native_vertices[i] = APIBuffer<Vec3fa>(scene->device,4*curves.size(),sizeof(Vec3fa),true);
       
       parallel_for(size_t(0), curves.size(), size_t(1024), [&] ( const range<size_t> rj ) {
           
           for (size_t j=rj.begin(); j<rj.end(); j++)
           {
             const unsigned id = curves[j];
             if (id+3 >= numVertices()) continue; // ignore invalid curves
             const Vec3fa v0 = vertices[i][id+0];
             const Vec3fa v1 = vertices[i][id+1];
             const Vec3fa v2 = vertices[i][id+2];
             const Vec3fa v3 = vertices[i][id+3];
             const InputCurve3fa icurve(v0,v1,v2,v3);
             OutputCurve3fa ocurve; convert<Vec3fa>(icurve,ocurve);
             native_vertices[i].store(4*j+0,ocurve.v0);
             native_vertices[i].store(4*j+1,ocurve.v1);
             native_vertices[i].store(4*j+2,ocurve.v2);
             native_vertices[i].store(4*j+3,ocurve.v3);
           }
         });
     });
   native_vertices0 = native_vertices[0];
 }
开发者ID:karimnaaji,项目名称:aobaker,代码行数:42,代码来源:scene_bezier_curves.cpp


示例14: apply

  static void apply( const mesh_type  & mesh ,
                     const elem_matrices_type & elem_matrices ,
                     const elem_vectors_type  & elem_vectors ,
                     const scalar_type  elem_coeff_K ,
                     const scalar_type  elem_coeff_Q )
  {
    ElementComputation comp( mesh , elem_matrices , elem_vectors , elem_coeff_K , elem_coeff_Q );
    const size_t elem_count = mesh.elem_node_ids.dimension_0();

    parallel_for( elem_count , comp );
  }
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:11,代码来源:ImplicitFunctors.hpp


示例15: ret

std::vector<sframe> subplan_executor::run(
    const std::vector<std::shared_ptr<planner_node>>& stuff_to_run_in_parallel,
    const materialize_options& exec_params) {

  std::vector<sframe> ret(stuff_to_run_in_parallel.size()); 

  parallel_for(0, stuff_to_run_in_parallel.size(), [&](const size_t i) {
      ret[i] = run(stuff_to_run_in_parallel[i], exec_params);
  });

  return ret; 
}
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:12,代码来源:subplan_executor.cpp


示例16: parallel_for

 size_t lualambda_master::make_lambda(const std::string& lambda_str) {
   size_t lambda_hash = std::hash<std::string>()(lambda_str);
   std::string newstr = lambda_str;
   if (boost::starts_with(newstr,"LUA")) {
     newstr = newstr.substr(3);
   }
   parallel_for (0, num_workers(), [&](size_t i) {
     clients[i]->doString(newstr);
     clients[i]->doString("lambda" + std::to_string(lambda_hash) + " = __lambda__transfer__");
   });
   return lambda_hash;
 }
开发者ID:Hannah1999,项目名称:Dato-Core,代码行数:12,代码来源:lualambda_master.cpp


示例17: printf

void FractalRenderer::performRendering(void)
{
	printf("data=%p, width=%d, heigth=%d, zoom=%f, resolution=%d, posx=%f, posy=%f\n",
		   m_data, m_image_x, m_image_y, m_scale, m_resolution, m_normalizedPosition.x, m_normalizedPosition.y);
	
	sf::Clock timer;
	parallel_for(tbb::blocked_range2d<unsigned, unsigned>(0, m_image_x, 50, 0, m_image_y, 50),
				 MandelbrotRenderer(m_data, m_image_x, m_image_y, m_scale, m_resolution, m_normalizedPosition));
	
	m_texture.update(m_data);
	m_lastRenderingTime = timer.getElapsedTime();
}
开发者ID:Yalir,项目名称:FractalExplorer,代码行数:12,代码来源:FractalRenderer.cpp


示例18: reduce_floats

void reduce_floats() {
  srand(time(NULL));
  const int numStars = 5000;
  star* array_of_structs = new star[numStars];
  stars struct_of_arrays(numStars);
  populate_star_array(array_of_structs, numStars);
  populate_stars(&struct_of_arrays);

  cout << "map pattern with arrays-of-structures" << endl;
  cout << "and structures-of-arrays" << endl;
  cout << "----------------------------------------" << endl;
  cout << "calculating longitude from right ascension of stars" << endl;

  auto get_longitude = [](const double ascension) {
    const double degrees = ascension * 15.0;
    const double adjusted_degrees = degrees > 360.0 ? degrees - 180.0 : degrees;
    return adjusted_degrees;
  };

  double output[numStars];
  const int numIterations = 10;

  clock_t start = clock();
  for(int i = 0, end = numIterations; i != end; ++i) {
    parallel_for(0, numStars, 1, [&struct_of_arrays, &output, get_longitude](int i) {
        output[i] = get_longitude(struct_of_arrays.ascension[i]);
      });
  }
  double seconds = (clock() - start) / (double)CLOCKS_PER_SEC;
  cout << "structure-of-arrays: " << seconds << " seconds." << endl;

  start = clock();
  for(int i = 0, end = numIterations; i != end; ++i) {
    parallel_for(0, numStars, 1, [&array_of_structs, &output, get_longitude](int i) {
        output[i] = get_longitude(array_of_structs[i].ascension);
      });
  }
  seconds = (clock() - start) / (double)CLOCKS_PER_SEC;
  cout << "array-of-structures: " << seconds << " seconds." << endl;
}
开发者ID:robert-butts,项目名称:parallel-patterns,代码行数:40,代码来源:data.cpp


示例19: assign

  void assign (size_t n, const Scalar& val) {

    /* Resize if necessary (behavour of std:vector) */

    if(n>capacity())
      DV::resize(size_t (n*_extra_storage));
    _size = n;

          /* Assign value either on host or on device */

    if( DV::modified_host >= DV::modified_device ) {
      set_functor_host f(DV::h_view,val);
      parallel_for(n,f);
      DV::t_host::device_type::fence();
      DV::modified_host++;
    } else {
      set_functor f(DV::d_view,val);
      parallel_for(n,f);
      DV::t_dev::device_type::fence();
      DV::modified_device++;
    }
  }
开发者ID:00liujj,项目名称:trilinos,代码行数:22,代码来源:Kokkos_Vector.hpp


示例20: main

int main(int argc, char** argv) {
    if(argc != 2) {
        printf("Usage: %s <password hash>\n",argv[0]);
        return 1;
    }
    
    int notfound=1;
    SpaceSearcher s( argv[1], &notfound );

    parallel_for( tbb::blocked_range<long>( 0, SEARCH_SPACE ), s );

    return 0;
}
开发者ID:acumartini,项目名称:parallel_prog,代码行数:13,代码来源:tbb_pass.cpp



注:本文中的parallel_for函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parallelsDriverLock函数代码示例发布时间:2022-05-30
下一篇:
C++ par_get函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap