amd-smi: fix cpu specific apis and header
1. provide prototype and documentation for esmi specific api. define structures and update classes as required 2. update cmake files as required and add esmi api to the amdsmi esmi integration example. Change-Id: I753ec176f9b381e74c9646525dfd9075237bf8d9
This commit is contained in:
committed by
khashaik
parent
8f3861e1d9
commit
65eed73f4d
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2023, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AMD_SMI_INCLUDE_AMD_SMI_CPU_CORE_H_
|
||||
#define AMD_SMI_INCLUDE_AMD_SMI_CPU_CORE_H_
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "amd_smi/amdsmi.h"
|
||||
#include "amd_smi/impl/amd_smi_processor.h"
|
||||
|
||||
namespace amd {
|
||||
namespace smi {
|
||||
|
||||
/*Subclass CPU Core*/
|
||||
class AMDSmiCpuCore : public AMDSmiProcessor {
|
||||
public:
|
||||
explicit AMDSmiCpuCore(const uint32_t& core_idx):AMDSmiProcessor(AMD_CPU_CORE),core_idx_(core_idx) {}
|
||||
|
||||
virtual ~AMDSmiCpuCore() {}
|
||||
|
||||
const uint32_t& get_core_id() const { return core_idx_; }
|
||||
void add_processor(AMDSmiProcessor* processor) { processors_.push_back(processor); }
|
||||
std::vector<AMDSmiProcessor*>& get_processors() { return processors_;}
|
||||
amdsmi_status_t get_processor_count(uint32_t* processor_count) const;
|
||||
|
||||
private:
|
||||
uint32_t core_idx_;
|
||||
std::vector<AMDSmiProcessor*> processors_;
|
||||
};
|
||||
|
||||
} // namespace smi
|
||||
} // namespace amd
|
||||
|
||||
#endif // AMD_SMI_INCLUDE_AMD_SMI_CPU_CORE_H_
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2023, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AMD_SMI_INCLUDE_AMD_SMI_CPU_SOCKET_H_
|
||||
#define AMD_SMI_INCLUDE_AMD_SMI_CPU_SOCKET_H_
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "amd_smi/amdsmi.h"
|
||||
#include "amd_smi/impl/amd_smi_processor.h"
|
||||
#include "amd_smi/impl/amd_smi_cpu_core.h"
|
||||
|
||||
namespace amd {
|
||||
namespace smi {
|
||||
|
||||
/*Subclass CPU Socket*/
|
||||
class AMDSmiCpuSocket : public AMDSmiProcessor {
|
||||
public:
|
||||
explicit AMDSmiCpuSocket(const uint32_t& id):AMDSmiProcessor(AMD_CPU),socket_identifier_(id) {}
|
||||
|
||||
virtual ~AMDSmiCpuSocket() {}
|
||||
|
||||
amdsmi_status_t get_cpu_vendor() { return AMDSMI_STATUS_SUCCESS; }
|
||||
uint32_t get_cpu_id() const { return cpu_id_; }
|
||||
const uint32_t& get_socket_id() const { return socket_identifier_; }
|
||||
|
||||
void add_processor(AMDSmiProcessor* processor) { processors_.push_back(processor); }
|
||||
std::vector<AMDSmiProcessor*>& get_processors() { return processors_;}
|
||||
amdsmi_status_t get_processor_count(uint32_t* processor_count) const;
|
||||
|
||||
private:
|
||||
uint32_t cpu_id_;
|
||||
uint32_t socket_identifier_;
|
||||
std::vector<AMDSmiProcessor*> processors_;
|
||||
};
|
||||
|
||||
} // namespace smi
|
||||
} // namespace amd
|
||||
|
||||
#endif // AMD_SMI_INCLUDE_AMD_SMI_CPU_SOCKET_H_
|
||||
@@ -44,6 +44,7 @@
|
||||
#ifndef AMD_SMI_INCLUDE_AMD_SMI_PROCESSOR_H_
|
||||
#define AMD_SMI_INCLUDE_AMD_SMI_PROCESSOR_H_
|
||||
|
||||
#include <string>
|
||||
#include "amd_smi/amdsmi.h"
|
||||
|
||||
namespace amd {
|
||||
@@ -51,14 +52,18 @@ namespace smi {
|
||||
|
||||
class AMDSmiProcessor {
|
||||
public:
|
||||
explicit AMDSmiProcessor(processor_type_t processor) : processor_type_(processor) {}
|
||||
explicit AMDSmiProcessor(processor_type_t type) : processor_type_(type) {}
|
||||
explicit AMDSmiProcessor(processor_type_t type, uint32_t index) : processor_type_(type), pindex_(index) {}
|
||||
explicit AMDSmiProcessor(const std::string& id) : processor_identifier_(id) {}
|
||||
virtual ~AMDSmiProcessor() {}
|
||||
processor_type_t get_processor_type() const { return processor_type_;}
|
||||
const std::string& get_processor_id() const { return processor_identifier_;}
|
||||
uint32_t get_processor_index() const { return pindex_;}
|
||||
private:
|
||||
processor_type_t processor_type_;
|
||||
uint32_t pindex_;
|
||||
std::string processor_identifier_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace smi
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -56,14 +56,46 @@ namespace smi {
|
||||
class AMDSmiSocket {
|
||||
public:
|
||||
explicit AMDSmiSocket(const std::string& id) : socket_identifier_(id) {}
|
||||
explicit AMDSmiSocket(uint32_t index) : sindex_(index) {}
|
||||
~AMDSmiSocket();
|
||||
const std::string& get_socket_id() const { return socket_identifier_;}
|
||||
void add_processor(AMDSmiProcessor* processor) { processors_.push_back(processor); }
|
||||
uint32_t get_socket_index() { return sindex_;}
|
||||
void add_processor(AMDSmiProcessor* processor) {
|
||||
switch (processor->get_processor_type()) {
|
||||
case AMD_GPU:
|
||||
processors_.push_back(processor);
|
||||
break;
|
||||
case AMD_CPU:
|
||||
cpu_processors_.push_back(processor);
|
||||
break;
|
||||
case AMD_CPU_CORE:
|
||||
cpu_core_processors_.push_back(processor);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::vector<AMDSmiProcessor*>& get_processors() { return processors_;}
|
||||
std::vector<AMDSmiProcessor*>& get_processors(processor_type_t type) {
|
||||
switch (type) {
|
||||
case AMD_GPU:
|
||||
return processors_;
|
||||
case AMD_CPU:
|
||||
return cpu_processors_;
|
||||
case AMD_CPU_CORE:
|
||||
return cpu_core_processors_;
|
||||
default:
|
||||
return processors_;
|
||||
}
|
||||
}
|
||||
amdsmi_status_t get_processor_count(uint32_t* processor_count) const;
|
||||
amdsmi_status_t get_processor_count(processor_type_t type, uint32_t* processor_count) const;
|
||||
private:
|
||||
uint32_t sindex_;
|
||||
std::string socket_identifier_;
|
||||
std::vector<AMDSmiProcessor*> processors_;
|
||||
std::vector<AMDSmiProcessor*> cpu_processors_;
|
||||
std::vector<AMDSmiProcessor*> cpu_core_processors_;
|
||||
};
|
||||
|
||||
} // namespace smi
|
||||
|
||||
@@ -50,9 +50,6 @@
|
||||
#include "amd_smi/impl/amd_smi_socket.h"
|
||||
#include "amd_smi/impl/amd_smi_processor.h"
|
||||
#include "amd_smi/impl/amd_smi_drm.h"
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
#include "amd_smi/impl/amd_smi_cpu_socket.h"
|
||||
#endif
|
||||
|
||||
namespace amd {
|
||||
namespace smi {
|
||||
@@ -78,25 +75,6 @@ class AMDSmiSystem {
|
||||
amdsmi_status_t gpu_index_to_handle(uint32_t gpu_index,
|
||||
amdsmi_processor_handle* processor_handle);
|
||||
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
std::vector<AMDSmiCpuSocket*>& get_cpu_sockets() {return cpu_sockets_;}
|
||||
|
||||
amdsmi_status_t handle_to_cpusocket(amdsmi_cpusocket_handle cpusock_handle,
|
||||
AMDSmiCpuSocket** cpu_socket);
|
||||
|
||||
amdsmi_status_t cpu_index_to_handle(uint32_t cpu_index,
|
||||
amdsmi_cpusocket_handle* cpusock_handle);
|
||||
|
||||
amdsmi_status_t get_cpu_sockets(uint32_t *socks);
|
||||
|
||||
amdsmi_status_t get_cpu_cores(uint32_t *cpus);
|
||||
|
||||
amdsmi_status_t get_threads_per_core(uint32_t *threads);
|
||||
|
||||
amdsmi_status_t get_cpu_family(uint32_t *family);
|
||||
|
||||
amdsmi_status_t get_cpu_model(uint32_t *model);
|
||||
#endif
|
||||
private:
|
||||
AMDSmiSystem() : init_flag_(AMDSMI_INIT_AMD_GPUS) {}
|
||||
|
||||
@@ -106,23 +84,12 @@ class AMDSmiSystem {
|
||||
*/
|
||||
amdsmi_status_t get_gpu_socket_id(uint32_t index, std::string& socketid);
|
||||
amdsmi_status_t populate_amd_gpu_devices();
|
||||
amdsmi_status_t populate_amd_cpus();
|
||||
uint64_t init_flag_;
|
||||
AMDSmiDrm drm_;
|
||||
std::vector<AMDSmiSocket*> sockets_;
|
||||
std::set<AMDSmiProcessor*> processors_; // Track valid processors
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
amdsmi_status_t populate_amd_cpus();
|
||||
std::vector<AMDSmiCpuSocket*> cpu_sockets_;
|
||||
static uint32_t sockets;
|
||||
static uint32_t cpus;
|
||||
static uint32_t threads;
|
||||
static uint32_t family;
|
||||
static uint32_t model;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace smi
|
||||
} // namespace amd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user