| 100 | } |
| 101 | |
| 102 | cl_device_id |
| 103 | BlasBase::getDevice(cl_device_type type, const char* name, |
| 104 | cl_int *error) |
| 105 | { |
| 106 | cl_int err; |
| 107 | cl_uint nrDevices, i, p; |
| 108 | cl_device_id *devices = NULL; |
| 109 | cl_device_id result = 0; |
| 110 | size_t sz; |
| 111 | char *str; |
| 112 | cl_platform_id* platforms = NULL; |
| 113 | cl_uint nrPlatforms; |
| 114 | |
| 115 | nrPlatforms = getPlatforms(&platforms, &err); |
| 116 | |
| 117 | if (error != NULL) { |
| 118 | *error = CL_SUCCESS; |
| 119 | } |
| 120 | |
| 121 | if (platOrd_ < nrPlatforms) { |
| 122 | platform_ = platforms[platOrd_]; |
| 123 | err = clGetDeviceIDs(platform_, type, 0, NULL, &nrDevices); |
| 124 | if (err != CL_SUCCESS) { |
| 125 | if (error != NULL) { |
| 126 | *error = err; |
| 127 | } |
| 128 | return NULL; |
| 129 | } |
| 130 | if (nrDevices == 0) { |
| 131 | return NULL; |
| 132 | } |
| 133 | |
| 134 | devices = new cl_device_id[nrDevices]; |
| 135 | err = clGetDeviceIDs(platform_, type, nrDevices, devices, NULL); |
| 136 | if (err != CL_SUCCESS) { |
| 137 | if (error != NULL) { |
| 138 | *error = err; |
| 139 | } |
| 140 | delete[] devices; |
| 141 | return NULL; |
| 142 | } |
| 143 | |
| 144 | if (devOrd_ < nrDevices) { |
| 145 | result = devices[devOrd_]; |
| 146 | } |
| 147 | delete[] devices; |
| 148 | devices = NULL; |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | platform_ = NULL; |
| 153 | } |
| 154 | |
| 155 | delete[] platforms; |
| 156 | return result; |
| 157 | } |
| 158 | |
| 159 | void |
nothing calls this directly
no test coverage detected