libhsakmt: Implement HSA_FORCE_ASIC_TYPE to overwrite asic type
Force all the GPUs to a certain type, use the below command:
HSA_FORCE_ASIC_TYPE="10.1.0 1 gfx1010 14"
meaning major.minor.step dgpu asic_name asic_id
This will faciliate the cooperation across the teams for bringing up
ASICs which reuse existing device IDs.
Change-Id: I40fe4c9b46d3ccb3e38ea52250e80e82fb50fb0f
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
[ROCm/ROCR-Runtime commit: d6539ddc24]
Этот коммит содержится в:
коммит произвёл
Yong Zhao
родитель
cc050951de
Коммит
fab21d6d81
@@ -37,6 +37,10 @@ extern unsigned long kfd_open_count;
|
||||
extern pthread_mutex_t hsakmt_mutex;
|
||||
extern bool is_dgpu;
|
||||
|
||||
extern int force_asic;
|
||||
extern char force_asic_name[HSA_PUBLIC_NAME_SIZE];
|
||||
extern struct hsa_gfxip_table force_asic_entry;
|
||||
|
||||
#undef HSAKMTAPI
|
||||
#define HSAKMTAPI __attribute__((visibility ("default")))
|
||||
|
||||
@@ -90,20 +94,31 @@ extern int hsakmt_debug_level;
|
||||
|
||||
enum asic_family_type {
|
||||
CHIP_KAVERI = 0,
|
||||
CHIP_HAWAII,
|
||||
CHIP_CARRIZO,
|
||||
CHIP_TONGA,
|
||||
CHIP_FIJI,
|
||||
CHIP_POLARIS10,
|
||||
CHIP_POLARIS11,
|
||||
CHIP_POLARIS12,
|
||||
CHIP_VEGAM,
|
||||
CHIP_VEGA10,
|
||||
CHIP_VEGA12,
|
||||
CHIP_VEGA20,
|
||||
CHIP_RAVEN,
|
||||
CHIP_ARCTURUS,
|
||||
CHIP_NAVI10,
|
||||
CHIP_HAWAII, /* 1 */
|
||||
CHIP_CARRIZO, /* 2 */
|
||||
CHIP_TONGA, /* 3 */
|
||||
CHIP_FIJI, /* 4 */
|
||||
CHIP_POLARIS10, /* 5 */
|
||||
CHIP_POLARIS11, /* 6 */
|
||||
CHIP_POLARIS12, /* 7 */
|
||||
CHIP_VEGAM, /* 8 */
|
||||
CHIP_VEGA10, /* 9 */
|
||||
CHIP_VEGA12, /* 10 */
|
||||
CHIP_VEGA20, /* 11 */
|
||||
CHIP_RAVEN, /* 12 */
|
||||
CHIP_ARCTURUS, /* 13 */
|
||||
CHIP_NAVI10, /* 14 */
|
||||
CHIP_LAST
|
||||
};
|
||||
|
||||
struct hsa_gfxip_table {
|
||||
uint16_t device_id; // Device ID
|
||||
unsigned char major; // GFXIP Major engine version
|
||||
unsigned char minor; // GFXIP Minor engine version
|
||||
unsigned char stepping; // GFXIP Stepping info
|
||||
unsigned char is_dgpu; // Predicate for dGPU devices
|
||||
const char *amd_name; // CALName of the device
|
||||
enum asic_family_type asic_family; // Device family id
|
||||
};
|
||||
|
||||
#define IS_SOC15(chip) ((chip) >= CHIP_VEGA10)
|
||||
|
||||
@@ -82,7 +82,7 @@ static inline void init_page_size(void)
|
||||
PAGE_SHIFT = ffs(PAGE_SIZE) - 1;
|
||||
}
|
||||
|
||||
static void init_vars_from_env(void)
|
||||
static HSAKMT_STATUS init_vars_from_env(void)
|
||||
{
|
||||
char *envvar;
|
||||
int debug_level;
|
||||
@@ -104,6 +104,34 @@ static void init_vars_from_env(void)
|
||||
envvar = getenv("HSA_ZFB");
|
||||
if (envvar)
|
||||
zfb_support = atoi(envvar);
|
||||
|
||||
/* Force all the GPUs to a certain type, use the below command:
|
||||
* export HSA_FORCE_ASIC_TYPE="10.1.0 1 Navi10 14"
|
||||
* meaning major.minor.step dgpu asic_name asic_id
|
||||
*/
|
||||
envvar = getenv("HSA_FORCE_ASIC_TYPE");
|
||||
if (envvar) {
|
||||
uint32_t major, minor, step, dgpu, asic_family;
|
||||
|
||||
if ((sscanf(envvar, "%u.%u.%u %u %63s %u", &major, &minor, &step,
|
||||
&dgpu, force_asic_name, &asic_family) != 6)
|
||||
|| (major > 63 || minor > 255 || step > 255)
|
||||
|| dgpu > 1 || asic_family >= CHIP_LAST) {
|
||||
pr_err("HSA_FORCE_ASIC_TYPE %s is invalid\n", envvar);
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
}
|
||||
|
||||
force_asic_entry.major = major;
|
||||
force_asic_entry.minor = minor;
|
||||
force_asic_entry.stepping = step;
|
||||
force_asic_entry.is_dgpu = dgpu;
|
||||
|
||||
force_asic_entry.asic_family = asic_family;
|
||||
|
||||
force_asic = 1;
|
||||
}
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void)
|
||||
@@ -122,7 +150,9 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void)
|
||||
clear_after_fork();
|
||||
|
||||
if (kfd_open_count == 0) {
|
||||
init_vars_from_env();
|
||||
result = init_vars_from_env();
|
||||
if (result != HSAKMT_STATUS_SUCCESS)
|
||||
goto open_failed;
|
||||
|
||||
fd = open(kfd_device_name, O_RDWR | O_CLOEXEC);
|
||||
|
||||
|
||||
@@ -84,15 +84,13 @@ static const char *supported_processor_vendor_name[] = {
|
||||
static HSAKMT_STATUS topology_take_snapshot(void);
|
||||
static HSAKMT_STATUS topology_drop_snapshot(void);
|
||||
|
||||
static struct hsa_gfxip_table {
|
||||
uint16_t device_id; // Device ID
|
||||
unsigned char major; // GFXIP Major engine version
|
||||
unsigned char minor; // GFXIP Minor engine version
|
||||
unsigned char stepping; // GFXIP Stepping info
|
||||
unsigned char is_dgpu; // Predicate for dGPU devices
|
||||
const char *amd_name; // CALName of the device
|
||||
enum asic_family_type asic_family;
|
||||
} gfxip_lookup_table[] = {
|
||||
int force_asic;
|
||||
char force_asic_name[HSA_PUBLIC_NAME_SIZE];
|
||||
struct hsa_gfxip_table force_asic_entry = {
|
||||
.amd_name = force_asic_name,
|
||||
};
|
||||
|
||||
static const struct hsa_gfxip_table gfxip_lookup_table[] = {
|
||||
/* Kaveri Family */
|
||||
{ 0x1304, 7, 0, 0, 0, "Spectre", CHIP_KAVERI },
|
||||
{ 0x1305, 7, 0, 0, 0, "Spectre", CHIP_KAVERI },
|
||||
@@ -722,6 +720,9 @@ static const struct hsa_gfxip_table *find_hsa_gfxip_device(uint16_t device_id)
|
||||
{
|
||||
uint32_t i, table_size;
|
||||
|
||||
if (force_asic)
|
||||
return &force_asic_entry;
|
||||
|
||||
table_size = sizeof(gfxip_lookup_table)/sizeof(struct hsa_gfxip_table);
|
||||
for (i = 0; i < table_size; i++) {
|
||||
if (gfxip_lookup_table[i].device_id == device_id)
|
||||
|
||||
Ссылка в новой задаче
Block a user