Skip to content

Commit 2f2a324

Browse files
committed
[AMD-SMI] Wrap ESMI functions in amdsmi_go_shim
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
1 parent 3fea6f4 commit 2f2a324

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

projects/amdsmi/goamdsmi_shim/smiwrapper/amdsmi_go_shim.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ uint32_t goamdsmi_cpu_threads_per_core_get() {
372372
bool readSuccess = false;
373373
uint32_t threads_per_core_temp = GOAMDSMI_VALUE_0;
374374

375+
#ifdef ENABLE_ESMI_LIB
375376
if ((AMDSMI_STATUS_SUCCESS == amdsmi_get_threads_per_core(&threads_per_core_temp)))
376377
readSuccess = true;
378+
#endif
377379
if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_1)) {
378380
printf("AMDSMI, %s, CpuThreadsPerCore:%lu\n", readSuccess ? "Success" : "Failed",
379381
(unsigned long)(threads_per_core_temp));
@@ -410,11 +412,13 @@ uint64_t goamdsmi_cpu_core_energy_get(uint32_t thread_index) {
410412
uint64_t core_energy_temp = GOAMDSMI_UINT64_MAX;
411413
uint32_t physicalCore_index = thread_index % num_cpu_physicalCore_inAllSocket;
412414

415+
#ifdef ENABLE_ESMI_LIB
413416
if (AMDSMI_STATUS_SUCCESS ==
414417
amdsmi_get_cpu_core_energy(
415418
amdsmi_processor_handle_all_cpu_physicalCore_across_socket[physicalCore_index],
416419
&core_energy_temp))
417420
readSuccess = true;
421+
#endif
418422
if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_1)) {
419423
printf(
420424
"AMDSMI, %s for Thread:%d PC:%d, CpuCoreEnergy:%llu, CpuCoreEnergyJoules:%.6f, "
@@ -430,10 +434,14 @@ uint64_t goamdsmi_cpu_core_energy_get(uint32_t thread_index) {
430434
uint64_t goamdsmi_cpu_socket_energy_get(uint32_t socket_index) {
431435
bool readSuccess = false;
432436
uint64_t socket_energy_temp = GOAMDSMI_UINT64_MAX;
437+
#ifdef ENABLE_ESMI_LIB
433438
if ((AMDSMI_STATUS_SUCCESS ==
434439
amdsmi_get_cpu_socket_energy(amdsmi_processor_handle_all_cpu_across_socket[socket_index],
435440
&socket_energy_temp)))
436441
readSuccess = true;
442+
#else
443+
(void)socket_index;
444+
#endif
437445
if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_1)) {
438446
printf(
439447
"AMDSMI, %s for Socket:%d, CpuSocketEnergy:%llu, CpuSocketEnergyJoules:%.6f, "
@@ -448,10 +456,14 @@ uint64_t goamdsmi_cpu_socket_energy_get(uint32_t socket_index) {
448456
uint32_t goamdsmi_cpu_prochot_status_get(uint32_t socket_index) {
449457
bool readSuccess = false;
450458
uint32_t prochot_temp = GOAMDSMI_UINT32_MAX;
459+
#ifdef ENABLE_ESMI_LIB
451460
if ((AMDSMI_STATUS_SUCCESS ==
452461
amdsmi_get_cpu_prochot_status(amdsmi_processor_handle_all_cpu_across_socket[socket_index],
453462
&prochot_temp)))
454463
readSuccess = true;
464+
#else
465+
(void)socket_index;
466+
#endif
455467
if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_1)) {
456468
printf("AMDSMI, %s for Socket:%d, CpuProchotStatus:%lu\n", readSuccess ? "Success" : "Failed",
457469
socket_index, (unsigned long)(prochot_temp));
@@ -495,11 +507,13 @@ uint32_t goamdsmi_cpu_core_boostlimit_get(uint32_t thread_index) {
495507
uint32_t core_boostlimit_temp = GOAMDSMI_UINT32_MAX;
496508
uint32_t physicalCore_index = thread_index % num_cpu_physicalCore_inAllSocket;
497509

510+
#ifdef ENABLE_ESMI_LIB
498511
if (AMDSMI_STATUS_SUCCESS ==
499512
amdsmi_get_cpu_core_boostlimit(
500513
amdsmi_processor_handle_all_cpu_physicalCore_across_socket[physicalCore_index],
501514
&core_boostlimit_temp))
502515
readSuccess = true;
516+
#endif
503517
if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_1)) {
504518
printf("AMDSMI, %s for Thread:%d PC:%d, CpuCoreBoostLimit:%lu\n",
505519
readSuccess ? "Success" : "Failed", thread_index, physicalCore_index,
@@ -676,14 +690,14 @@ uint64_t goamdsmi_gpu_dev_power_get(uint32_t dv_ind) {
676690
uint64_t goamdsmi_gpu_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor, uint32_t metric) {
677691
bool readSuccess = false;
678692
uint64_t gpu_temperature = GOAMDSMI_UINT64_MAX;
679-
uint64_t gpu_temperature_temp = GOAMDSMI_UINT64_MAX;
693+
int64_t gpu_temperature_temp = (int64_t)GOAMDSMI_UINT64_MAX;
680694

681695
if ((dv_ind < num_gpu_devices_inAllSocket) &&
682696
(AMDSMI_STATUS_SUCCESS ==
683697
amdsmi_get_temp_metric(amdsmi_processor_handle_all_gpu_device_across_socket[dv_ind], sensor,
684698
metric, &gpu_temperature_temp))) {
685699
readSuccess = true;
686-
gpu_temperature = gpu_temperature_temp;
700+
gpu_temperature = (uint64_t)gpu_temperature_temp;
687701
gpu_temperature =
688702
(gpu_temperature) * 1000; // to maintain backward compatibility with old ROCM SMI
689703
if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_1)) {

0 commit comments

Comments
 (0)