* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef INC_FRAMEWORK_MEMORY_MEMORY_API_H_
#define INC_FRAMEWORK_MEMORY_MEMORY_API_H_
#include "ge/ge_api_error_codes.h"
#include "graph/compute_graph.h"
#include "runtime/mem.h"
namespace ge {
enum MemStorageType {
HBM = 0,
RDMA_HBM,
HOST_DDR,
HOST_SVM,
};
struct HostVarInfo {
uint64_t base_addr;
uint64_t var_size;
};
struct TensorInfo {
std::string var_name;
std::vector<int64_t> dims;
DataType data_type;
};
GE_FUNC_VISIBILITY Status InitRdmaPool(size_t size, rtMemType_t mem_type = RT_MEMORY_HBM);
GE_FUNC_VISIBILITY Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info,
rtMemType_t mem_type = RT_MEMORY_HBM);
GE_FUNC_VISIBILITY Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uint64_t &memory_size);
GE_FUNC_VISIBILITY Status GetVarBaseAddrAndSize(const std::string &var_name, uint64_t &base_addr, uint64_t &var_size);
GE_FUNC_VISIBILITY Status GetVarBaseAddrAndSize(const char_t *var_name,
uint64_t &base_addr,
uint64_t &var_size);
* @brief
* @param [in] graph
* @param [out] available_mem:graph mem size
*/
GE_FUNC_VISIBILITY Status GetGraphAvailableMemory(const ComputeGraphPtr &graph, uint64_t &available_mem);
* @brief
* @param [in] session_id
* @param [out] var_size:session variables mem size
* @param [out] graphs_mem_info: graphs mem info, include key:graph_id; value: {feature_map_size, const_size}
*/
GE_FUNC_VISIBILITY Status GetSessionMemInfo(const uint64_t session_id, uint64_t &var_size,
std::map<uint32_t, std::vector<uint64_t>> &graphs_mem_info);
}
#endif