* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* 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 FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* -------------------------------------------------------------------------
*/
#ifndef ACL_HOOKS_H
#define ACL_HOOKS_H
#include <cstdint>
#include <cstddef>
#include <dlfcn.h>
#include "vallina_symbol.h"
#include "atb_hooks/atb_stub.h"
namespace MemScope {
constexpr int ACL_SUCCESS = 0;
constexpr int ACL_ERROR_INTERNAL_ERROR = 500000;
const constexpr int ACL_ERROR_RT_FAILURE = 500003;
struct AclLibLoader {
static void *Load(void)
{
return LibLoad("libascendcl.so");
}
};
}
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_MSC_VER)
#ifdef FUNC_VISIBILITY
#define ACL_FUNC_VISIBILITY _declspec(dllexport)
#else
#define ACL_FUNC_VISIBILITY
#endif
#else
#ifdef FUNC_VISIBILITY
#define ACL_FUNC_VISIBILITY __attribute__((visibility("default")))
#else
#define ACL_FUNC_VISIBILITY
#endif
#endif
typedef int aclError;
typedef void *aclrtStream;
typedef enum aclrtMemcpyKind {
ACL_MEMCPY_HOST_TO_HOST,
ACL_MEMCPY_HOST_TO_DEVICE,
ACL_MEMCPY_DEVICE_TO_HOST,
ACL_MEMCPY_DEVICE_TO_DEVICE,
} aclrtMemcpyKind;
typedef enum aclrtMemAttr {
ACL_DDR_MEM,
ACL_HBM_MEM,
ACL_DDR_MEM_HUGE,
ACL_DDR_MEM_NORMAL,
ACL_HBM_MEM_HUGE,
ACL_HBM_MEM_NORMAL,
ACL_DDR_MEM_P2P_HUGE,
ACL_DDR_MEM_P2P_NORMAL,
ACL_HBM_MEM_P2P_HUGE,
ACL_HBM_MEM_P2P_NORMAL,
ACL_HBM_MEM_HUGE1G,
ACL_HBM_MEM_P2P_HUGE1G
} aclrtMemAttr;
ACL_FUNC_VISIBILITY aclError aclInit(const char *configPath);
ACL_FUNC_VISIBILITY aclError aclFinalize();
aclError aclrtMemcpy(void *dst, size_t destMax, const void *src, size_t count, aclrtMemcpyKind kind);
aclError aclrtSynchronizeStream(aclrtStream stream);
aclError aclrtGetMemInfo(aclrtMemAttr attr, size_t *free, size_t *total);
#ifdef __cplusplus
}
#endif
#endif