本文整理汇总了C++中DeviceVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceVector::size方法的具体用法?C++ DeviceVector::size怎么用?C++ DeviceVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceVector
的用法示例。
在下文中一共展示了DeviceVector::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initOpenCL
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");
}
示例2: runtime_error
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>());
}
示例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() );
}
示例4: 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() );
}
}
示例5: 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 );
}
示例6: 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;
}
示例7: handleMethod
ErrorPtr DaliDeviceContainer::handleMethod(VdcApiRequestPtr aRequest, const string &aMethod, ApiValuePtr aParams)
{
ErrorPtr respErr;
if (aMethod=="x-p44-groupDevices") {
// create a composite device out of existing single-channel ones
ApiValuePtr components;
long long collectionID = -1;
DeviceVector groupedDevices;
respErr = checkParam(aParams, "members", components);
if (Error::isOK(respErr)) {
if (components->isType(apivalue_object)) {
components->resetKeyIteration();
string dimmerType;
ApiValuePtr o;
while (components->nextKeyValue(dimmerType, o)) {
DsUid memberUID;
memberUID.setAsBinary(o->binaryValue());
bool deviceFound = false;
// search for this device
for (DeviceVector::iterator pos = devices.begin(); pos!=devices.end(); ++pos) {
// only non-grouped DALI devices can be grouped
DaliDevicePtr dev = boost::dynamic_pointer_cast<DaliDevice>(*pos);
if (dev && dev->getDsUid() == memberUID) {
deviceFound = true;
// found this device, create DB entry for it
db.executef(
"INSERT OR REPLACE INTO compositeDevices (dimmerUID, dimmerType, collectionID) VALUES ('%s','%s',%lld)",
memberUID.getString().c_str(),
dimmerType.c_str(),
collectionID
);
if (collectionID<0) {
// use rowid of just inserted item as collectionID
collectionID = db.last_insert_rowid();
// - update already inserted first record
db.executef(
"UPDATE compositeDevices SET collectionID=%lld WHERE ROWID=%lld",
collectionID,
collectionID
);
}
// remember
groupedDevices.push_back(dev);
// done
break;
}
}
if (!deviceFound) {
respErr = ErrorPtr(new WebError(404, "some devices of the group could not be found"));
break;
}
}
if (Error::isOK(respErr) && groupedDevices.size()>0) {
// all components inserted into DB
// - remove grouped single devices
for (DeviceVector::iterator pos = groupedDevices.begin(); pos!=groupedDevices.end(); ++pos) {
(*pos)->hasVanished(false); // vanish, but keep settings
}
// - re-collect devices to find grouped composite now, but only in a second starting from main loop, not from here
CompletedCB cb = boost::bind(&DaliDeviceContainer::groupCollected, this, aRequest);
MainLoop::currentMainLoop().executeOnce(boost::bind(&DaliDeviceContainer::collectDevices, this, cb, false, false), 1*Second);
}
}
}
}
else {
respErr = inherited::handleMethod(aRequest, aMethod, aParams);
}
return respErr;
}