From 3c3af5c586401ab60ec88f60cec07db58a9cf63c Mon Sep 17 00:00:00 2001 From: Longlong Yao Date: Thu, 12 Dec 2024 00:00:29 -0800 Subject: [PATCH] wsl/hsakmt: check hsakmt_is_dgpu for hsakmt To align with Native Linux, use NumCPUCores in GPU and NumFComputeCores in CPU to determine if the asic is dGPU. This value is only for libhsakmt internal use. Reviewed-by: Flora Cui Signed-off-by: Longlong Yao Part-of: --- globals.cpp | 2 +- libhsakmt.h | 2 +- memory.cpp | 2 +- topology.cpp | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/globals.cpp b/globals.cpp index 6643407ad4..25fabb5ead 100644 --- a/globals.cpp +++ b/globals.cpp @@ -31,7 +31,7 @@ int kfd_fd = -1; unsigned long dxg_open_count; unsigned long system_properties_count; pthread_mutex_t hsakmt_mutex = PTHREAD_MUTEX_INITIALIZER; -bool is_dgpu; +bool hsakmt_is_dgpu; #ifndef PAGE_SIZE int PAGE_SIZE; diff --git a/libhsakmt.h b/libhsakmt.h index e34d4e10c9..9995026591 100644 --- a/libhsakmt.h +++ b/libhsakmt.h @@ -40,7 +40,7 @@ wsl::thunk::WDDMDevice* get_wddmdev(uint32_t node_id); extern unsigned long dxg_open_count; extern bool hsakmt_forked; extern pthread_mutex_t hsakmt_mutex; -extern bool is_dgpu; +extern bool hsakmt_is_dgpu; extern bool is_svm_api_supported; extern int zfb_support; extern int vendor_packet_process; diff --git a/memory.cpp b/memory.cpp index add31df673..950a5dedba 100644 --- a/memory.cpp +++ b/memory.cpp @@ -404,7 +404,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterMemoryWithFlags( if ((MemFlags.ui32.HostAccess != 1) || (MemFlags.ui32.NonPaged == 1)) return HSAKMT_STATUS_NOT_SUPPORTED; - if (!is_dgpu) + if (!hsakmt_is_dgpu) /* TODO: support mixed APU and dGPU configurations */ return HSAKMT_STATUS_NOT_SUPPORTED; diff --git a/topology.cpp b/topology.cpp index e53e1094a7..fa7d08a98a 100644 --- a/topology.cpp +++ b/topology.cpp @@ -390,8 +390,9 @@ err: void topology_setup_is_dgpu_param(HsaNodeProperties *props) { /* if we found a dGPU node, then treat the whole system as dGPU */ + /* noted that some APUs are also treated as dGPU in runtime */ if (!props->NumCPUCores && props->NumFComputeCores) - is_dgpu = true; + hsakmt_is_dgpu = true; } static HSAKMT_STATUS topology_get_cpu_model_name(HsaNodeProperties& props, @@ -1010,6 +1011,8 @@ HSAKMT_STATUS topology_take_snapshot(void) { goto err; } + topology_setup_is_dgpu_param(&temp_props[i].node); + if (temp_props[i].node.NumCPUCores) topology_get_cpu_model_name(temp_props[i].node, cpuinfo); @@ -1176,8 +1179,6 @@ hsaKmtAcquireSystemProperties(HsaSystemProperties *SystemProperties) { assert(g_system); // err = fmm_init_process_apertures(g_system->NumNodes); - // TODO: Determine if it is a dGPU - is_dgpu = true; if (err != HSAKMT_STATUS_SUCCESS) goto init_process_apertures_failed;