本文整理汇总了C++中boost::compute::device类的典型用法代码示例。如果您正苦于以下问题:C++ device类的具体用法?C++ device怎么用?C++ device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了device类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
std::vector<device> device_list(DevFilter&& filter) {
std::vector<device> dev_list = boost::compute::system::devices();
std::vector<device> device;
for(auto d = dev_list.begin(); d != dev_list.end(); d++) {
if (!d->get_info<cl_bool>(CL_DEVICE_AVAILABLE)) continue;
if (!filter(*d)) continue;
device.push_back(*d);
}
return device;
}
开发者ID:ddemidov,项目名称:vexcl,代码行数:13,代码来源:context.hpp
示例2: operator
bool operator()(const boost::compute::device &d) const {
static std::map<cl_device_id, std::string> dev_uids = get_uids();
static /*thread_local*/ std::vector<std::unique_ptr<locker>> locks;
std::unique_ptr<locker> lck(new locker(dev_uids[d.get()]));
if (lck->try_lock() && filter(d)) {
locks.push_back(std::move(lck));
return true;
}
return false;
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例3: printDeviceInfo
void printDeviceInfo(const boost::compute::device & dev)
{
INFOM("====================================================================");
INFOM("name : " << dev.name());
// misc information
INFOM("--- misc info -----------------------------");
INFOM("CL_DEVICE_ERROR_CORRECTION_SUPPORT : " << dev.get_info<cl_bool>(CL_DEVICE_ERROR_CORRECTION_SUPPORT));
INFOM("CL_DEVICE_HOST_UNIFIED_MEMORY : " << dev.get_info<cl_bool>(CL_DEVICE_HOST_UNIFIED_MEMORY));
INFOM("CL_DEVICE_MAX_COMPUTE_UNITS : " << dev.get_info<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS));
INFOM("CL_DEVICE_PROFILING_TIMER_RESOLUTION (ns) : " << dev.get_info<size_t>(CL_DEVICE_PROFILING_TIMER_RESOLUTION));
// global memory information
INFOM("--- global memory info --------------------");
INFOM("CL_DEVICE_GLOBAL_MEM_CACHE_SIZE (KB) : " << dev.get_info<cl_ulong>(CL_DEVICE_GLOBAL_MEM_CACHE_SIZE) / 1024);
INFOM("CL_DEVICE_GLOBAL_MEM_CACHE_TYPE : " << cacheTypeToString(dev.get_info<cl_device_mem_cache_type>(CL_DEVICE_GLOBAL_MEM_CACHE_TYPE)));
INFOM("CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE (B) : " << dev.get_info<cl_uint>(CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE));
INFOM("CL_DEVICE_GLOBAL_MEM_SIZE (MB) : " << dev.get_info<cl_ulong>(CL_DEVICE_GLOBAL_MEM_SIZE) / 1024 / 1024);
// local memory information
INFOM("--- local memory info ---------------------");
INFOM("CL_DEVICE_LOCAL_MEM_SIZE (KB) : " << dev.get_info<cl_ulong>(CL_DEVICE_LOCAL_MEM_SIZE) / 1024);
INFOM("CL_DEVICE_LOCAL_MEM_TYPE : " << localMemTypeToString(dev.get_info<cl_device_local_mem_type>(CL_DEVICE_LOCAL_MEM_TYPE)));
// constant memory information
INFOM("--- constant memory info ------------------");
INFOM("CL_DEVICE_MAX_CONSTANT_ARGS : " << dev.get_info<cl_uint>(CL_DEVICE_MAX_CONSTANT_ARGS));
INFOM("CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE (KB) : " << dev.get_info<cl_ulong>(CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE) / 1024);
// memory object information
INFOM("--- memory object info --------------------");
INFOM("CL_DEVICE_MAX_MEM_ALLOC_SIZE (MB) : " << dev.get_info<cl_ulong>(CL_DEVICE_MAX_MEM_ALLOC_SIZE) / 1024 / 1024);
// work group information
INFOM("--- work group info -----------------------");
INFOM("CL_DEVICE_MAX_WORK_GROUP_SIZE : " << dev.get_info<size_t>(CL_DEVICE_MAX_WORK_GROUP_SIZE));
INFOM("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS : " << dev.get_info<size_t>(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS));
INFOM("CL_DEVICE_MAX_WORK_ITEM_SIZES : " << dev.get_info<std::vector<size_t>>(CL_DEVICE_MAX_WORK_ITEM_SIZES));
INFOM("====================================================================");
}
开发者ID:jcxz,项目名称:DIP,代码行数:42,代码来源:ocl.cpp
示例4: findGPUDevice
bool findGPUDevice(boost::compute::device & dev)
{
std::vector<boost::compute::device> devs(boost::compute::system::devices());
for (const boost::compute::device & dev_ : devs)
{
if (dev_.type() == CL_DEVICE_TYPE_GPU)
{
INFOM("Using device: " << dev_.name());
dev = dev_;
return true;
}
}
dev = boost::compute::system::default_device();
WARNM("Could not find any GPU device. Using device: " << dev.name());
return false;
}
开发者ID:jcxz,项目名称:DIP,代码行数:20,代码来源:ocl.cpp
示例5: select_context
namespace compute {
typedef boost::compute::context context;
typedef boost::compute::device device;
typedef boost::compute::program program;
typedef boost::compute::command_queue command_queue;
typedef cl_command_queue_properties command_queue_properties;
typedef cl_device_id device_id;
typedef cl_context context_id;
/// Launch grid size.
struct ndrange {
union {
size_t dim[3];
struct {
size_t x, y, z;
};
};
ndrange(size_t x = 1, size_t y = 1, size_t z = 1)
: x(x), y(y), z(z) {}
};
/// Binds the specified context to the calling CPU thread.
/**
* With the OpenCL backend this is an empty stub provided for compatibility
* with the CUDA backend.
*/
inline void select_context(const command_queue&) { }
/// Returns device associated with the given queue.
inline device get_device(const command_queue &q) {
return q.get_device();
}
/// Returns id of the device associated with the given queue.
inline device_id get_device_id(const command_queue &q) {
return q.get_device().get();
}
/// Returns raw context id for the given queue.
inline context_id get_context_id(const command_queue &q) {
return q.get_context().get();
}
/// Returns context for the given queue.
inline context get_context(const command_queue &q) {
return q.get_context();
}
/// Compares contexts by raw ids.
struct compare_contexts {
bool operator()(const context &a, const context &b) const {
return a.get() < b.get();
}
};
/// Compares queues by raw ids.
struct compare_queues {
bool operator()(const command_queue &a, const command_queue &b) const {
return a.get() < b.get();
}
};
/// Create command queue on the same context and device as the given one.
inline command_queue duplicate_queue(const command_queue &q) {
return command_queue(q.get_context(), q.get_device(), q.get_properties());
}
/// Checks if the compute device is CPU.
inline bool is_cpu(const command_queue &q) {
return q.get_device().get_info<cl_device_type>(CL_DEVICE_TYPE) & CL_DEVICE_TYPE_CPU;
}
/// Select devices by given criteria.
/**
* \param filter Device filter functor. Functors may be combined with logical
* operators.
* \returns list of devices satisfying the provided filter.
*
* This example selects any GPU which supports double precision arithmetic:
\code
auto devices = device_list(
Filter::Type(CL_DEVICE_TYPE_GPU) && Filter::DoublePrecision
);
\endcode
*/
template<class DevFilter>
std::vector<device> device_list(DevFilter&& filter) {
std::vector<device> dev_list = boost::compute::system::devices();
std::vector<device> device;
for(auto d = dev_list.begin(); d != dev_list.end(); d++) {
if (!d->get_info<cl_bool>(CL_DEVICE_AVAILABLE)) continue;
if (!filter(*d)) continue;
device.push_back(*d);
}
return device;
//.........这里部分代码省略.........
开发者ID:ddemidov,项目名称:vexcl,代码行数:101,代码来源:context.hpp
示例6: compare_compute_units
// used to sort devices by number of compute units
bool compare_compute_units(const boost::compute::device &a,
const boost::compute::device &b)
{
return a.compute_units() < b.compute_units();
}
开发者ID:junmuz,项目名称:compute,代码行数:6,代码来源:test_device.cpp
注:本文中的boost::compute::device类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论