当前位置: 首页>>代码示例>>C++>>正文


C++ parallel_for函数代码示例

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


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


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