1 #ifndef VIENNACL_GENERATOR_PROFILES_HPP
2 #define VIENNACL_GENERATOR_PROFILES_HPP
54 template<
class KeyType,
class ValueType>
78 map[vendor_id][CL_DEVICE_TYPE_GPU][family][
""][expression] = map[vendor_id][CL_DEVICE_TYPE_GPU][family][device_name][expression];
105 static database_type init_database(){
298 static database_type database = init_database();
303 if(profile->is_invalid(device, descriptor.scalartype_size))
305 return profile.
get();
309 static profile_base *
get(
viennacl::ocl::device const & device, expression_descriptor
const & descriptor){
313 std::string
const & device_name = device.
name();
318 database_type::map_type::iterator vendor_it = database.
map.find(vendor_id);
320 if(vendor_it==database.
map.end())
321 return handle_failure(device, descriptor,
at(
at(
at(
at(
at(database.
map, viennacl::ocl::unknown_id).map, dev_type).map,
viennacl::ocl::UNKNOWN).map, std::string(
"")).map, expression_key));
325 device_type_map::map_type::iterator device_type_it = vendor_it->second.map.find(dev_type);
327 if(device_type_it==vendor_it->second.map.end())
328 return handle_failure(device, descriptor,
at(
at(
at(
at(
at(database.
map, viennacl::ocl::unknown_id).map, dev_type).map,
viennacl::ocl::UNKNOWN).map, std::string(
"")).map, expression_key));
332 device_architecture_map::map_type::iterator architecture_it = device_type_it->second.map.find(device_architecture);
333 if(architecture_it==device_type_it->second.map.end())
334 return handle_failure(device, descriptor,
at(
at(
at(
at(
at(database.
map, viennacl::ocl::unknown_id).map, dev_type).map,
viennacl::ocl::UNKNOWN).map, std::string(
"")).map, expression_key));
338 device_name_map::map_type::iterator device_name_it = architecture_it->second.map.find(device_name);
340 if(device_name_it==architecture_it->second.map.end())
341 return handle_failure(device, descriptor,
at(
at(
at(
at(
at(database.
map, vendor_id).map, dev_type).map, device_architecture).map, std::string(
"")).map, expression_key));
345 expression_map::map_type::iterator expression_it = device_name_it->second.map.find(expression_key);
347 if(expression_it==device_name_it->second.map.end())
348 return handle_failure(device, descriptor,
at(
at(
at(
at(
at(database.
map, vendor_id).map, dev_type).map, device_architecture).map, std::string(
"")).map, expression_key));
352 return handle_failure(device, descriptor,
at(
at(
at(
at(
at(database.
map, vendor_id).map, dev_type).map, device_architecture).map, std::string(
"")).map, expression_key));
std::string name() const
Device name string.
Definition: device.hpp:566
Definition: forwards.h:61
Definition: forwards.h:60
Represents device_type->device_arch in the map hierarchy vendor->device_type->device_arch->device->ex...
Definition: profiles.hpp:71
Definition: device_utils.hpp:54
Definition: device_utils.hpp:55
Represents an OpenCL device within ViennaCL.
Kernel generation class for matrix-matrix products.
Definition: matrix_product.hpp:44
OpenCL kernel generation class for matrix expressions of AXPY type, i.e. A = alpha * B + beta * C...
Definition: saxpy.hpp:117
void set_generation_default_to(database_type &map, vendor_id_type vendor_id, viennacl::ocl::device_architecture_family family, expression_key_type expression, std::string const &device_name)
Set a default of a generation to a particular device for a particular operation.
Definition: profiles.hpp:77
void set_all_generation_default_to(database_type &map, vendor_id_type vendor_id, viennacl::ocl::device_architecture_family family, std::string const &device_name)
Set a default of a generation to a particular device for all operations.
Definition: profiles.hpp:82
cl_device_type device_type
Definition: profiles.hpp:48
cl_uint vendor_id_type
Definition: profiles.hpp:47
viennacl::tools::shared_ptr< profile_base > profile_base_ptr
Definition: profiles.hpp:51
device_architecture_family architecture_family() const
Device architecture family.
Definition: device.hpp:578
Definition: device_utils.hpp:62
Represents expression->profile in the map hierarchy vendor->device_type->device_arch->device->express...
Definition: profiles.hpp:62
A class representing a compute device (e.g. a GPU)
Definition: device.hpp:49
Definition: forwards.h:59
Definition: forwards.h:54
Definition: forwards.h:58
ValueT const & at(std::map< KeyT, ValueT > const &map, KeyT const &key)
Emulation of C++11's .at() member for std::map<>
Definition: forwards.h:97
Definition: forwards.h:56
Definition: forwards.h:57
device_architecture_family
Definition: device_utils.hpp:51
Implementation of a shared pointer class (cf. std::shared_ptr, boost::shared_ptr). Will be used until C++11 is widely available.
OpenCL kernel generation class for vector expressions of AXPY type, i.e. x = alpha * y + beta * z...
Definition: saxpy.hpp:44
Definition: device_utils.hpp:58
Base classes for the profiles.
Helper struct for mapping a std::map<KeyType, ValueType>. Used to avoids type length explosion when u...
Definition: profiles.hpp:55
Definition: forwards.h:55
Definition: device_utils.hpp:60
cl_uint vendor_id() const
A unique device vendor identifier. An example of a unique device identifier could be the PCIe ID...
Definition: device.hpp:917
std::map< KeyType, ValueType > map_type
Definition: profiles.hpp:56
Represents device->expression in the map hierarchy vendor->device_type->device_arch->device->expressi...
Definition: profiles.hpp:65
Kernel template for the matrix product operation.
Kernel template for the vector reduction operation.
OpenCL kernel template for reductions resulting in a vector. Example: Computing the row norms of a ma...
Definition: vector_reduction.hpp:44
Kernel template for the saxpy-like operation.
Definition: forwards.h:53
std::pair< expression_type, vcl_size_t > expression_key_type
Definition: forwards.h:81
cl_device_type type() const
The OpenCL device type.
Definition: device.hpp:893
map_type map
Definition: profiles.hpp:57
Represents vendor->device_type in the map hierarchy vendor->device_type->device_arch->device->express...
Definition: profiles.hpp:74
ValueType & operator[](KeyType const &key)
Definition: profiles.hpp:58
Represents device_arch->device in the map hierarchy vendor->device_type->device_arch->device->express...
Definition: profiles.hpp:68
std::string device_name_type
Definition: profiles.hpp:50
OpenCL kernel generation template for scalar reduction operations such as s = norm_2(x).
Definition: scalar_reduction.hpp:45
Kernel template for the scalar reduction operation.