ViennaCL - The Vienna Computing Library
1.5.2
|
00001 #ifndef VIENNACL_OCL_DEVICE_UTILS_HPP_ 00002 #define VIENNACL_OCL_DEVICE_UTILS_HPP_ 00003 00004 /* ========================================================================= 00005 Copyright (c) 2010-2014, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 Portions of this software are copyright by UChicago Argonne, LLC. 00009 00010 ----------------- 00011 ViennaCL - The Vienna Computing Library 00012 ----------------- 00013 00014 Project Head: Karl Rupp rupp@iue.tuwien.ac.at 00015 00016 (A list of authors and contributors can be found in the PDF manual) 00017 00018 License: MIT (X11), see file LICENSE in the base directory 00019 ============================================================================= */ 00020 00025 #define VIENNACL_OCL_MAX_DEVICE_NUM 8 00026 00027 #ifdef __APPLE__ 00028 #include <OpenCL/cl.h> 00029 #else 00030 #include <CL/cl.h> 00031 #endif 00032 00033 00034 #include <stddef.h> 00035 #include <map> 00036 #include <string> 00037 00038 #include "viennacl/forwards.h" 00039 00040 namespace viennacl 00041 { 00042 namespace ocl 00043 { 00044 00045 static const cl_uint intel_id = 32902; 00046 static const cl_uint nvidia_id = 4318; 00047 static const cl_uint amd_id = 4098; 00048 static const cl_uint unknown_id = 0; 00049 00050 //Architecture Family 00051 enum device_architecture_family{ 00052 //NVidia 00053 Tesla, 00054 Fermi, 00055 Kepler, 00056 00057 //AMD 00058 Evergreen, 00059 NorthernIslands, 00060 SouthernIslands, 00061 00062 UNKNOWN 00063 }; 00064 00065 static device_architecture_family get_device_architecture(cl_uint vendor_id, std::string const & name){ 00066 00067 /*-NVidia-*/ 00068 if(vendor_id==nvidia_id){ 00069 //GeForce 00070 vcl_size_t found=0; 00071 if((found= name.find("GeForce",0)) != std::string::npos){ 00072 if((found = name.find_first_of("123456789", found)) != std::string::npos){ 00073 switch (name[found]) { 00074 case '2' : return Tesla; 00075 case '3' : return Tesla; 00076 00077 case '4' : return Fermi; 00078 case '5' : return Fermi; 00079 00080 case '6' : return Kepler; 00081 case '7' : return Kepler; 00082 00083 default: return UNKNOWN; 00084 } 00085 } 00086 else 00087 return UNKNOWN; 00088 } 00089 00090 //Tesla 00091 else if((found = name.find("Tesla",0)) != std::string::npos){ 00092 if((found = name.find("CMK", found)) != std::string::npos){ 00093 switch(name[found]){ 00094 case 'C' : return Fermi; 00095 case 'M' : return Fermi; 00096 00097 case 'K' : return Kepler; 00098 00099 default : return UNKNOWN; 00100 } 00101 } 00102 else 00103 return UNKNOWN; 00104 } 00105 00106 else 00107 return UNKNOWN; 00108 } 00109 00110 /*-AMD-*/ 00111 else if(vendor_id==amd_id){ 00112 00113 #define VIENNACL_DEVICE_MAP(device,arch)if(name.find(device,0)!=std::string::npos) return arch; 00114 00115 //Evergreen 00116 VIENNACL_DEVICE_MAP("Cedar",Evergreen); 00117 VIENNACL_DEVICE_MAP("Redwood",Evergreen); 00118 VIENNACL_DEVICE_MAP("Juniper",Evergreen); 00119 VIENNACL_DEVICE_MAP("Cypress",Evergreen); 00120 VIENNACL_DEVICE_MAP("Hemlock",Evergreen); 00121 00122 //NorthernIslands 00123 VIENNACL_DEVICE_MAP("Caicos",NorthernIslands); 00124 VIENNACL_DEVICE_MAP("Turks",NorthernIslands); 00125 VIENNACL_DEVICE_MAP("Barts",NorthernIslands); 00126 VIENNACL_DEVICE_MAP("Cayman",NorthernIslands); 00127 VIENNACL_DEVICE_MAP("Antilles",NorthernIslands); 00128 00129 //SouthernIslands 00130 VIENNACL_DEVICE_MAP("Cape",SouthernIslands); 00131 VIENNACL_DEVICE_MAP("Bonaire",SouthernIslands); 00132 VIENNACL_DEVICE_MAP("Pitcaim",SouthernIslands); 00133 VIENNACL_DEVICE_MAP("Tahiti",SouthernIslands); 00134 VIENNACL_DEVICE_MAP("Malta",SouthernIslands); 00135 00136 #undef VIENNACL_DEVICE_MAP 00137 00138 return UNKNOWN; 00139 00140 } 00141 00142 /*-Other-*/ 00143 else{ 00144 return UNKNOWN; 00145 } 00146 00147 } 00148 00149 00150 } 00151 } //namespace viennacl 00152 00153 #endif 00154