libhsakmt: Add MarketingName and AMDName for all nodes - CPU & GPU
HSA thunk API is currently reporting engineering name to MarketingName and returning NULL when querying for AMDName. -Change current name reporting from MarketingName to AMDName. -Use libpci to get MarketingName Change-Id: I819a6de7b067a2e724a6695e7d800274b83a71f8 Signed-off-by: Lan Xiao <Lan.Xiao@amd.com>
Этот коммит содержится в:
@@ -1,7 +1,7 @@
|
||||
Package: hsakmt-rocm-dev
|
||||
Architecture: amd64
|
||||
Maintainer: Advanced Micro Devices Inc.
|
||||
Depends:
|
||||
Depends:libpci3
|
||||
Priority: optional
|
||||
Version: $version
|
||||
Description: Thunk library for AMD KFD
|
||||
|
||||
@@ -195,7 +195,7 @@ typedef union
|
||||
// of throughput compute units (= SIMDs) associated with a H-NUMA node.
|
||||
//
|
||||
|
||||
#define HSA_PUBLIC_NAME_SIZE 128
|
||||
#define HSA_PUBLIC_NAME_SIZE 64 // Marketing name string size
|
||||
|
||||
typedef struct _HsaNodeProperties
|
||||
{
|
||||
@@ -248,6 +248,8 @@ typedef struct _HsaNodeProperties
|
||||
|
||||
HSAuint16 MarketingName[HSA_PUBLIC_NAME_SIZE]; // Public name of the "device" on the node (board or APU name).
|
||||
// Unicode string
|
||||
HSAuint8 AMDName[HSA_PUBLIC_NAME_SIZE]; //CAL Name of the "device", ASCII
|
||||
HSAuint8 Reserved[64];
|
||||
} HsaNodeProperties;
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ ifneq ($(REL),1)
|
||||
CFLAGS += -ggdb
|
||||
endif
|
||||
|
||||
LDFLAGS += -lrt -pthread -Wl,--version-script=libhsakmt.ver -Wl,-soname=$(LIB_NAME).$(LIB_MAJOR_VER) -Wl,-z,nodelete
|
||||
LDFLAGS += -lrt -pthread -lpci -Wl,--version-script=libhsakmt.ver -Wl,-soname=$(LIB_NAME).$(LIB_MAJOR_VER) -Wl,-z,nodelete
|
||||
|
||||
OBJS = debug.o globals.o memory.o perfctr.o time.o version.o \
|
||||
events.o openclose.o queues.o topology.o fmm.o pmc_table.o \
|
||||
@@ -55,7 +55,7 @@ BUILDDIR = $(BUILD_ROOT)/$(MAKECMDGOALS)
|
||||
TARGET = $(addprefix $(BUILDDIR)/,$(OBJS))
|
||||
|
||||
$(BUILDDIR)/$(LIB_NAME).$(LIB_MAJOR_VER): $(TARGET)
|
||||
gcc -shared $(LDFLAGS) -o $@ $^
|
||||
gcc -shared -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(BUILDDIR)/$(LIB_NAME): $(BUILDDIR)/$(LIB_NAME).$(LIB_MAJOR_VER)
|
||||
@ln -sf $(LIB_NAME).$(LIB_MAJOR_VER) $(BUILDDIR)/$(LIB_NAME)
|
||||
@@ -73,6 +73,7 @@ ROCM_LIB = $(ROCM_ROOT)/lib
|
||||
ROCM_INCLUDE = $(ROCM_ROOT)/include
|
||||
INSTALL_LIB_DIR = libhsakmt/lib
|
||||
INSTALL_INCLUDE_DIR = libhsakmt/include/libhsakmt
|
||||
|
||||
export PACKAGE_DIR
|
||||
|
||||
package-common: lnx64a
|
||||
@@ -106,7 +107,6 @@ lnx64a: $(BUILDDIR)/$(LIB_NAME)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_ROOT)
|
||||
|
||||
#Rule
|
||||
$(BUILDDIR)/%.o: %.c ../include/hsakmt.h ../include/hsakmttypes.h ../include/linux/kfd_ioctl.h
|
||||
@echo Compiling $^
|
||||
|
||||
+6
-1
@@ -33,6 +33,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
#define NON_VALID_GPU_ID 0
|
||||
|
||||
@@ -1053,6 +1054,7 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes)
|
||||
struct kfd_process_device_apertures * process_apertures;
|
||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
||||
char *disableCache;
|
||||
struct pci_access *pacc;
|
||||
|
||||
/* If HSA_DISABLE_CACHE is set to a non-0 value, disable caching */
|
||||
disableCache = getenv("HSA_DISABLE_CACHE");
|
||||
@@ -1070,8 +1072,10 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes)
|
||||
* 0 by calloc. This is necessary because this function
|
||||
* gets called before hsaKmtAcquireSystemProperties() is called.*/
|
||||
gpu_mem_count = 0;
|
||||
pacc = pci_alloc();
|
||||
pci_init(pacc);
|
||||
while (i < NumNodes) {
|
||||
ret = topology_sysfs_get_node_props(i, &props, &gpu_id);
|
||||
ret = topology_sysfs_get_node_props(i, &props, &gpu_id, pacc);
|
||||
if (ret != HSAKMT_STATUS_SUCCESS)
|
||||
goto sysfs_parse_failed;
|
||||
|
||||
@@ -1092,6 +1096,7 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes)
|
||||
}
|
||||
i++;
|
||||
}
|
||||
pci_cleanup(pacc);
|
||||
|
||||
/* The ioctl will also return Number of Nodes if args.kfd_process_device_apertures_ptr
|
||||
* is set to NULL. This is not required since Number of nodes is already known. Kernel
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
extern int kfd_fd;
|
||||
extern unsigned long kfd_open_count;
|
||||
@@ -68,7 +69,8 @@ HSAKMT_STATUS validate_nodeid_array(uint32_t **gpu_id_array,
|
||||
uint32_t NumberOfNodes, uint32_t *NodeArray);
|
||||
|
||||
HSAKMT_STATUS topology_sysfs_get_gpu_id(uint32_t node_id, uint32_t *gpu_id);
|
||||
HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties *props, uint32_t *gpu_id);
|
||||
HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties *props,
|
||||
uint32_t *gpu_id, struct pci_access* pacc);
|
||||
HSAKMT_STATUS topology_sysfs_get_system_props(HsaSystemProperties *props);
|
||||
bool topology_is_dgpu(uint16_t device_id);
|
||||
|
||||
|
||||
+27
-9
@@ -34,6 +34,7 @@
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <sched.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
#include "libhsakmt.h"
|
||||
#include "fmm.h"
|
||||
@@ -81,7 +82,7 @@ static struct hsa_gfxip_table {
|
||||
unsigned char minor; // GFXIP Minor engine version
|
||||
unsigned char stepping; // GFXIP Stepping info
|
||||
unsigned char is_dgpu; // Predicate for dGPU devices
|
||||
const char* marketing_name; // Marketing Name of the device
|
||||
const char* amd_name; // CALName of the device
|
||||
} gfxip_lookup_table[] = {
|
||||
/* Kaveri Family */
|
||||
{ 0x1304, 7, 0, 0, 0, "Spectre" },
|
||||
@@ -433,7 +434,7 @@ bool topology_is_dgpu(uint16_t device_id)
|
||||
static HSAKMT_STATUS
|
||||
topology_get_cpu_model_name(HsaNodeProperties *props) {
|
||||
FILE *fd;
|
||||
char read_buf[256], cpu_model_name[128];
|
||||
char read_buf[256], cpu_model_name[HSA_PUBLIC_NAME_SIZE];
|
||||
const char *p;
|
||||
uint32_t i, apic_id;
|
||||
|
||||
@@ -478,6 +479,8 @@ topology_get_cpu_model_name(HsaNodeProperties *props) {
|
||||
|
||||
/* Set CPU model name only if corresponding apic id */
|
||||
if (props->CComputeIdLo == apic_id) {
|
||||
/* Retrieve the CAL name of CPU node */
|
||||
strncpy( (char *) props->AMDName, cpu_model_name, sizeof(props->AMDName));
|
||||
/* Convert from UTF8 to UTF16 */
|
||||
for (i = 0; cpu_model_name[i] != '\0' && i < HSA_PUBLIC_NAME_SIZE - 1; i++)
|
||||
props->MarketingName[i] = cpu_model_name[i];
|
||||
@@ -542,7 +545,9 @@ static void topology_set_processor_vendor(void)
|
||||
}
|
||||
|
||||
HSAKMT_STATUS
|
||||
topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties *props, uint32_t *gpu_id) {
|
||||
topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties *props, uint32_t *gpu_id,
|
||||
struct pci_access* pacc )
|
||||
{
|
||||
FILE *fd;
|
||||
char *read_buf, *p;
|
||||
char prop_name[256];
|
||||
@@ -552,6 +557,8 @@ topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties *props, uint32
|
||||
uint16_t fw_version = 0;
|
||||
int read_size;
|
||||
const struct hsa_gfxip_table* hsa_gfxip;
|
||||
char namebuf[HSA_PUBLIC_NAME_SIZE];
|
||||
const char* name;
|
||||
|
||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
||||
|
||||
@@ -652,15 +659,22 @@ topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties *props, uint32
|
||||
props->EngineId.ui32.Minor = hsa_gfxip->minor;
|
||||
props->EngineId.ui32.Stepping = hsa_gfxip->stepping;
|
||||
|
||||
if (!hsa_gfxip->marketing_name) {
|
||||
if (!hsa_gfxip->amd_name) {
|
||||
ret = HSAKMT_STATUS_ERROR;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Retrieve the marketing name of the node, convert UTF8 to UTF16 */
|
||||
for (i = 0; hsa_gfxip->marketing_name[i] != 0 && i < HSA_PUBLIC_NAME_SIZE - 1; i++)
|
||||
props->MarketingName[i] = hsa_gfxip->marketing_name[i];
|
||||
props->MarketingName[i] = 0;
|
||||
/* Retrieve the CAL name of the node */
|
||||
strncpy( (char *) props->AMDName, hsa_gfxip->amd_name, sizeof(props->AMDName) );
|
||||
/* Retrieve the marketing name of the node using pcilib,
|
||||
* convert UTF8 to UTF16
|
||||
*/
|
||||
name = pci_lookup_name(pacc, namebuf, sizeof(namebuf), PCI_LOOKUP_DEVICE,
|
||||
props->VendorId, props->DeviceId);
|
||||
|
||||
for (i = 0; name[i] != 0 && i < HSA_PUBLIC_NAME_SIZE - 1; i++)
|
||||
props->MarketingName[i] = name[i];
|
||||
props->MarketingName[i] = '\0';
|
||||
} else {
|
||||
/* Is CPU node */
|
||||
if (!props->NumFComputeCores || !props->DeviceId) {
|
||||
@@ -1357,6 +1371,7 @@ topology_take_snapshot(void)
|
||||
node_t *temp_nodes = 0;
|
||||
void *cpu_ci_list = NULL;
|
||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
||||
struct pci_access *pacc;
|
||||
|
||||
topology_set_processor_vendor();
|
||||
retry:
|
||||
@@ -1371,10 +1386,12 @@ retry:
|
||||
temp_nodes = calloc(sys_props.NumNodes * sizeof(node_t),1);
|
||||
if (!temp_nodes)
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
pacc = pci_alloc();
|
||||
pci_init(pacc);
|
||||
for (i = 0; i < sys_props.NumNodes; i++) {
|
||||
ret = topology_sysfs_get_node_props(i,
|
||||
&temp_nodes[i].node,
|
||||
&temp_nodes[i].gpu_id);
|
||||
&temp_nodes[i].gpu_id, pacc);
|
||||
if (ret != HSAKMT_STATUS_SUCCESS) {
|
||||
free_nodes(temp_nodes, i);
|
||||
goto err;
|
||||
@@ -1443,6 +1460,7 @@ retry:
|
||||
}
|
||||
|
||||
}
|
||||
pci_cleanup(pacc);
|
||||
}
|
||||
|
||||
/* The Kernel only creates one way direct link -
|
||||
|
||||
Ссылка в новой задаче
Block a user