A debug only function that checks to see if the driver or runtime function is part of the CudaToDriverVersion array. If the runtime version is not part of the array then an error is thrown in debug mode. If the driver version is not part of the array, then a message is displayed in the error stream. \param[in] runtime_version The version integer returned by cudaRuntimeGetVersion \param[in] drive
| 455 | /// cudaDriverGetVersion |
| 456 | /// \note: only works in debug builds |
| 457 | void debugRuntimeCheck(spdlog::logger *logger, int runtime_version, |
| 458 | int driver_version) { |
| 459 | auto runtime_it = |
| 460 | find_if(begin(CudaToDriverVersion), end(CudaToDriverVersion), |
| 461 | [runtime_version](ToolkitDriverVersions ver) { |
| 462 | return runtime_version == ver.version; |
| 463 | }); |
| 464 | auto driver_it = |
| 465 | find_if(begin(CudaToDriverVersion), end(CudaToDriverVersion), |
| 466 | [driver_version](ToolkitDriverVersions ver) { |
| 467 | return driver_version == ver.version; |
| 468 | }); |
| 469 | |
| 470 | auto getLogger = [&logger]() -> spdlog::logger * { return logger; }; |
| 471 | |
| 472 | // If the runtime version is not part of the CudaToDriverVersion array, |
| 473 | // display a message in the trace. Do not throw an error unless this is |
| 474 | // a debug build |
| 475 | if (runtime_it == end(CudaToDriverVersion)) { |
| 476 | constexpr size_t buf_size = 256; |
| 477 | char buf[buf_size]; |
| 478 | const char *err_msg = |
| 479 | "CUDA runtime version({}) not recognized. Please create an issue " |
| 480 | "or a pull request on the ArrayFire repository to update the " |
| 481 | "CudaToDriverVersion variable with this version of the CUDA " |
| 482 | "runtime.\n"; |
| 483 | fmt::format_to_n(buf, buf_size, err_msg, |
| 484 | fromCudaVersion(runtime_version)); |
| 485 | AF_TRACE("{}", buf); |
| 486 | #ifndef NDEBUG |
| 487 | AF_ERROR(buf, AF_ERR_RUNTIME); |
| 488 | #endif |
| 489 | } |
| 490 | |
| 491 | if (driver_it == end(CudaToDriverVersion)) { |
| 492 | AF_TRACE( |
| 493 | "CUDA driver version({}) not part of the CudaToDriverVersion " |
| 494 | "array. Please create an issue or a pull request on the ArrayFire " |
| 495 | "repository to update the CudaToDriverVersion variable with this " |
| 496 | "version of the CUDA runtime.\n", |
| 497 | fromCudaVersion(driver_version)); |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | // Check if the device driver version is recent enough to run the cuda libs |
| 502 | // linked with afcuda: |
no test coverage detected