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


C++ DeviceVector类代码示例

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


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

示例1: throwOnError

CLContext::CLContext() {
  cl_int         result;
  PlatformVector allPlatforms;

  result = cl::Platform::get(&allPlatforms);
  throwOnError("cl::Platform::get", result);

  if(allPlatforms.size() == 0) {
    throw std::runtime_error("No platforms available");
  }

  platform_ = allPlatforms[0];

  //printValue("Platform", platform_.getInfo<CL_PLATFORM_NAME>());

  // Create context
  cl_context_properties cps[3] = {
    CL_CONTEXT_PLATFORM,
    (cl_context_properties)(platform_)(),
    0
  };

  context_ = cl::Context(CL_DEVICE_TYPE_GPU, cps, NULL, NULL, &result);
  throwOnError("cl::Context", result);

  DeviceVector allDevices = context_.getInfo<CL_CONTEXT_DEVICES>();

  if(allDevices.size() == 0) {
    throw std::runtime_error("No devices available");
  }

  device_ = allDevices[0];

  //printValue("Device", device_.getInfo<CL_DEVICE_NAME>());
}
开发者ID:jholewinski,项目名称:overtile,代码行数:35,代码来源:CLContext.cpp

示例2: assert

void OCLSample::initOpenCL() {
  cl_int result;

  // First, select an OpenCL platform
  typedef std::vector<cl::Platform> PlatformVector;
  PlatformVector platforms;
  result = cl::Platform::get(&platforms);
  assert(result == CL_SUCCESS && "Failed to retrieve OpenCL platform");
  assert(platforms.size() > 0 && "No OpenCL platforms found");

  // For now, just blindly select the first platform.
  // @TODO: Implement a check here for the NVidia OpenCL platform.
  platform_ = platforms[0];

  // Create an OpenCL context.
  cl_context_properties cps[] = { CL_CONTEXT_PLATFORM,
    (cl_context_properties)(platform_)(), 0 };
  context_ = cl::Context(CL_DEVICE_TYPE_GPU, cps, NULL, NULL, &result);
  assert(result == CL_SUCCESS && "Failed to create OpenCL context");

  // Retrieve the available OpenCL devices.
  typedef std::vector<cl::Device> DeviceVector;
  DeviceVector devices;
  devices = context_.getInfo<CL_CONTEXT_DEVICES>();
  assert(devices.size() > 0 && "No OpenCL devices found");

  // For now, just blindly select the first device.
  // @TODO: Implement some sort of device check here.
  device_ = devices[0];

  // Create a command queue
  queue_ = cl::CommandQueue(context_, device_, CL_QUEUE_PROFILING_ENABLE, &result);
  assert(result == CL_SUCCESS && "Failed to create command queue");
}
开发者ID:Quanteek,项目名称:llvm-ptx-samples,代码行数:34,代码来源:OCLSample.cpp

示例3: updateValues

void updateValues( BorderSubdType i_BorderSubdType, const DeviceVector< T >& i_Src, const subd::TopologyData& i_Topo, int i_Stride, int i_Offset, DeviceVector< T >& o_Dst  )
{
	assert( o_Dst.size() != 0 );

	grind::subd::genFacePointsDevice( i_Topo.faceList.size(), i_Topo.faceList.getDevicePtr(), i_Src.getDevicePtr(), i_Topo.facePointsOffset, i_Topo.vertPointsOffset, i_Stride, i_Offset, o_Dst.getDevicePtr() );
	grind::subd::tweakVertPointsDevice( i_Topo.srcVertCount, i_Topo.vertFaceValence.getDevicePtr(), i_Topo.vertEdgeValence.getDevicePtr(), i_Topo.vertPointsOffset, i_Stride, i_Offset, o_Dst.getDevicePtr() );
	grind::subd::genEdgePointsDevice( i_Topo.edgeList.size(), i_Topo.edgeList.getDevicePtr(), i_Src.getDevicePtr(), i_Topo.vertFaceValence.getDevicePtr(), i_Topo.vertEdgeValence.getDevicePtr(), i_Topo.edgePointsOffset, i_Topo.vertPointsOffset, i_Stride, i_Offset, o_Dst.getDevicePtr() );
	grind::subd::genVertPointsDevice( i_BorderSubdType, i_Topo.srcVertCount, i_Src.getDevicePtr(), i_Topo.vertFaceValence.getDevicePtr(), i_Topo.vertEdgeValence.getDevicePtr(), i_Topo.vertPointsOffset, i_Stride, i_Offset, o_Dst.getDevicePtr() );
}
开发者ID:achayan,项目名称:anim-studio-tools,代码行数:9,代码来源:mesh_subdivide.cpp

示例4: getDevicesFromTypeAddr

DeviceVector DeviceVector::getDevicesFromTypeAddr(
        audio_devices_t type, const String8& address) const
{
    DeviceVector devices;
    for (size_t i = 0; i < size(); i++) {
        if (itemAt(i)->type() == type) {
            if (itemAt(i)->mAddress == address) {
                devices.add(itemAt(i));
            }
        }
    }
    return devices;
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例5: removeDevice

  void removeDevice(Freenect2DeviceImpl *device)
  {
    DeviceVector::iterator it = std::find(devices_.begin(), devices_.end(), device);

    if(it != devices_.end())
    {
      devices_.erase(it);
    }
    else
    {
      std::cout << "[Freenect2Impl] tried to remove device, which is not in the internal device list!" << std::endl;
    }
  }
开发者ID:JebusChris,项目名称:libfreenect2,代码行数:13,代码来源:libfreenect2.cpp

示例6: tryGetDevice

  bool tryGetDevice(libusb_device *usb_device, Freenect2DeviceImpl **device)
  {
    for(DeviceVector::iterator it = devices_.begin(); it != devices_.end(); ++it)
    {
      if((*it)->isSameUsbDevice(usb_device))
      {
        *device = *it;
        return true;
      }
    }

    return false;
  }
开发者ID:JebusChris,项目名称:libfreenect2,代码行数:13,代码来源:libfreenect2.cpp

示例7: transferVector

DeviceVector* transferVector(const Stream& stream, const PinnedHostVector& vectorHost) {
    const cudaStream_t& cudaStream = stream.getCudaStream();
    const int numberOfRows = vectorHost.getNumberOfRows();

    DeviceVector* deviceVector = new DeviceVector(numberOfRows);
    PRECISION* deviceVectorPointer = deviceVector->getMemoryPointer();
    const PRECISION* hostVectorPointer = vectorHost.getMemoryPointer();

    handleCublasStatus(
        cublasSetVectorAsync(numberOfRows, sizeof(PRECISION), hostVectorPointer, 1, deviceVectorPointer, 1, cudaStream),
        "Error when transferring vector from host to device: ");

    return deviceVector;
}
开发者ID:Berjiz,项目名称:CuEira,代码行数:14,代码来源:HostToDevice.cpp

示例8: clearValues

void clearValues( const DeviceVector< T >& i_Src, const subd::TopologyData& i_Topo, int i_Stride, int i_Offset, DeviceVector< T >& o_Dst  )
{
	size_t vert_count = i_Topo.faceList.size() + i_Topo.edgeList.size() + i_Topo.srcVertCount;

	if( i_Src.size() != i_Topo.srcVertCount * i_Stride ){
		throw std::runtime_error( "mesh topology doesn't appear to match guide topology" );
	}

	//! should provide a zero value for vec3, vec2, float etc
	const static T zero = T() * 0.0f;

	o_Dst.resize( vert_count * i_Stride );
	setAllElements( zero, o_Dst );
}
开发者ID:achayan,项目名称:anim-studio-tools,代码行数:14,代码来源:mesh_subdivide.cpp

示例9: clearDevices

  void clearDevices()
  {
    DeviceVector devices(devices_.begin(), devices_.end());

    for(DeviceVector::iterator it = devices.begin(); it != devices.end(); ++it)
    {
      delete (*it);
    }

    if(!devices_.empty())
    {
      std::cout << "[Freenect2Impl] after deleting all devices the internal device list should be empty!" << std::endl;
    }
  }
开发者ID:JebusChris,项目名称:libfreenect2,代码行数:14,代码来源:libfreenect2.cpp

示例10: max_iter

size_t ConvNet::max_iter(DeviceVector<float> v) {
	size_t i = 0;
//#ifdef NOTUNIFIEDMEMORY
	v.pop();
//#endif

	float_t max = v[0];
	for (size_t j = 1; j < v.size(); j++) {
		if (v[j] > max) {
			max = v[j];
			i = j;
		}
	}
	return i;
}
开发者ID:dagoliveira,项目名称:radiation-benchmarks,代码行数:15,代码来源:ConvNet.cpp

示例11: createDevices

	DeviceVector ATIGPUDevice::createDevices(unsigned int flags)
	{
		DeviceVector devices;

		if(deviceCount() == 0) return devices;

		try {
			// Multiple devices is not supported yet
			devices.push_back(new ATIGPUDevice());
		} catch (hydrazine::Exception he) {
			// Swallow the exception and return empty device vector
			report(he.what());
		}

		return devices;
	}
开发者ID:dulejuve,项目名称:Benchmarking-CUDA,代码行数:16,代码来源:ATIGPUDevice.cpp

示例12: loadDevicesFromTag

void DeviceVector::loadDevicesFromTag(char *tag,
                                       const DeviceVector& declaredDevices)
{
    char *devTag = strtok(tag, "|");
    while (devTag != NULL) {
        if (strlen(devTag) != 0) {
            audio_devices_t type = ConfigParsingUtils::stringToEnum(sDeviceTypeToEnumTable,
                                 ARRAY_SIZE(sDeviceTypeToEnumTable),
                                 devTag);
            if (type != AUDIO_DEVICE_NONE) {
                sp<DeviceDescriptor> dev = new DeviceDescriptor(type);
                if (type == AUDIO_DEVICE_IN_REMOTE_SUBMIX ||
                        type == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ) {
                    dev->mAddress = String8("0");
                }
                add(dev);
            } else {
                sp<DeviceDescriptor> deviceDesc =
                        declaredDevices.getDeviceFromTag(String8(devTag));
                if (deviceDesc != 0) {
                    add(deviceDesc);
                }
            }
         }
         devTag = strtok(NULL, "|");
     }
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例13: audio_is_output_devices

DeviceVector DeviceVector::getDevicesFromType(audio_devices_t type) const
{
    DeviceVector devices;
    bool isOutput = audio_is_output_devices(type);
    type &= ~AUDIO_DEVICE_BIT_IN;
    for (size_t i = 0; (i < size()) && (type != AUDIO_DEVICE_NONE); i++) {
        bool curIsOutput = audio_is_output_devices(itemAt(i)->mDeviceType);
        audio_devices_t curType = itemAt(i)->mDeviceType & ~AUDIO_DEVICE_BIT_IN;
        if ((isOutput == curIsOutput) && ((type & curType) != 0)) {
            devices.add(itemAt(i));
            type &= ~curType;
            ALOGV("DeviceVector::getDevicesFromType() for type %x found %p",
                  itemAt(i)->type(), itemAt(i).get());
        }
    }
    return devices;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例14: updateTopology

//-------------------------------------------------------------------------------------------------
void updateTopology(	size_t i_SrcVertCount,
                    	const DeviceVector<int>& i_MeshConnectivity,
						const DeviceVector<int>& i_PolyVertCounts,
						subd::TopologyData& o_Topo,
						DeviceVector<int>* o_Id )
{
	o_Topo.srcVertCount = i_SrcVertCount;

	meshSanityCheck( i_PolyVertCounts );

	o_Topo.cumulativePolyVertCounts.resize( i_PolyVertCounts.size() );
	inclusiveScan( i_PolyVertCounts, o_Topo.cumulativePolyVertCounts );

	o_Topo.vertEdgeValence.resize( o_Topo.srcVertCount );
	setAllElements( 0, o_Topo.vertEdgeValence );
	o_Topo.vertFaceValence.resize( o_Topo.srcVertCount );
	setAllElements( 0, o_Topo.vertFaceValence );

	int face_count = i_PolyVertCounts.size();

	o_Topo.faceList.resize( face_count );

	buildFaceListDevice( face_count, i_MeshConnectivity.getDevicePtr(), o_Topo.cumulativePolyVertCounts.getDevicePtr(), o_Topo.faceList.getDevicePtr(), o_Topo.vertFaceValence.getDevicePtr() );

	int non_unique_edge_count = reduce( i_PolyVertCounts );

	DeviceVector< grind::subd::Edge > d_edges;
	d_edges.resize( non_unique_edge_count );
	int actual_edge_count = buildEdgeListDevice( face_count, i_MeshConnectivity.getDevicePtr(), o_Topo.cumulativePolyVertCounts.getDevicePtr(), d_edges.getDevicePtr(), o_Topo.vertEdgeValence.getDevicePtr() );
	o_Topo.edgeList.setValueDevice( d_edges.getDevicePtr(), actual_edge_count );

	int subd_quad_count = non_unique_edge_count;
	DRD_LOG_INFO( L, "faces before subd: " << face_count );
	DRD_LOG_INFO( L, "faces after subd: " << subd_quad_count );

	o_Topo.facePointsOffset = 0;
	o_Topo.edgePointsOffset = o_Topo.faceList.size();
	o_Topo.vertPointsOffset = o_Topo.faceList.size() + o_Topo.edgeList.size();

	if( o_Id != NULL ){
		o_Id->resize( subd_quad_count * 4, -1 );
		buildSubdFaceTopologyDevice( o_Topo.edgeList.size(), o_Topo.edgeList.getDevicePtr(), i_MeshConnectivity.getDevicePtr(), o_Topo.cumulativePolyVertCounts.getDevicePtr(), o_Topo.facePointsOffset, o_Topo.edgePointsOffset, o_Topo.vertPointsOffset, o_Id->getDevicePtr() );
	}
}
开发者ID:achayan,项目名称:anim-studio-tools,代码行数:45,代码来源:mesh_subdivide.cpp

示例15: buildCatmullRomP

//-------------------------------------------------------------------------------------------------
//! extrapolate end verts
void buildCatmullRomP( int i_CurveCount, int i_CvCount, const DeviceVector<Imath::V3f>& i_P, HostVector<Imath::V3f>& o_Result )
{
	HostVector<Imath::V3f> p;
	i_P.getValue(p);
	int src_cv_id = 0;
	for( int curve = 0; curve < i_CurveCount; ++curve ){
		// extend tangent before curve
		o_Result.push_back( p[src_cv_id]*2 - p[src_cv_id+1] );

		for( int cv = 0; cv < i_CvCount; ++cv, ++src_cv_id ){
			// copy curve value
			o_Result.push_back( p[src_cv_id] );
		}
		// extend tangent after curve
		o_Result.push_back( p[src_cv_id-1]*2 - p[src_cv_id-2] );
	}
}
开发者ID:achayan,项目名称:anim-studio-tools,代码行数:19,代码来源:line_soup.cpp


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