Check for compatible compute version based on runtime cuda toolkit version
| 241 | |
| 242 | /// Check for compatible compute version based on runtime cuda toolkit version |
| 243 | void checkAndSetDevMaxCompute(pair<int, int> &computeCapability) { |
| 244 | auto originalCompute = computeCapability; |
| 245 | int rtCudaVer = 0; |
| 246 | CUDA_CHECK(cudaRuntimeGetVersion(&rtCudaVer)); |
| 247 | auto tkitMaxCompute = find_if( |
| 248 | begin(Toolkit2MaxCompute), end(Toolkit2MaxCompute), |
| 249 | [rtCudaVer](cuNVRTCcompute v) { return rtCudaVer == v.cudaVersion; }); |
| 250 | |
| 251 | bool embeddedDevice = isEmbedded(computeCapability); |
| 252 | |
| 253 | // If runtime cuda version is found in toolkit array |
| 254 | // check for max possible compute for that cuda version |
| 255 | if (tkitMaxCompute != end(Toolkit2MaxCompute) && |
| 256 | computeCapability.first >= tkitMaxCompute->major) { |
| 257 | int minorVersion = embeddedDevice ? tkitMaxCompute->embedded_minor |
| 258 | : tkitMaxCompute->minor; |
| 259 | |
| 260 | if (computeCapability.second > minorVersion) { |
| 261 | computeCapability = make_pair(tkitMaxCompute->major, minorVersion); |
| 262 | spdlog::get("platform") |
| 263 | ->warn( |
| 264 | "The compute capability for the current device({}.{}) " |
| 265 | "exceeds maximum supported by ArrayFire's CUDA " |
| 266 | "runtime({}.{}). Download or rebuild the latest version of " |
| 267 | "ArrayFire to avoid this warning. Using {}.{} for JIT " |
| 268 | "compilation kernels.", |
| 269 | originalCompute.first, originalCompute.second, |
| 270 | computeCapability.first, computeCapability.second, |
| 271 | computeCapability.first, computeCapability.second); |
| 272 | } |
| 273 | } else if (computeCapability.first >= Toolkit2MaxCompute[0].major) { |
| 274 | // If runtime cuda version is NOT found in toolkit array |
| 275 | // use the top most toolkit max compute |
| 276 | int minorVersion = embeddedDevice ? tkitMaxCompute->embedded_minor |
| 277 | : tkitMaxCompute->minor; |
| 278 | if (computeCapability.second > minorVersion) { |
| 279 | computeCapability = |
| 280 | make_pair(Toolkit2MaxCompute[0].major, minorVersion); |
| 281 | spdlog::get("platform") |
| 282 | ->warn( |
| 283 | "CUDA runtime version({}) not recognized. Targeting " |
| 284 | "compute {}.{} for this device which is the latest compute " |
| 285 | "capability supported by ArrayFire's CUDA runtime({}.{}). " |
| 286 | "Please create an issue or a pull request on the ArrayFire " |
| 287 | "repository to update the Toolkit2MaxCompute array with " |
| 288 | "this version of the CUDA Runtime.", |
| 289 | fromCudaVersion(rtCudaVer), originalCompute.first, |
| 290 | originalCompute.second, computeCapability.first, |
| 291 | computeCapability.second, computeCapability.first, |
| 292 | computeCapability.second); |
| 293 | } |
| 294 | } else if (computeCapability.first < 3) { |
| 295 | // all compute versions prior to Kepler, we don't support |
| 296 | // don't change the computeCapability. |
| 297 | spdlog::get("platform") |
| 298 | ->warn( |
| 299 | "The compute capability of the current device({}.{}) " |
| 300 | "lower than the minimum compute version ArrayFire " |
no test coverage detected