From 89713b2c221f8931044d1e5c7a5889cad4125454 Mon Sep 17 00:00:00 2001 From: Gera Shegalov Date: Mon, 6 Jun 2022 13:31:45 -0700 Subject: [PATCH] Properly handle cudaMemHandleTypeNone and cudaErrorInvalidValue in is_export_handle_type_supported (#1055) - [x] Intercept `cudaErrorInvalidValue` returned from `cudaDeviceGetAttribute` to return `false` from `is_export_handle_type_supported ` - [x] Return true from is_export_handle_type_supported for `cudaMemHandleTypeNone` Co-authored-by: @jrhemstad Co-authored-by: @harrism Closes #1054 Signed-off-by: Gera Shegalov Authors: - Gera Shegalov (https://github.com/gerashegalov) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1055 --- include/rmm/detail/dynamic_load_runtime.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index a095eb321..28121e6a8 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -136,9 +136,18 @@ struct async_alloc { { int supported_handle_types_bitmask{}; #if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes - RMM_CUDA_TRY(cudaDeviceGetAttribute(&supported_handle_types_bitmask, - cudaDevAttrMemoryPoolSupportedHandleTypes, - rmm::detail::current_device().value())); + if (cudaMemHandleTypeNone != handle_type) { + auto const result = cudaDeviceGetAttribute(&supported_handle_types_bitmask, + cudaDevAttrMemoryPoolSupportedHandleTypes, + rmm::detail::current_device().value()); + + // Don't throw on cudaErrorInvalidValue + auto const unsupported_runtime = (result == cudaErrorInvalidValue); + if (unsupported_runtime) return false; + // throw any other error that may have occurred + RMM_CUDA_TRY(result); + } + #endif return (supported_handle_types_bitmask & handle_type) == handle_type; }