| @@ -0,0 +1,73 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef INC_EXTERNAL_ACL_ACL_H_ | |||||
| #define INC_EXTERNAL_ACL_ACL_H_ | |||||
| #include "acl_rt.h" | |||||
| #include "acl_op.h" | |||||
| #include "acl_mdl.h" | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| // Current version is 1.0.0 | |||||
| #define ACL_MAJOR_VERSION 1 | |||||
| #define ACL_MINOR_VERSION 0 | |||||
| #define ACL_PATCH_VERSION 0 | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief acl initialize | |||||
| * | |||||
| * @par Restriction | |||||
| * The aclInit interface can be called only once in a process | |||||
| * @param configPath [IN] the config path,it can be NULL | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclInit(const char *configPath); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief acl finalize | |||||
| * | |||||
| * @par Restriction | |||||
| * Need to call aclFinalize before the process exits. | |||||
| * After calling aclFinalize,the services cannot continue to be used normally. | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclFinalize(); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief query ACL interface version | |||||
| * | |||||
| * @param majorVersion[OUT] ACL interface major version | |||||
| * @param minorVersion[OUT] ACL interface minor version | |||||
| * @param patchVersion[OUT] ACL interface patch version | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetVersion(int32_t *majorVersion, int32_t *minorVersion, int32_t *patchVersion); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif // INC_EXTERNAL_ACL_ACL_H_ | |||||
| @@ -223,6 +223,29 @@ ACL_FUNC_VISIBILITY aclDataBuffer *aclCreateDataBuffer(void *data, size_t size); | |||||
| */ | */ | ||||
| ACL_FUNC_VISIBILITY aclError aclDestroyDataBuffer(const aclDataBuffer *dataBuffer); | ACL_FUNC_VISIBILITY aclError aclDestroyDataBuffer(const aclDataBuffer *dataBuffer); | ||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief update new data of aclDataBuffer | |||||
| * | |||||
| * @param dataBuffer [OUT] pointer to aclDataBuffer | |||||
| * @li The old data need to be released by the user, otherwise it may occur memory leak leakage | |||||
| * call aclGetDataBufferAddr interface to get old data address | |||||
| * call aclrtFree interface to release memory | |||||
| * | |||||
| * @param data [IN] pointer to new data | |||||
| * @li Need to be managed by the user, | |||||
| * call aclrtMalloc interface to apply for memory, | |||||
| * call aclrtFree interface to release memory | |||||
| * | |||||
| * @param size [IN] size of data in bytes | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtMalloc | aclrtFree | aclGetDataBufferAddr | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclUpdateDataBuffer(aclDataBuffer *dataBuffer, void *data, size_t size); | |||||
| /** | /** | ||||
| * @ingroup AscendCL | * @ingroup AscendCL | ||||
| * @brief get data address from aclDataBuffer | * @brief get data address from aclDataBuffer | ||||
| @@ -547,6 +570,19 @@ ACL_FUNC_VISIBILITY void *aclGetTensorDescAddress(const aclTensorDesc *desc); | |||||
| */ | */ | ||||
| ACL_FUNC_VISIBILITY aclError aclSetTensorDynamicInput(aclTensorDesc *desc, const char *dynamicInputName); | ACL_FUNC_VISIBILITY aclError aclSetTensorDynamicInput(aclTensorDesc *desc, const char *dynamicInputName); | ||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Set const data specified by the tensor description | |||||
| * | |||||
| * @param desc [OUT] pointer to the instance of aclTensorDesc | |||||
| * @param dataBuffer [IN] pointer to the const databuffer | |||||
| * @param length [IN] the length of const databuffer | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclSetTensorConst(aclTensorDesc *desc, void *dataBuffer, size_t length); | |||||
| /** | /** | ||||
| * @ingroup AscendCL | * @ingroup AscendCL | ||||
| * @brief an interface for users to output APP logs | * @brief an interface for users to output APP logs | ||||
| @@ -0,0 +1,323 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef INC_EXTERNAL_ACL_PROF_H_ | |||||
| #define INC_EXTERNAL_ACL_PROF_H_ | |||||
| #include "acl_base.h" | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| #define ACL_PROF_ACL_API 0x0001 | |||||
| #define ACL_PROF_TASK_TIME 0x0002 | |||||
| #define ACL_PROF_AICORE_METRICS 0x0004 | |||||
| #define ACL_PROF_AICPU_TRACE 0x0008 | |||||
| #define ACL_PROF_MAX_OP_NAME_LEN 257 | |||||
| #define ACL_PROF_MAX_OP_TYPE_LEN 65 | |||||
| typedef enum { | |||||
| ACL_AICORE_ARITHMATIC_THROUGHPUT = 0, | |||||
| ACL_AICORE_ARITHMETIC_UTILIZATION = 0, | |||||
| ACL_AICORE_PIPE_UTILIZATION = 1, | |||||
| ACL_AICORE_MEMORY_BANDWIDTH = 2, | |||||
| ACL_AICORE_L0B_AND_WIDTH = 3, | |||||
| ACL_AICORE_RESOURCE_CONFLICT_RATIO = 4, | |||||
| ACL_AICORE_NONE = 0xFF | |||||
| } aclprofAicoreMetrics; | |||||
| typedef struct aclprofConfig aclprofConfig; | |||||
| typedef struct aclprofStopConfig aclprofStopConfig; | |||||
| typedef struct aclprofAicoreEvents aclprofAicoreEvents; | |||||
| typedef struct aclprofSubscribeConfig aclprofSubscribeConfig; | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief profiling initialize | |||||
| * | |||||
| * @param profilerResultPath [IN] path of profiling result | |||||
| * @param length [IN] length of profilerResultPath | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofFinalize | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofInit(const char *profilerResultPath, size_t length); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief profiling finalize | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofInit | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofFinalize(); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Start profiling modules by profilerConfig | |||||
| * | |||||
| * @param profilerConfig [IN] config of profiling | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofStop | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofStart(const aclprofConfig *profilerConfig); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Create data of type aclprofConfig | |||||
| * | |||||
| * @param deviceIdList [IN] list of device id | |||||
| * @param deviceNums [IN] number of devices | |||||
| * @param aicoreMetrics [IN] type of aicore metrics | |||||
| * @param aicoreEvents [IN] pointer to aicore events, only support NULL now | |||||
| * @param dataTypeConfig [IN] config modules need profiling | |||||
| * | |||||
| * @retval the aclprofConfig pointer | |||||
| * | |||||
| * @see aclprofDestroyConfig | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclprofConfig *aclprofCreateConfig(uint32_t *deviceIdList, uint32_t deviceNums, | |||||
| aclprofAicoreMetrics aicoreMetrics, | |||||
| aclprofAicoreEvents *aicoreEvents, uint64_t dataTypeConfig); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Destroy data of type aclprofConfig | |||||
| * | |||||
| * @param profilerConfig [IN] config of profiling | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofCreateConfig | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofDestroyConfig(const aclprofConfig *profilerConfig); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief stop profiling modules by stopProfilingConfig | |||||
| * | |||||
| * @param profilerConfig [IN] pointer to stop config of profiling | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofStart | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofStop(const aclprofConfig *profilerConfig); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief subscribe profiling data of model | |||||
| * | |||||
| * @param modelId [IN] the model id subscribed | |||||
| * @param profSubscribeConfig [IN] pointer to config of model subscribe | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofModelUnSubscribe | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofModelSubscribe(uint32_t modelId, const aclprofSubscribeConfig *profSubscribeConfig); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief unsubscribe profiling data of model | |||||
| * | |||||
| * @param modelId [IN] the model id unsubscribed | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofModelSubscribe | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofModelUnSubscribe(uint32_t modelId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief create subscribe config | |||||
| * | |||||
| * @param timeInfoSwitch [IN] switch whether get time info from model | |||||
| * @param aicoreMetrics [IN] aicore metrics | |||||
| * @param fd [IN] pointer to write pipe | |||||
| * | |||||
| * @retval the aclprofSubscribeConfig pointer | |||||
| * | |||||
| * @see aclprofDestroySubscribeConfig | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclprofSubscribeConfig *aclprofCreateSubscribeConfig(int8_t timeInfoSwitch, | |||||
| aclprofAicoreMetrics aicoreMetrics, void *fd); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief destroy subscribe config | |||||
| * | |||||
| * @param profSubscribeConfig [IN] subscribe config | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclprofCreateSubscribeConfig | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofDestroySubscribeConfig(const aclprofSubscribeConfig *profSubscribeConfig); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief create subscribe config | |||||
| * | |||||
| * @param opDescSize [OUT] size of op desc | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpDescSize(size_t *opDescSize); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get op number from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param opNumber [OUT] op number of subscription data | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpNum(const void *opInfo, size_t opInfoLen, uint32_t *opNumber); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get op type from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * @param opType [OUT] obtained op type string | |||||
| * @param opTypeLen [IN] obtained length of op type string | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpType(const void *opInfo, size_t opInfoLen, uint32_t index, char *opType, | |||||
| size_t opTypeLen); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get op type from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * @param opName [OUT] obtained op name string | |||||
| * @param opNameLen [IN] obtained length of op name string | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclprofGetOpName(const void *opInfo, size_t opInfoLen, uint32_t index, char *opName, | |||||
| size_t opNameLen); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get start time of specified op from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * | |||||
| * @retval start time(us) of specified op with timestamp | |||||
| * @retval 0 for failed | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpStart(const void *opInfo, size_t opInfoLen, uint32_t index); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get end time of specified op from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * | |||||
| * @retval end time(us) of specified op with timestamp | |||||
| * @retval 0 for failed | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpEnd(const void *opInfo, size_t opInfoLen, uint32_t index); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get excution time of specified op from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * | |||||
| * @retval execution time(us) of specified op with timestamp | |||||
| * @retval 0 for failed | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpDuration(const void *opInfo, size_t opInfoLen, uint32_t index); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get model id from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * | |||||
| * @retval model id of subscription data | |||||
| * @retval 0 for failed | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY size_t aclprofGetModelId(const void *opInfo, size_t opInfoLen, uint32_t index); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get cube ops from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * | |||||
| * @retval cube ops of subscription data | |||||
| * @retval 0 for failed | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpCubeOps(const void *opInfo, size_t opInfoLen, uint32_t index); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get vector ops from subscription data | |||||
| * | |||||
| * @param opInfo [IN] pointer to subscription data | |||||
| * @param opInfoLen [IN] memory size of subscription data | |||||
| * @param index [IN] index of op array in opInfo | |||||
| * | |||||
| * @retval vector ops of subscription data | |||||
| * @retval 0 for failed | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint64_t aclprofGetOpVectorOps(const void *opInfo, size_t opInfoLen, uint32_t index); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif // INC_EXTERNAL_ACL_PROF_H_ | |||||
| @@ -0,0 +1,932 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef INC_EXTERNAL_ACL_ACL_RT_H_ | |||||
| #define INC_EXTERNAL_ACL_ACL_RT_H_ | |||||
| #include <stdint.h> | |||||
| #include <stddef.h> | |||||
| #include "acl_base.h" | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| typedef enum aclrtRunMode { | |||||
| ACL_DEVICE, | |||||
| ACL_HOST, | |||||
| } aclrtRunMode; | |||||
| typedef enum aclrtTsId { | |||||
| ACL_TS_ID_AICORE = 0, | |||||
| ACL_TS_ID_AIVECTOR = 1, | |||||
| ACL_TS_ID_RESERVED = 2, | |||||
| } aclrtTsId; | |||||
| typedef enum aclrtEventStatus { | |||||
| ACL_EVENT_STATUS_COMPLETE = 0, | |||||
| ACL_EVENT_STATUS_NOT_READY = 1, | |||||
| ACL_EVENT_STATUS_RESERVED = 2, | |||||
| } aclrtEventStatus; | |||||
| typedef enum aclrtCallbackBlockType { | |||||
| ACL_CALLBACK_NO_BLOCK, | |||||
| ACL_CALLBACK_BLOCK, | |||||
| } aclrtCallbackBlockType; | |||||
| 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 aclrtMemMallocPolicy { | |||||
| ACL_MEM_MALLOC_HUGE_FIRST, | |||||
| ACL_MEM_MALLOC_HUGE_ONLY, | |||||
| ACL_MEM_MALLOC_NORMAL_ONLY, | |||||
| ACL_MEM_MALLOC_HUGE_FIRST_P2P, | |||||
| ACL_MEM_MALLOC_HUGE_ONLY_P2P, | |||||
| ACL_MEM_MALLOC_NORMAL_ONLY_P2P, | |||||
| } aclrtMemMallocPolicy; | |||||
| 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, | |||||
| } aclrtMemAttr; | |||||
| typedef enum aclrtGroupAttr { | |||||
| ACL_GROUP_AICORE_INT, | |||||
| ACL_GROUP_AIV_INT, | |||||
| ACL_GROUP_AIC_INT, | |||||
| ACL_GROUP_SDMANUM_INT, | |||||
| ACL_GROUP_ASQNUM_INT | |||||
| } aclrtGroupAttr; | |||||
| typedef struct tagRtGroupInfo aclrtGroupInfo; | |||||
| typedef struct rtExceptionInfo aclrtExceptionInfo; | |||||
| typedef void (*aclrtCallback)(void *userData); | |||||
| typedef void (*aclrtExceptionInfoCallback)(aclrtExceptionInfo *exceptionInfo); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Set a callback function to handle exception information | |||||
| * | |||||
| * @param callback [IN] callback function to handle exception information | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSetExceptionInfoCallback(aclrtExceptionInfoCallback callback); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get task id from exception information | |||||
| * | |||||
| * @param info [IN] pointer of exception information | |||||
| * | |||||
| * @retval The task id from exception information | |||||
| * @retval 0xFFFFFFFF if info is null | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetTaskIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get stream id from exception information | |||||
| * | |||||
| * @param info [IN] pointer of exception information | |||||
| * | |||||
| * @retval The stream id from exception information | |||||
| * @retval 0xFFFFFFFF if info is null | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetStreamIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get thread id from exception information | |||||
| * | |||||
| * @param info [IN] pointer of exception information | |||||
| * | |||||
| * @retval The thread id of fail task | |||||
| * @retval 0xFFFFFFFF if info is null | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetThreadIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get device id from exception information | |||||
| * | |||||
| * @param info [IN] pointer of exception information | |||||
| * | |||||
| * @retval The thread id of fail task | |||||
| * @retval 0xFFFFFFFF if info is null | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY uint32_t aclrtGetDeviceIdFromExceptionInfo(const aclrtExceptionInfo *info); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief The thread that handles the callback function on the Stream | |||||
| * | |||||
| * @param threadId [IN] thread ID | |||||
| * @param stream [IN] stream handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSubscribeReport(uint64_t threadId, aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Add a callback function to be executed on the host | |||||
| * to the task queue of the Stream | |||||
| * | |||||
| * @param fn [IN] Specify the callback function to be added | |||||
| * The function prototype of the callback function is: | |||||
| * typedef void (*aclrtCallback)(void *userData); | |||||
| * @param userData [IN] User data to be passed to the callback function | |||||
| * @param blockType [IN] callback block type | |||||
| * @param stream [IN] stream handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtLaunchCallback(aclrtCallback fn, void *userData, aclrtCallbackBlockType blockType, | |||||
| aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief After waiting for a specified time, trigger callback processing | |||||
| * | |||||
| * @par Function | |||||
| * The thread processing callback specified by | |||||
| * the aclrtSubscribeReport interface | |||||
| * | |||||
| * @param timeout [IN] timeout value | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtSubscribeReport | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtProcessReport(int32_t timeout); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Cancel thread registration, | |||||
| * the callback function on the specified Stream | |||||
| * is no longer processed by the specified thread | |||||
| * | |||||
| * @param threadId [IN] thread ID | |||||
| * @param stream [IN] stream handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtUnSubscribeReport(uint64_t threadId, aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief create context and associates it with the calling thread | |||||
| * | |||||
| * @par Function | |||||
| * The following use cases are supported: | |||||
| * @li If you don't call the aclrtCreateContext interface | |||||
| * to explicitly create the context, | |||||
| * the system will use the default context, which is implicitly created | |||||
| * when the aclrtSetDevice interface is called. | |||||
| * @li If multiple contexts are created in a process | |||||
| * (there is no limit on the number of contexts), | |||||
| * the current thread can only use one of them at the same time. | |||||
| * It is recommended to explicitly specify the context of the current thread | |||||
| * through the aclrtSetCurrentContext interface to increase. | |||||
| * the maintainability of the program. | |||||
| * | |||||
| * @param context [OUT] point to the created context | |||||
| * @param deviceId [IN] device to create context on | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtSetDevice | aclrtSetCurrentContext | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtCreateContext(aclrtContext *context, int32_t deviceId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief destroy context instance | |||||
| * | |||||
| * @par Function | |||||
| * Can only destroy context created through aclrtCreateContext interface | |||||
| * | |||||
| * @param context [IN] the context to destroy | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtCreateContext | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyContext(aclrtContext context); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief set the context of the thread | |||||
| * | |||||
| * @par Function | |||||
| * The following scenarios are supported: | |||||
| * @li If the aclrtCreateContext interface is called in a thread to explicitly | |||||
| * create a Context (for example: ctx1), the thread's Context can be specified | |||||
| * without calling the aclrtSetCurrentContext interface. | |||||
| * The system uses ctx1 as the context of thread1 by default. | |||||
| * @li If the aclrtCreateContext interface is not explicitly created, | |||||
| * the system uses the default context as the context of the thread. | |||||
| * At this time, the aclrtDestroyContext interface cannot be used to release | |||||
| * the default context. | |||||
| * @li If the aclrtSetCurrentContext interface is called multiple times to | |||||
| * set the thread's Context, the last one prevails. | |||||
| * | |||||
| * @par Restriction | |||||
| * @li If the cevice corresponding to the context set for the thread | |||||
| * has been reset, you cannot set the context as the context of the thread, | |||||
| * otherwise a business exception will result. | |||||
| * @li It is recommended to use the context created in a thread. | |||||
| * If the aclrtCreateContext interface is called in thread A to create a context, | |||||
| * and the context is used in thread B, | |||||
| * the user must guarantee the execution order of tasks in the same stream | |||||
| * under the same context in two threads. | |||||
| * | |||||
| * @param context [IN] the current context of the thread | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtCreateContext | aclrtDestroyContext | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSetCurrentContext(aclrtContext context); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get the context of the thread | |||||
| * | |||||
| * @par Function | |||||
| * If the user calls the aclrtSetCurrentContext interface | |||||
| * multiple times to set the context of the current thread, | |||||
| * then the last set context is obtained | |||||
| * | |||||
| * @param context [OUT] the current context of the thread | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtSetCurrentContext | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetCurrentContext(aclrtContext *context); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Specify the device to use for the operation | |||||
| * implicitly create the default context and the default stream | |||||
| * | |||||
| * @par Function | |||||
| * The following use cases are supported: | |||||
| * @li Device can be specified in the process or thread. | |||||
| * If you call the aclrtSetDevice interface multiple | |||||
| * times to specify the same device, | |||||
| * you only need to call the aclrtResetDevice interface to reset the device. | |||||
| * @li The same device can be specified for operation | |||||
| * in different processes or threads. | |||||
| * @li Device is specified in a process, | |||||
| * and multiple threads in the process can share this device to explicitly | |||||
| * create a Context (aclrtCreateContext interface). | |||||
| * @li In multi-device scenarios, you can switch to other devices | |||||
| * through the aclrtSetDevice interface in the process. | |||||
| * | |||||
| * @param deviceId [IN] the device id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtResetDevice |aclrtCreateContext | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSetDevice(int32_t deviceId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Reset the current operating Device and free resources on the device, | |||||
| * including the default context, the default stream, | |||||
| * and all streams created under the default context, | |||||
| * and synchronizes the interface. | |||||
| * If the task under the default context or stream has not been completed, | |||||
| * the system will wait for the task to complete before releasing it. | |||||
| * | |||||
| * @par Restriction | |||||
| * @li The Context, Stream, and Event that are explicitly created | |||||
| * on the device to be reset. Before resetting, | |||||
| * it is recommended to follow the following interface calling sequence, | |||||
| * otherwise business abnormalities may be caused. | |||||
| * @li Interface calling sequence: | |||||
| * call aclrtDestroyEvent interface to release Event or | |||||
| * call aclrtDestroyStream interface to release explicitly created Stream-> | |||||
| * call aclrtDestroyContext to release explicitly created Context-> | |||||
| * call aclrtResetDevice interface | |||||
| * | |||||
| * @param deviceId [IN] the device id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtResetDevice(int32_t deviceId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get target device of current thread | |||||
| * | |||||
| * @param deviceId [OUT] the device id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetDevice(int32_t *deviceId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get target side | |||||
| * | |||||
| * @param runMode [OUT] the run mode | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetRunMode(aclrtRunMode *runMode); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Wait for compute device to finish | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSynchronizeDevice(void); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Set Scheduling TS | |||||
| * | |||||
| * @param tsId [IN] the ts id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSetTsDevice(aclrtTsId tsId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get total device number. | |||||
| * | |||||
| * @param count [OUT] the device number | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetDeviceCount(uint32_t *count); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief create event instance | |||||
| * | |||||
| * @param event [OUT] created event | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtCreateEvent(aclrtEvent *event); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief destroy event instance | |||||
| * | |||||
| * @par Function | |||||
| * Only events created through the aclrtCreateEvent interface can be | |||||
| * destroyed, synchronous interfaces. When destroying an event, | |||||
| * the user must ensure that the tasks involved in the aclrtSynchronizeEvent | |||||
| * interface or the aclrtStreamWaitEvent interface are completed before | |||||
| * they are destroyed. | |||||
| * | |||||
| * @param event [IN] event to destroy | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtCreateEvent | aclrtSynchronizeEvent | aclrtStreamWaitEvent | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyEvent(aclrtEvent event); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Record an Event in the Stream | |||||
| * | |||||
| * @param event [IN] event to record | |||||
| * @param stream [IN] stream handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtRecordEvent(aclrtEvent event, aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Reset an event | |||||
| * | |||||
| * @par Function | |||||
| * Users need to make sure to wait for the tasks in the Stream | |||||
| * to complete before resetting the Event | |||||
| * | |||||
| * @param event [IN] event to reset | |||||
| * @param stream [IN] stream handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtResetEvent(aclrtEvent event, aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Queries an event's status | |||||
| * | |||||
| * @param event [IN] event to query | |||||
| * @param status [OUT] event status | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtQueryEvent(aclrtEvent event, aclrtEventStatus *status); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Block Host Running, wait event to be complete | |||||
| * | |||||
| * @param event [IN] event to wait | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSynchronizeEvent(aclrtEvent event); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief computes the elapsed time between events. | |||||
| * | |||||
| * @param ms [OUT] time between start and end in ms | |||||
| * @param start [IN] starting event | |||||
| * @param end [IN] ending event | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtCreateEvent | aclrtRecordEvent | aclrtSynchronizeStream | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtEventElapsedTime(float *ms, aclrtEvent start, aclrtEvent end); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief alloc memory on device | |||||
| * | |||||
| * @par Function | |||||
| * alloc for size linear memory on device | |||||
| * and return a pointer to allocated memory by *devPtr | |||||
| * | |||||
| * @par Restriction | |||||
| * @li The memory requested by the aclrtMalloc interface needs to be released | |||||
| * through the aclrtFree interface. | |||||
| * @li Before calling the media data processing interface, | |||||
| * if you need to apply memory on the device to store input or output data, | |||||
| * you need to call acldvppMalloc to apply for memory. | |||||
| * | |||||
| * @param devPtr [OUT] pointer to pointer to allocated memory on device | |||||
| * @param size [IN] alloc memory size | |||||
| * @param policy [IN] memory alloc policy | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtFree | acldvppMalloc | aclrtMallocCached | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMalloc(void **devPtr, size_t size, aclrtMemMallocPolicy policy); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief allocate memory on device with cache | |||||
| * | |||||
| * @par Function | |||||
| * alloc for size linear memory on device | |||||
| * and return a pointer to allocated memory by *devPtr | |||||
| * | |||||
| * @par Restriction | |||||
| * @li The memory requested by the aclrtMallocCached interface needs to be released | |||||
| * through the aclrtFree interface. | |||||
| * | |||||
| * @param devPtr [OUT] pointer to pointer to allocated memory on device | |||||
| * @param size [IN] alloc memory size | |||||
| * @param policy [IN] memory alloc policy | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtFree | aclrtMalloc | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMallocCached(void **devPtr, size_t size, aclrtMemMallocPolicy policy); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief flush cache data to ddr | |||||
| * | |||||
| * @param devPtr [IN] the pointer that flush data to ddr | |||||
| * @param size [IN] flush size | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMemFlush(void *devPtr, size_t size); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief invalidate cache data | |||||
| * | |||||
| * @param devPtr [IN] pointer to invalidate cache data | |||||
| * @param size [IN] invalidate size | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMemInvalidate(void *devPtr, size_t size); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief free device memory | |||||
| * | |||||
| * @par Function | |||||
| * can only free memory allocated through the aclrtMalloc interface | |||||
| * | |||||
| * @param devPtr [IN] Pointer to memory to be freed | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtMalloc | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtFree(void *devPtr); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief alloc memory on host | |||||
| * | |||||
| * @par Restriction | |||||
| * @li The requested memory cannot be used in the Device | |||||
| * and needs to be explicitly copied to the Device. | |||||
| * @li The memory requested by the aclrtMallocHost interface | |||||
| * needs to be released through the aclrtFreeHost interface. | |||||
| * | |||||
| * @param hostPtr [OUT] pointer to pointer to allocated memory on the host | |||||
| * @param size [IN] alloc memory size | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtFreeHost | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMallocHost(void **hostPtr, size_t size); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief free host memory | |||||
| * | |||||
| * @par Function | |||||
| * can only free memory allocated through the aclrtMallocHost interface | |||||
| * | |||||
| * @param hostPtr [IN] free memory pointer | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtMallocHost | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtFreeHost(void *hostPtr); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief synchronous memory replication between host and device | |||||
| * | |||||
| * @param dst [IN] destination address pointer | |||||
| * @param destMax [IN] Max length of the destination address memory | |||||
| * @param src [IN] source address pointer | |||||
| * @param count [IN] the length of byte to copy | |||||
| * @param kind [IN] memcpy type | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMemcpy(void *dst, size_t destMax, const void *src, size_t count, | |||||
| aclrtMemcpyKind kind); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Initialize memory and set contents of memory to specified value | |||||
| * | |||||
| * @par Function | |||||
| * The memory to be initialized is on the Host or device side, | |||||
| * and the system determines whether | |||||
| * it is host or device according to the address | |||||
| * | |||||
| * @param devPtr [IN] Starting address of memory | |||||
| * @param maxCount [IN] Max length of destination address memory | |||||
| * @param value [IN] Set value | |||||
| * @param count [IN] The length of memory | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMemset(void *devPtr, size_t maxCount, int32_t value, size_t count); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Asynchronous memory replication between Host and Device | |||||
| * | |||||
| * @par Function | |||||
| * After calling this interface, | |||||
| * be sure to call the aclrtSynchronizeStream interface to ensure that | |||||
| * the task of memory replication has been completed | |||||
| * | |||||
| * @par Restriction | |||||
| * @li For on-chip Device-to-Device memory copy, | |||||
| * both the source and destination addresses must be 64-byte aligned | |||||
| * | |||||
| * @param dst [IN] destination address pointer | |||||
| * @param destMax [IN] Max length of destination address memory | |||||
| * @param src [IN] source address pointer | |||||
| * @param count [IN] the number of byte to copy | |||||
| * @param kind [IN] memcpy type | |||||
| * @param stream [IN] asynchronized task stream | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtSynchronizeStream | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMemcpyAsync(void *dst, size_t destMax, const void *src, size_t count, | |||||
| aclrtMemcpyKind kind, aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Asynchronous initialize memory | |||||
| * and set contents of memory to specified value async | |||||
| * | |||||
| * @par Function | |||||
| * The memory to be initialized is on the Host or device side, | |||||
| * and the system determines whether | |||||
| * it is host or device according to the address | |||||
| * | |||||
| * @param devPtr [IN] destination address pointer | |||||
| * @param maxCount [IN] Max length of destination address memory | |||||
| * @param value [IN] set value | |||||
| * @param count [IN] the number of byte to set | |||||
| * @param stream [IN] asynchronized task stream | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtSynchronizeStream | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtMemsetAsync(void *devPtr, size_t maxCount, int32_t value, size_t count, | |||||
| aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief create stream instance | |||||
| * | |||||
| * @param stream [OUT] the created stream | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtCreateStream(aclrtStream *stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief destroy stream instance | |||||
| * | |||||
| * @par Function | |||||
| * Can only destroy streams created through the aclrtCreateStream interface | |||||
| * | |||||
| * @par Restriction | |||||
| * Before calling the aclrtDestroyStream interface to destroy | |||||
| * the specified Stream, you need to call the aclrtSynchronizeStream interface | |||||
| * to ensure that the tasks in the Stream have been completed. | |||||
| * | |||||
| * @param stream [IN] the stream to destroy | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtCreateStream | aclrtSynchronizeStream | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyStream(aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief block the host until all tasks | |||||
| * in the specified stream have completed | |||||
| * | |||||
| * @param stream [IN] the stream to wait | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSynchronizeStream(aclrtStream stream); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Blocks the operation of the specified Stream until | |||||
| * the specified Event is completed. | |||||
| * Support for multiple streams waiting for the same event. | |||||
| * | |||||
| * @param stream [IN] the wait stream If using thedefault Stream, set NULL | |||||
| * @param event [IN] the event to wait | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief set group | |||||
| * | |||||
| * @par Function | |||||
| * set the task to the corresponding group | |||||
| * | |||||
| * @param groupId [IN] group id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtGetGroupCount | aclrtGetAllGroupInfo | aclrtGetGroupInfoDetail | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtSetGroup(int32_t groupId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get the number of group | |||||
| * | |||||
| * @par Function | |||||
| * get the number of group. if the number of group is zero, | |||||
| * it means that group is not supported or group is not created. | |||||
| * | |||||
| * @param count [OUT] the number of group | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetGroupCount(uint32_t *count); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief create group information | |||||
| * | |||||
| * @retval null for failed. | |||||
| * @retval OtherValues success. | |||||
| * | |||||
| * @see aclrtDestroyGroupInfo | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclrtGroupInfo *aclrtCreateGroupInfo(); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief destroy group information | |||||
| * | |||||
| * @param groupInfo [IN] pointer to group information | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtCreateGroupInfo | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDestroyGroupInfo(aclrtGroupInfo *groupInfo); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get all group information | |||||
| * | |||||
| * @param groupInfo [OUT] pointer to group information | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtGetGroupCount | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetAllGroupInfo(aclrtGroupInfo *groupInfo); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief get detail information of group | |||||
| * | |||||
| * @param groupInfo [IN] pointer to group information | |||||
| * @param groupId [IN] group index value | |||||
| * @param attr [IN] group attribute | |||||
| * @param attrValue [OUT] pointer to attribute value | |||||
| * @param valueLen [IN] length of attribute value | |||||
| * @param paramRetSize [OUT] pointer to real length of attribute value | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtGetGroupCount | aclrtGetAllGroupInfo | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetGroupInfoDetail(const aclrtGroupInfo *groupInfo, int32_t groupId, | |||||
| aclrtGroupAttr attr, void *attrValue, size_t valueLen, | |||||
| size_t *paramRetSize); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief checking whether current device and peer device support the p2p feature | |||||
| * | |||||
| * @param canAccessPeer [OUT] pointer to save the checking result | |||||
| * @param deviceId [IN] current device id | |||||
| * @param peerDeviceId [IN] peer device id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtDeviceEnablePeerAccess | aclrtDeviceDisablePeerAccess | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDeviceCanAccessPeer(int32_t *canAccessPeer, int32_t deviceId, int32_t peerDeviceId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief enable the peer device to support the p2p feature | |||||
| * | |||||
| * @param peerDeviceId [IN] the peer device id | |||||
| * @param flags [IN] reserved field, now it must be zero | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtDeviceCanAccessPeer | aclrtDeviceDisablePeerAccess | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDeviceEnablePeerAccess(int32_t peerDeviceId, uint32_t flags); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief disable the peer device to support the p2p function | |||||
| * | |||||
| * @param peerDeviceId [IN] the peer device id | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see aclrtDeviceCanAccessPeer | aclrtDeviceEnablePeerAccess | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtDeviceDisablePeerAccess(int32_t peerDeviceId); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Obtain the free memory and total memory of specified attribute. | |||||
| * the specified memory include normal memory and huge memory. | |||||
| * | |||||
| * @param attr [IN] the memory attribute of specified device | |||||
| * @param free [OUT] the free memory of specified device | |||||
| * @param total [OUT] the total memory of specified device. | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError aclrtGetMemInfo(aclrtMemAttr attr, size_t *free, size_t *total); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif // INC_EXTERNAL_ACL_ACL_RT_H_ | |||||
| @@ -0,0 +1,276 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef INC_EXTERNAL_ACL_ACL_TDT_H_ | |||||
| #define INC_EXTERNAL_ACL_ACL_TDT_H_ | |||||
| #include "acl/acl_base.h" | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| enum acltdtTensorType { | |||||
| ACL_TENSOR_DATA_UNDEFINED = -1, | |||||
| ACL_TENSOR_DATA_TENSOR, | |||||
| ACL_TENSOR_DATA_END_OF_SEQUENCE, | |||||
| ACL_TENSOR_DATA_ABNORMAL | |||||
| }; | |||||
| typedef struct acltdtDataItem acltdtDataItem; | |||||
| typedef struct acltdtDataset acltdtDataset; | |||||
| typedef struct acltdtChannelHandle acltdtChannelHandle; | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get tensor type from item | |||||
| * | |||||
| * @param dataItem [IN] pointer to the data item | |||||
| * | |||||
| * @retval Tensor type. | |||||
| * @retval ACL_DT_UNDEFINED if dataItem is null | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY acltdtTensorType acltdtGetTensorTypeFromItem(const acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get data type from item | |||||
| * | |||||
| * @param dataItem [IN] pointer to the data item | |||||
| * | |||||
| * @retval Data type. | |||||
| * @retval ACL_DT_UNDEFINED if dataItem is null | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclDataType acltdtGetDataTypeFromItem(const acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get data address from item | |||||
| * | |||||
| * @param dataItem [IN] pointer to data item | |||||
| * | |||||
| * @retval null for failed | |||||
| * @retval OtherValues success | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY void *acltdtGetDataAddrFromItem(const acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get data size from item | |||||
| * | |||||
| * @param dataItem [IN] pointer to data item | |||||
| * | |||||
| * @retval 0 for failed | |||||
| * @retval OtherValues success | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY size_t acltdtGetDataSizeFromItem(const acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get dim's number from item | |||||
| * | |||||
| * @param dataItem [IN] pointer to data item | |||||
| * | |||||
| * @retval 0 for failed | |||||
| * @retval OtherValues success | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY size_t acltdtGetDimNumFromItem(const acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get dims from item | |||||
| * | |||||
| * @param dataItem [IN] the struct of data item | |||||
| * @param dims [IN|OUT] pointer to the dims of dataTtem | |||||
| * @param dimNum [IN] the size of the dims | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtGetDimsFromItem(const acltdtDataItem *dataItem, int64_t *dims, size_t dimNum); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Create the struct of data item | |||||
| * | |||||
| * @param tdtType [IN] Tdt tensor type | |||||
| * @param dims [IN] pointer of tdtDataItem's dims | |||||
| * @param dimNum [IN] Dim number | |||||
| * @param dataType [IN] Data type | |||||
| * @param data [IN] Data pointer | |||||
| * @param size [IN] Data size | |||||
| * | |||||
| * @retval null for failed | |||||
| * @retval OtherValues success | |||||
| * | |||||
| * @see acltdtDestroyDataItem | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY acltdtDataItem *acltdtCreateDataItem(acltdtTensorType tdtType, const int64_t *dims, size_t dimNum, | |||||
| aclDataType dataType, void *data, size_t size); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Destroy the struct of data item | |||||
| * | |||||
| * @param dataItem [IN] pointer to the data item | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtCreateDataItem | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtDestroyDataItem(acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Create the tdt dataset | |||||
| * | |||||
| * @retval null for failed | |||||
| * @retval OtherValues success | |||||
| * | |||||
| * @see acltdtDestroyDataset | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY acltdtDataset *acltdtCreateDataset(); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Destroy the tdt dataset | |||||
| * | |||||
| * @param dataset [IN] pointer to the dataset | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtCreateDataset | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtDestroyDataset(acltdtDataset *dataset); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get the data item | |||||
| * | |||||
| * @param dataset [IN] pointer to the dataset | |||||
| * @param index [IN] index of the dataset | |||||
| * | |||||
| * @retval null for failed | |||||
| * @retval OtherValues success | |||||
| * | |||||
| * @see acltdtAddDataItem | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY acltdtDataItem *acltdtGetDataItem(const acltdtDataset *dataset, size_t index); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get the data item | |||||
| * | |||||
| * @param dataset [OUT] pointer to the dataset | |||||
| * @param dataItem [IN] pointer to the data item | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtGetDataItem | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtAddDataItem(acltdtDataset *dataset, acltdtDataItem *dataItem); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Get the size of dataset | |||||
| * | |||||
| * @param dataset [IN] pointer to the dataset | |||||
| * | |||||
| * @retval 0 for failed | |||||
| * @retval OtherValues success | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY size_t acltdtGetDatasetSize(const acltdtDataset *dataset); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Stop the channel | |||||
| * | |||||
| * @param handle [IN] pointer to the channel handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtCreateChannel | acltdtDestroyChannel | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtStopChannel(acltdtChannelHandle *handle); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Create the channel | |||||
| * | |||||
| * @param deviceId [IN] the device id | |||||
| * @param name [IN] the channel's name | |||||
| * | |||||
| * @retval null for failed | |||||
| * @retval OtherValues success | |||||
| * | |||||
| * @see acltdtStopChannel | acltdtDestroyChannel | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY acltdtChannelHandle *acltdtCreateChannel(uint32_t deviceId, const char *name); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Destroy the channel | |||||
| * | |||||
| * @param handle [IN] pointer to the channel handle | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtCreateChannel | acltdtStopChannel | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtDestroyChannel(acltdtChannelHandle *handle); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Send tensor to device | |||||
| * | |||||
| * @param handle [IN] pointer to the channel handle | |||||
| * @param dataset [IN] pointer to the dataset | |||||
| * @param timeout [IN] to be reserved, now it must be -1 | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtReceiveTensor | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtSendTensor(const acltdtChannelHandle *handle, const acltdtDataset *dataset, | |||||
| int32_t timeout); | |||||
| /** | |||||
| * @ingroup AscendCL | |||||
| * @brief Receive tensor from device | |||||
| * | |||||
| * @param handle [IN] pointer to the channel handle | |||||
| * @param dataset [OUT] pointer to the dataset | |||||
| * @param timeout [IN] to be reserved, now it must be -1 | |||||
| * | |||||
| * @retval ACL_SUCCESS The function is successfully executed. | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @see acltdtSendTensor | |||||
| */ | |||||
| ACL_FUNC_VISIBILITY aclError acltdtReceiveTensor(const acltdtChannelHandle *handle, acltdtDataset *dataset, | |||||
| int32_t timeout); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif // INC_EXTERNAL_ACL_ACL_TDT_H_ | |||||
| @@ -46,6 +46,7 @@ static const int32_t ACL_ERROR_RT_INVALID_MEMORY_TYPE = 107016; // invalid | |||||
| static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPROT = 207000; // feature not support | static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPROT = 207000; // feature not support | ||||
| static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error | static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error | ||||
| static const int32_t ACL_ERROR_RT_MEMORY_FREE = 207002; // memory free error | static const int32_t ACL_ERROR_RT_MEMORY_FREE = 207002; // memory free error | ||||
| static const int32_t ACL_ERROR_RT_AICORE_OVER_FLOW = 207003; // aicore over flow | |||||
| static const int32_t ACL_ERROR_RT_INTERNEL_ERROR = 507000; // runtime internel error | static const int32_t ACL_ERROR_RT_INTERNEL_ERROR = 507000; // runtime internel error | ||||
| static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error | static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error | ||||
| @@ -0,0 +1,134 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| /** | |||||
| * @file hccl.h | |||||
| * @brief HCCL API | |||||
| */ | |||||
| #ifndef HCCL_H_ | |||||
| #define HCCL_H_ | |||||
| #include <hccl/hccl_types.h> | |||||
| #include <acl/acl.h> | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif // __cplusplus | |||||
| /** | |||||
| * @brief Initialize HCCL. | |||||
| * | |||||
| * @param clusterInfo A string identifying the cluster info file path, include file name. | |||||
| * @param rank A integer identifying the identify for the rank. | |||||
| * @param comm A pointer identifying the initialized communication resource. | |||||
| * @return HcclResult | |||||
| * @see HcclCommDestroy() | |||||
| */ | |||||
| extern HcclResult HcclCommInitClusterInfo(const char *clusterInfo, uint32_t rank, HcclComm *comm); | |||||
| /** | |||||
| * @brief Get hccl root info. | |||||
| * | |||||
| * @param rootInfo A pointer identifying the hccl root info. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcclGetRootInfo(HcclRootInfo *rootInfo); | |||||
| /** | |||||
| * @brief Initialize HCCL with root info. | |||||
| * | |||||
| * @param nRanks A integer identifying the rank size of the cluster. | |||||
| * @param rootInfo A struct identifying the hccl root info. | |||||
| * @param rank A integer identifying the identify for the rank. | |||||
| * @param comm A pointer identifying the initialized communication resource. | |||||
| * @return HcclResult | |||||
| * @see HcclCommDestroy() | |||||
| */ | |||||
| extern HcclResult HcclCommInitRootInfo(uint32_t nRanks, const HcclRootInfo *rootInfo, uint32_t rank, HcclComm *comm); | |||||
| /** | |||||
| * @brief AllReduce operator. | |||||
| * | |||||
| * @param sendBuf A pointer identifying the input data address of the operator. | |||||
| * @param recvBuf A pointer identifying the output data address of the operator. | |||||
| * @param count An integer(u64) identifying the number of the output data. | |||||
| * @param dataType The data type of the operator, must be one of the following types: int8, int16, int32, float16, | |||||
| * float32. | |||||
| * @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod. | |||||
| * @param comm A pointer identifying the communication resource based on. | |||||
| * @param stream A pointer identifying the stream information. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, | |||||
| HcclComm comm, aclrtStream stream); | |||||
| /** | |||||
| * @brief Broadcast operator. | |||||
| * | |||||
| * @param buf A pointer identifying the data address of the operator. | |||||
| * @param count An integer(u64) identifying the number of the data. | |||||
| * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32. | |||||
| * @param root An integer(u32) identifying the the root rank in the operator. | |||||
| * @param comm A pointer identifying the communication resource based on | |||||
| * @param stream A pointer identifying the stream information. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcclBroadcast(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, HcclComm comm, | |||||
| aclrtStream stream); | |||||
| /** | |||||
| * @brief ReduceScatter operator. | |||||
| * | |||||
| * @param sendBuf A pointer identifying the input data address of the operator. | |||||
| * @param recvBuf A pointer identifying the output data address of the operator. | |||||
| * @param recvCount An integer(u64) identifying the number of the output data. | |||||
| * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32. | |||||
| * @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod. | |||||
| * @param comm A pointer identifying the communication resource based on. | |||||
| * @param stream A pointer identifying the stream information. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcclReduceScatter(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, | |||||
| HcclReduceOp op, HcclComm comm, aclrtStream stream); | |||||
| /** | |||||
| * @brief AllGather operator. | |||||
| * | |||||
| * @param sendBuf A pointer identifying the input data address of the operator. | |||||
| * @param recvBuf A pointer identifying the output data address of the operator. | |||||
| * @param sendCount An integer(u64) identifying the number of the input data. | |||||
| * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32. | |||||
| * @param comm A pointer identifying the communication resource based on. | |||||
| * @param stream A pointer identifying the stream information. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | |||||
| aclrtStream stream); | |||||
| /** | |||||
| * @brief Destroy HCCL comm | |||||
| * | |||||
| * @param comm A pointer identifying the communication resource targetting | |||||
| * @return HcclResult | |||||
| * @see HcclCommInitClusterInfo() | |||||
| */ | |||||
| extern HcclResult HcclCommDestroy(HcclComm comm); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif // __cplusplus | |||||
| #endif // HCCL_H_ | |||||
| @@ -0,0 +1,101 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| /** | |||||
| * @file hccl_types.h | |||||
| * @brief HCCL data type definition | |||||
| * | |||||
| */ | |||||
| #ifndef HCCL_TYPES_H_ | |||||
| #define HCCL_TYPES_H_ | |||||
| #include <stdint.h> | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif // __cplusplus | |||||
| /** | |||||
| * @brief HCCL functions return value definition | |||||
| */ | |||||
| typedef enum { | |||||
| HCCL_SUCCESS = 0, /**< success */ | |||||
| HCCL_E_PARA = 1, /**< parameter error */ | |||||
| HCCL_E_PTR = 2, /**< empty pointer */ | |||||
| HCCL_E_MEMORY = 3, /**< memory error */ | |||||
| HCCL_E_INTERNAL = 4, /**< internal error */ | |||||
| HCCL_E_NOT_SUPPORT = 5, /**< not support feature */ | |||||
| HCCL_E_NOT_FOUND = 6, /**< not found specific resource */ | |||||
| HCCL_E_UNAVAIL = 7, /**< resource unavailable */ | |||||
| HCCL_E_SYSCALL = 8, /**< call system interface error */ | |||||
| HCCL_E_TIMEOUT = 9, /**< timeout */ | |||||
| HCCL_E_OPEN_FILE_FAILURE = 10, /**< open file fail */ | |||||
| HCCL_E_TCP_CONNECT = 11, /**< tcp connect fail */ | |||||
| HCCL_E_ROCE_CONNECT = 12, /**< roce connect fail */ | |||||
| HCCL_E_TCP_TRANSFER = 13, /**< tcp transfer fail */ | |||||
| HCCL_E_ROCE_TRANSFER = 14, /**< roce transfer fail */ | |||||
| HCCL_E_RUNTIME = 15, /**< call runtime api fail */ | |||||
| HCCL_E_DRV = 16, /**< call driver api fail */ | |||||
| HCCL_E_PROFILING = 17, /**< call profiling api fail */ | |||||
| HCCL_E_CCE = 18, /**< call cce api fail */ | |||||
| HCCL_E_NETWORK = 19, /**< call network api fail */ | |||||
| HCCL_E_RESERVED /**< reserved */ | |||||
| } HcclResult; | |||||
| /** | |||||
| * @brief handle to HCCL communicator | |||||
| */ | |||||
| typedef void *HcclComm; | |||||
| /** | |||||
| * @brief HCCL Reduction opperation | |||||
| */ | |||||
| typedef enum { | |||||
| HCCL_REDUCE_SUM = 0, /**< sum */ | |||||
| HCCL_REDUCE_PROD = 1, /**< prod */ | |||||
| HCCL_REDUCE_MAX = 2, /**< max */ | |||||
| HCCL_REDUCE_MIN = 3, /**< min */ | |||||
| HCCL_REDUCE_RESERVED /**< reserved */ | |||||
| } HcclReduceOp; | |||||
| /** | |||||
| * @brief HCCL data type | |||||
| */ | |||||
| typedef enum { | |||||
| HCCL_DATA_TYPE_INT8 = 0, /**< int8 */ | |||||
| HCCL_DATA_TYPE_INT16 = 1, /**< int16 */ | |||||
| HCCL_DATA_TYPE_INT32 = 2, /**< int32 */ | |||||
| HCCL_DATA_TYPE_FP16 = 3, /**< fp16 */ | |||||
| HCCL_DATA_TYPE_FP32 = 4, /**< fp32 */ | |||||
| HCCL_DATA_TYPE_INT64 = 5, /**< int64 */ | |||||
| HCCL_DATA_TYPE_UINT64 = 6, /**< uint64 */ | |||||
| HCCL_DATA_TYPE_RESERVED /**< reserved */ | |||||
| } HcclDataType; | |||||
| const uint32_t HCCL_ROOT_INFO_BYTES = 4108; // 4108: root info length | |||||
| /** | |||||
| * @brief HCCL root info | |||||
| */ | |||||
| typedef struct HcclRootInfoDef { | |||||
| char internal[HCCL_ROOT_INFO_BYTES]; | |||||
| } HcclRootInfo; | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif // __cplusplus | |||||
| #endif // HCCL_TYPES_H_ | |||||
| @@ -46,6 +46,7 @@ static const int32_t ACL_ERROR_RT_INVALID_MEMORY_TYPE = 107016; // invalid | |||||
| static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPROT = 207000; // feature not support | static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPROT = 207000; // feature not support | ||||
| static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error | static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error | ||||
| static const int32_t ACL_ERROR_RT_MEMORY_FREE = 207002; // memory free error | static const int32_t ACL_ERROR_RT_MEMORY_FREE = 207002; // memory free error | ||||
| static const int32_t ACL_ERROR_RT_AICORE_OVER_FLOW = 207003; // aicore over flow | |||||
| static const int32_t ACL_ERROR_RT_INTERNEL_ERROR = 507000; // runtime internel error | static const int32_t ACL_ERROR_RT_INTERNEL_ERROR = 507000; // runtime internel error | ||||
| static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error | static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error | ||||
| @@ -0,0 +1,60 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef AICPU_OP_TYPE_LIST_H_ | |||||
| #define AICPU_OP_TYPE_LIST_H_ | |||||
| enum OpKernelType { | |||||
| TF_KERNEL, | |||||
| CPU_KERNEL | |||||
| }; | |||||
| enum ReturnCode { | |||||
| OP_TYPE_NOT_SUPPORT, | |||||
| FORMAT_NOT_SUPPORT, | |||||
| DTYPE_NOT_SUPPORT | |||||
| }; | |||||
| #pragma pack(push, 1) | |||||
| //One byte alignment | |||||
| struct SysOpInfo { | |||||
| uint64_t opLen; | |||||
| uint64_t opType; | |||||
| OpKernelType kernelsType; | |||||
| }; | |||||
| struct OpParamInfo { | |||||
| uint64_t num; | |||||
| uint64_t dtypeList; | |||||
| uint64_t formatList; | |||||
| }; | |||||
| struct SysOpCheckInfo { | |||||
| uint64_t opListNum; | |||||
| uint64_t offSetLen; | |||||
| uint64_t sysOpInfoList; | |||||
| uint64_t opParamInfoList; | |||||
| }; | |||||
| struct SysOpCheckResp { | |||||
| uint64_t opListNum; | |||||
| bool isWithoutJson; | |||||
| uint64_t returnCodeList; | |||||
| uint64_t sysOpInfoList; | |||||
| uint64_t opParamInfoList; | |||||
| }; | |||||
| #pragma pack(pop) | |||||
| #endif // AICPU_OP_TYPE_LIST_H_ | |||||
| @@ -33,18 +33,22 @@ typedef enum { | |||||
| FMK_KERNEL_TYPE_RESERVED | FMK_KERNEL_TYPE_RESERVED | ||||
| } FwkkernelType_t; | } FwkkernelType_t; | ||||
| #pragma pack(push, 1) | |||||
| typedef struct { | typedef struct { | ||||
| uint32_t fwkKernelType; // FwkkernelType_t | uint32_t fwkKernelType; // FwkkernelType_t | ||||
| union { | union { | ||||
| ::aicpu::FWKAdapter::FWKOperateParam fwk_kernel; | ::aicpu::FWKAdapter::FWKOperateParam fwk_kernel; | ||||
| } fwkKernelBase; | } fwkKernelBase; | ||||
| } __attribute__((packed)) STR_FWK_OP_KERNEL; | |||||
| } STR_FWK_OP_KERNEL; | |||||
| #pragma pack(pop) | |||||
| #pragma pack(push, 1) | |||||
| struct SessionInfo { | struct SessionInfo { | ||||
| uint64_t sessionId; | uint64_t sessionId; | ||||
| uint64_t kernelId; | uint64_t kernelId; | ||||
| bool sessFlag; | bool sessFlag; | ||||
| } __attribute__((packed)); | |||||
| }; | |||||
| #pragma pack(pop) | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| @@ -70,6 +70,7 @@ enum FWKExtUpdateAddrType { | |||||
| FWK_ADPT_UPDATE_INPUT_OUTPUT | FWK_ADPT_UPDATE_INPUT_OUTPUT | ||||
| }; | }; | ||||
| #pragma pack(push, 1) | |||||
| // API Parameter Structure | // API Parameter Structure | ||||
| struct StrFWKKernel { | struct StrFWKKernel { | ||||
| FWKOperateType opType; | FWKOperateType opType; | ||||
| @@ -89,31 +90,39 @@ struct StrFWKKernel { | |||||
| uint64_t extInfoLen; // extend info total length | uint64_t extInfoLen; // extend info total length | ||||
| uint64_t extInfoAddr; // extend info addr, ExtInfo structure | uint64_t extInfoAddr; // extend info addr, ExtInfo structure | ||||
| } __attribute__((packed)); | |||||
| }; | |||||
| #pragma pack(pop) | |||||
| typedef StrFWKKernel FWKOperateParam; | typedef StrFWKKernel FWKOperateParam; | ||||
| // Extent info ShapeAndType | // Extent info ShapeAndType | ||||
| const uint32_t kMaxShapeDims = 8; | const uint32_t kMaxShapeDims = 8; | ||||
| #pragma pack(push, 1) | |||||
| struct ShapeAndType { | struct ShapeAndType { | ||||
| int32_t type; | int32_t type; | ||||
| int64_t dims[kMaxShapeDims]; | int64_t dims[kMaxShapeDims]; | ||||
| } __attribute__((packed)); | |||||
| }; | |||||
| #pragma pack(pop) | |||||
| // Extend info structure for extInfoAddr | // Extend info structure for extInfoAddr | ||||
| const uint32_t kExtInfoHeadSize = 8; | const uint32_t kExtInfoHeadSize = 8; | ||||
| #pragma pack(push, 1) | |||||
| struct ExtInfo { | struct ExtInfo { | ||||
| int32_t infoType; // extend type | int32_t infoType; // extend type | ||||
| uint32_t infoLen; // length for infoMsg | uint32_t infoLen; // length for infoMsg | ||||
| char infoMsg[0]; // extend value | char infoMsg[0]; // extend value | ||||
| } __attribute__((packed)); | |||||
| }; | |||||
| #pragma pack(pop) | |||||
| #pragma pack(push, 1) | |||||
| struct ResultSummary { | struct ResultSummary { | ||||
| uint64_t shape_data_ptr; // shape data addr, need convert to void* | uint64_t shape_data_ptr; // shape data addr, need convert to void* | ||||
| uint64_t shape_data_size; // num of dims | uint64_t shape_data_size; // num of dims | ||||
| uint64_t raw_data_ptr; // raw data addr, need convert to void* | uint64_t raw_data_ptr; // raw data addr, need convert to void* | ||||
| uint64_t raw_data_size; // size of raw data | uint64_t raw_data_size; // size of raw data | ||||
| } __attribute__((packed)); | |||||
| }; | |||||
| #pragma pack(pop) | |||||
| } // end namespace FWKAdapter | } // end namespace FWKAdapter | ||||
| } // namespace aicpu | } // namespace aicpu | ||||
| @@ -22,7 +22,8 @@ | |||||
| #ifndef HCCL_BASE_H_ | #ifndef HCCL_BASE_H_ | ||||
| #define HCCL_BASE_H_ | #define HCCL_BASE_H_ | ||||
| #include <hccl/hccl_types.h> | |||||
| #include <string> | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #endif // __cplusplus | #endif // __cplusplus | ||||
| @@ -95,6 +96,33 @@ typedef void *rtStream_t; | |||||
| */ | */ | ||||
| typedef void *rtModel_t; | typedef void *rtModel_t; | ||||
| struct HcomOperation { | |||||
| std::string hcclType; | |||||
| void *inputPtr; | |||||
| void *outputPtr; | |||||
| u64 count; | |||||
| HcclDataType dataType; | |||||
| HcclReduceOp opType; | |||||
| u32 root; | |||||
| HcomOperation() | |||||
| { | |||||
| inputPtr = nullptr; | |||||
| outputPtr = nullptr; | |||||
| count = 0; | |||||
| dataType = HCCL_DATA_TYPE_RESERVED; | |||||
| opType = HCCL_REDUCE_RESERVED; | |||||
| root = 0; | |||||
| } | |||||
| }; | |||||
| struct HcomRemoteAccessAddrInfo { | |||||
| u32 remotetRankID; | |||||
| u64 remoteAddr; // host embedding table address | |||||
| u64 localAddr; // device HBM address | |||||
| u64 length; // Memory Length in Bytes | |||||
| }; | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif // __cplusplus | #endif // __cplusplus | ||||
| @@ -0,0 +1,101 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| /** | |||||
| * @file hccl_types.h | |||||
| * @brief HCCL data type definition | |||||
| * | |||||
| */ | |||||
| #ifndef HCCL_TYPES_H_ | |||||
| #define HCCL_TYPES_H_ | |||||
| #include <stdint.h> | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif // __cplusplus | |||||
| /** | |||||
| * @brief HCCL functions return value definition | |||||
| */ | |||||
| typedef enum { | |||||
| HCCL_SUCCESS = 0, /**< success */ | |||||
| HCCL_E_PARA = 1, /**< parameter error */ | |||||
| HCCL_E_PTR = 2, /**< empty pointer */ | |||||
| HCCL_E_MEMORY = 3, /**< memory error */ | |||||
| HCCL_E_INTERNAL = 4, /**< internal error */ | |||||
| HCCL_E_NOT_SUPPORT = 5, /**< not support feature */ | |||||
| HCCL_E_NOT_FOUND = 6, /**< not found specific resource */ | |||||
| HCCL_E_UNAVAIL = 7, /**< resource unavailable */ | |||||
| HCCL_E_SYSCALL = 8, /**< call system interface error */ | |||||
| HCCL_E_TIMEOUT = 9, /**< timeout */ | |||||
| HCCL_E_OPEN_FILE_FAILURE = 10, /**< open file fail */ | |||||
| HCCL_E_TCP_CONNECT = 11, /**< tcp connect fail */ | |||||
| HCCL_E_ROCE_CONNECT = 12, /**< roce connect fail */ | |||||
| HCCL_E_TCP_TRANSFER = 13, /**< tcp transfer fail */ | |||||
| HCCL_E_ROCE_TRANSFER = 14, /**< roce transfer fail */ | |||||
| HCCL_E_RUNTIME = 15, /**< call runtime api fail */ | |||||
| HCCL_E_DRV = 16, /**< call driver api fail */ | |||||
| HCCL_E_PROFILING = 17, /**< call profiling api fail */ | |||||
| HCCL_E_CCE = 18, /**< call cce api fail */ | |||||
| HCCL_E_NETWORK = 19, /**< call network api fail */ | |||||
| HCCL_E_RESERVED /**< reserved */ | |||||
| } HcclResult; | |||||
| /** | |||||
| * @brief handle to HCCL communicator | |||||
| */ | |||||
| typedef void *HcclComm; | |||||
| /** | |||||
| * @brief HCCL Reduction opperation | |||||
| */ | |||||
| typedef enum { | |||||
| HCCL_REDUCE_SUM = 0, /**< sum */ | |||||
| HCCL_REDUCE_PROD = 1, /**< prod */ | |||||
| HCCL_REDUCE_MAX = 2, /**< max */ | |||||
| HCCL_REDUCE_MIN = 3, /**< min */ | |||||
| HCCL_REDUCE_RESERVED /**< reserved */ | |||||
| } HcclReduceOp; | |||||
| /** | |||||
| * @brief HCCL data type | |||||
| */ | |||||
| typedef enum { | |||||
| HCCL_DATA_TYPE_INT8 = 0, /**< int8 */ | |||||
| HCCL_DATA_TYPE_INT16 = 1, /**< int16 */ | |||||
| HCCL_DATA_TYPE_INT32 = 2, /**< int32 */ | |||||
| HCCL_DATA_TYPE_FP16 = 3, /**< fp16 */ | |||||
| HCCL_DATA_TYPE_FP32 = 4, /**< fp32 */ | |||||
| HCCL_DATA_TYPE_INT64 = 5, /**< int64 */ | |||||
| HCCL_DATA_TYPE_UINT64 = 6, /**< uint64 */ | |||||
| HCCL_DATA_TYPE_RESERVED /**< reserved */ | |||||
| } HcclDataType; | |||||
| const uint32_t HCCL_ROOT_INFO_BYTES = 4108; // 4108: root info length | |||||
| /** | |||||
| * @brief HCCL root info | |||||
| */ | |||||
| typedef struct HcclRootInfoDef { | |||||
| char internal[HCCL_ROOT_INFO_BYTES]; | |||||
| } HcclRootInfo; | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif // __cplusplus | |||||
| #endif // HCCL_TYPES_H_ | |||||
| @@ -24,6 +24,8 @@ | |||||
| #include <hccl/base.h> | #include <hccl/base.h> | ||||
| #include <hccl/hccl_types.h> | #include <hccl/hccl_types.h> | ||||
| #include <functional> | |||||
| #include <vector> | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| @@ -40,6 +42,15 @@ extern "C" { | |||||
| */ | */ | ||||
| HcclResult hcom_get_rank_size(const char *group, u32 *rankSize); | HcclResult hcom_get_rank_size(const char *group, u32 *rankSize); | ||||
| /** | |||||
| * @brief Get the rank number in the group. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param rankSize A pointer identifying the rank number. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomGetRankSize(const char *group, u32 *rankSize); | |||||
| /** | /** | ||||
| * @brief Get the rank number of this rank's server within the group. | * @brief Get the rank number of this rank's server within the group. | ||||
| * | * | ||||
| @@ -49,6 +60,15 @@ HcclResult hcom_get_rank_size(const char *group, u32 *rankSize); | |||||
| */ | */ | ||||
| HcclResult hcom_get_local_rank_size(const char *group, u32 *localRankSize); | HcclResult hcom_get_local_rank_size(const char *group, u32 *localRankSize); | ||||
| /** | |||||
| * @brief Get the rank number of this rank's server within the group. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param localRankSize A pointer identifying the rank number. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomGetLocalRankSize(const char *group, u32 *localRankSize); | |||||
| /** | /** | ||||
| * @brief Get the rank id of this rank. | * @brief Get the rank id of this rank. | ||||
| * | * | ||||
| @@ -58,6 +78,15 @@ HcclResult hcom_get_local_rank_size(const char *group, u32 *localRankSize); | |||||
| */ | */ | ||||
| HcclResult hcom_get_rank_id(const char *group, u32 *rankId); | HcclResult hcom_get_rank_id(const char *group, u32 *rankId); | ||||
| /** | |||||
| * @brief Get the rank id of this rank. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param rankId A pointer identifying the rank id. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomGetRankId(const char *group, u32 *rankId); | |||||
| /** | /** | ||||
| * @brief Get the local rank id of this rank's server within the group. | * @brief Get the local rank id of this rank's server within the group. | ||||
| * | * | ||||
| @@ -67,6 +96,15 @@ HcclResult hcom_get_rank_id(const char *group, u32 *rankId); | |||||
| */ | */ | ||||
| HcclResult hcom_get_local_rank_id(const char *group, u32 *localRankId); | HcclResult hcom_get_local_rank_id(const char *group, u32 *localRankId); | ||||
| /** | |||||
| * @brief Get the local rank id of this rank's server within the group. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param localRankId A pointer identifying the local rank id. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomGetLocalRankId(const char *group, u32 *localRankId); | |||||
| /** | /** | ||||
| * @brief Get the world rank id according to the group rank id. | * @brief Get the world rank id according to the group rank id. | ||||
| * | * | ||||
| @@ -77,6 +115,16 @@ HcclResult hcom_get_local_rank_id(const char *group, u32 *localRankId); | |||||
| */ | */ | ||||
| HcclResult hcom_get_world_rank_from_group_rank(const char *group, u32 groupRank, u32 *worldRank); | HcclResult hcom_get_world_rank_from_group_rank(const char *group, u32 groupRank, u32 *worldRank); | ||||
| /** | |||||
| * @brief Get the world rank id according to the group rank id. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param groupRank An integer(u32) identifying the group rank id. | |||||
| * @param worldRank A pointer identifying the world rank id. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomGetWorldRankFromGroupRank(const char *group, u32 groupRank, u32 *worldRank); | |||||
| /** | /** | ||||
| * @brief Get the group rank id according to the world rank id. | * @brief Get the group rank id according to the world rank id. | ||||
| * | * | ||||
| @@ -87,6 +135,16 @@ HcclResult hcom_get_world_rank_from_group_rank(const char *group, u32 groupRank, | |||||
| */ | */ | ||||
| HcclResult hcom_get_group_rank_from_world_rank(u32 worldRank, const char *group, u32 *groupRank); | HcclResult hcom_get_group_rank_from_world_rank(u32 worldRank, const char *group, u32 *groupRank); | ||||
| /** | |||||
| * @brief Get the group rank id according to the world rank id. | |||||
| * | |||||
| * @param worldRank An integer(u32) identifying the world rank id. | |||||
| * @param group A string identifying the group name. | |||||
| * @param groupRank A pointer identifying the group rank id. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomGetGroupRankFromWorldRank(u32 worldRank, const char *group, u32 *groupRank); | |||||
| /** | /** | ||||
| * @brief Create group. | * @brief Create group. | ||||
| * | * | ||||
| @@ -97,6 +155,16 @@ HcclResult hcom_get_group_rank_from_world_rank(u32 worldRank, const char *group, | |||||
| */ | */ | ||||
| HcclResult hcom_create_group(const char *group, u32 rankNum, u32 *rankIds); | HcclResult hcom_create_group(const char *group, u32 rankNum, u32 *rankIds); | ||||
| /** | |||||
| * @brief Create group. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param rankNum An integer(u32) identifying the number of ranks in the group. | |||||
| * @param rankIds A list identifying the ranks in the group. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomCreateGroup(const char *group, u32 rankNum, u32 *rankIds); | |||||
| /** | /** | ||||
| * @brief Destroy group | * @brief Destroy group | ||||
| * | * | ||||
| @@ -105,6 +173,14 @@ HcclResult hcom_create_group(const char *group, u32 rankNum, u32 *rankIds); | |||||
| */ | */ | ||||
| HcclResult hcom_destroy_group(const char *group); | HcclResult hcom_destroy_group(const char *group); | ||||
| /** | |||||
| * @brief Destroy group | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @return HcclResult | |||||
| */ | |||||
| HcclResult HcomDestroyGroup(const char *group); | |||||
| /** | /** | ||||
| * @brief Set the gradient split strategy with in the group, according to gradient index. | * @brief Set the gradient split strategy with in the group, according to gradient index. | ||||
| * | * | ||||
| @@ -115,6 +191,16 @@ HcclResult hcom_destroy_group(const char *group); | |||||
| */ | */ | ||||
| extern HcclResult hcom_set_split_strategy_by_index(const char *group, u32 segmentNum, const u32 *IdxList); | extern HcclResult hcom_set_split_strategy_by_index(const char *group, u32 segmentNum, const u32 *IdxList); | ||||
| /** | |||||
| * @brief Set the gradient split strategy with in the group, according to gradient index. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param segmentNum An integer(u32) identifying the segments number of gradients. | |||||
| * @param IdxList A list identifying the index of end gradient in each segment. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcomSetGradFusionByIndex(const char *group, u32 segmentNum, const u32 *IdxList); | |||||
| /** | /** | ||||
| * @brief Set the gradient split strategy with in the group, according to gradient data size. | * @brief Set the gradient split strategy with in the group, according to gradient data size. | ||||
| * | * | ||||
| @@ -125,6 +211,16 @@ extern HcclResult hcom_set_split_strategy_by_index(const char *group, u32 segmen | |||||
| */ | */ | ||||
| extern HcclResult hcom_set_split_strategy_by_size(const char *group, u32 segmentNum, const float *sizeList); | extern HcclResult hcom_set_split_strategy_by_size(const char *group, u32 segmentNum, const float *sizeList); | ||||
| /** | |||||
| * @brief Set the gradient split strategy with in the group, according to gradient data size. | |||||
| * | |||||
| * @param group A string identifying the group name. | |||||
| * @param segmentNum An integer(u32) identifying the segments number of gradients. | |||||
| * @param sizeList A list identifying the percent of each segment. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcomSetGradFusionBySize(const char *group, u32 segmentNum, const float *sizeList); | |||||
| /** | /** | ||||
| * @brief Register memories and init resources for remote access. | * @brief Register memories and init resources for remote access. | ||||
| * | * | ||||
| @@ -134,6 +230,25 @@ extern HcclResult hcom_set_split_strategy_by_size(const char *group, u32 segment | |||||
| */ | */ | ||||
| extern HcclResult hcom_remote_access_mem_register(const MemRegisterAddr* addrList, u32 count); | extern HcclResult hcom_remote_access_mem_register(const MemRegisterAddr* addrList, u32 count); | ||||
| /** | |||||
| * @brief Register memories and init resources for remote access. | |||||
| * | |||||
| * @param addrList memory addresses for remote access. | |||||
| * @param count number of remote memory addresses. | |||||
| * @return HcclResult | |||||
| */ | |||||
| extern HcclResult HcomRegRemoteAccessMem(const MemRegisterAddr* addrList, u32 count); | |||||
| HcclResult HcomExecInitialize(); | |||||
| HcclResult HcomExecFinalize(); | |||||
| HcclResult HcomExecEnqueueOperation(HcomOperation opInfo, std::function<void(HcclResult status)> callback); | |||||
| HcclResult HcomExecEnqueueRemoteAccess(const std::string& remoteAccessType, | |||||
| const std::vector<HcomRemoteAccessAddrInfo>& addrInfos, | |||||
| std::function<void(HcclResult status)> callback); | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif // __cplusplus | #endif // __cplusplus | ||||
| @@ -50,7 +50,7 @@ typedef int (*mmFilter)(const mmDirent *entry); | |||||
| typedef int (*mmFilter2)(const mmDirent2 *entry); | typedef int (*mmFilter2)(const mmDirent2 *entry); | ||||
| typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); | typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); | ||||
| typedef int (*mmSort2)(const mmDirent2 **a, const mmDirent2 **b); | typedef int (*mmSort2)(const mmDirent2 **a, const mmDirent2 **b); | ||||
| typedef size_t mmSize_t; | |||||
| typedef size_t mmSize_t; //lint !e410 !e1051 | |||||
| typedef off_t mmOfft_t; | typedef off_t mmOfft_t; | ||||
| typedef pid_t mmPid_t; | typedef pid_t mmPid_t; | ||||
| typedef long MM_LONG; | typedef long MM_LONG; | ||||
| @@ -215,6 +215,10 @@ typedef struct { | |||||
| #define S_IWRITE S_IWUSR | #define S_IWRITE S_IWUSR | ||||
| #endif | #endif | ||||
| #define mm_no_argument no_argument | |||||
| #define mm_required_argument required_argument | |||||
| #define mm_optional_argument optional_argument | |||||
| #define M_FILE_RDONLY O_RDONLY | #define M_FILE_RDONLY O_RDONLY | ||||
| #define M_FILE_WRONLY O_WRONLY | #define M_FILE_WRONLY O_WRONLY | ||||
| #define M_FILE_RDWR O_RDWR | #define M_FILE_RDWR O_RDWR | ||||
| @@ -412,8 +416,12 @@ MMPA_FUNC_VISIBILITY VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount); | |||||
| // Poll related interface | // Poll related interface | ||||
| MMPA_FUNC_VISIBILITY mmCompletionHandle mmCreateCompletionPort(); | MMPA_FUNC_VISIBILITY mmCompletionHandle mmCreateCompletionPort(); | ||||
| MMPA_FUNC_VISIBILITY VOID mmCloseCompletionPort(mmCompletionHandle handle); | MMPA_FUNC_VISIBILITY VOID mmCloseCompletionPort(mmCompletionHandle handle); | ||||
| MMPA_FUNC_VISIBILITY INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, | |||||
| pmmPollData polledData, mmPollBack pollBack); | |||||
| MMPA_FUNC_VISIBILITY INT32 mmPoll(mmPollfd *fds, | |||||
| INT32 fdCount, | |||||
| INT32 timeout, | |||||
| mmCompletionHandle handleIOCP, | |||||
| pmmPollData polledData, | |||||
| mmPollBack pollBack); | |||||
| MMPA_FUNC_VISIBILITY INT32 mmGetErrorCode(); | MMPA_FUNC_VISIBILITY INT32 mmGetErrorCode(); | ||||
| MMPA_FUNC_VISIBILITY CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); | MMPA_FUNC_VISIBILITY CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); | ||||
| MMPA_FUNC_VISIBILITY INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); | MMPA_FUNC_VISIBILITY INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); | ||||
| @@ -237,6 +237,11 @@ typedef struct { | |||||
| } mmThreadAttr; | } mmThreadAttr; | ||||
| typedef VOID (*mmPf)(VOID); | typedef VOID (*mmPf)(VOID); | ||||
| #define mm_no_argument 0 | |||||
| #define mm_required_argument 1 | |||||
| #define mm_optional_argument 2 | |||||
| #define M_FILE_RDONLY GENERIC_READ | #define M_FILE_RDONLY GENERIC_READ | ||||
| #define M_FILE_WRONLY GENERIC_WRITE | #define M_FILE_WRONLY GENERIC_WRITE | ||||
| #define M_FILE_RDWR (GENERIC_READ | GENERIC_WRITE) | #define M_FILE_RDWR (GENERIC_READ | GENERIC_WRITE) | ||||
| @@ -18,6 +18,7 @@ | |||||
| #define __CCE_RUNTIME_BASE_H__ | #define __CCE_RUNTIME_BASE_H__ | ||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include "toolchain/prof_callback.h" | |||||
| #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) | #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) | ||||
| extern "C" { | extern "C" { | ||||
| @@ -86,10 +87,20 @@ typedef struct rtExceptionInfo { | |||||
| uint32_t deviceid; | uint32_t deviceid; | ||||
| } rtExceptionInfo; | } rtExceptionInfo; | ||||
| typedef struct rtTaskFailInfo { | |||||
| uint32_t taskid; | |||||
| uint32_t streamid; | |||||
| uint32_t tid; | |||||
| uint32_t deviceid; | |||||
| uint32_t retcode; | |||||
| } rtTaskFailInfo; | |||||
| typedef void (*rtErrorCallback)(rtExceptionType); | typedef void (*rtErrorCallback)(rtExceptionType); | ||||
| typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo); | typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo); | ||||
| typedef void (*rtTaskFailCallbackByModule)(rtTaskFailInfo *exceptionInfo); | |||||
| typedef void (*rtDeviceStateCallback)(uint32_t devId, bool isOpen); | typedef void (*rtDeviceStateCallback)(uint32_t devId, bool isOpen); | ||||
| /** | /** | ||||
| @@ -146,6 +157,12 @@ RTS_API rtError_t rtProfilerStop(uint64_t profConfig, int32_t numsDev, uint32_t* | |||||
| */ | */ | ||||
| RTS_API rtError_t rtProfilerTrace(uint64_t id, bool notify, uint32_t flags, rtStream_t stream); | RTS_API rtError_t rtProfilerTrace(uint64_t id, bool notify, uint32_t flags, rtStream_t stream); | ||||
| /** | |||||
| * @ingroup profiling_base | |||||
| * @brief ts set profiling reporter callback. | |||||
| */ | |||||
| RTS_API rtError_t rtSetMsprofReporterCallback(MsprofReporterCallback callback); | |||||
| /** | /** | ||||
| * @ingroup dvrt_base | * @ingroup dvrt_base | ||||
| * @brief Returns the last error from a runtime call. | * @brief Returns the last error from a runtime call. | ||||
| @@ -184,6 +201,16 @@ RTS_API rtError_t rtSetTaskFailCallback(rtTaskFailCallback callback); | |||||
| */ | */ | ||||
| RTS_API rtError_t rtRegDeviceStateCallback(const char *regName, rtDeviceStateCallback callback); | RTS_API rtError_t rtRegDeviceStateCallback(const char *regName, rtDeviceStateCallback callback); | ||||
| /** | |||||
| * @ingroup dvrt_base | |||||
| * @brief register callback for fail task | |||||
| * @param [in] uniName unique register name, can't be null | |||||
| * @param [in] callback fail task callback function | |||||
| * @param [out] NA | |||||
| * @return RT_ERROR_NONE for ok | |||||
| */ | |||||
| RTS_API rtError_t rtRegTaskFailCallbackByModule(const char *moduleName, rtTaskFailCallbackByModule callback); | |||||
| /** | /** | ||||
| * @ingroup dvrt_base | * @ingroup dvrt_base | ||||
| * @brief notify handle. | * @brief notify handle. | ||||
| @@ -121,14 +121,6 @@ typedef struct tagRtMemoryConfig { | |||||
| typedef struct tagRtPlatformConfig { uint32_t platformConfig; } rtPlatformConfig_t; | typedef struct tagRtPlatformConfig { uint32_t platformConfig; } rtPlatformConfig_t; | ||||
| /** | |||||
| * @ingroup | |||||
| * @brief get platform | |||||
| * @param [in] platForm | |||||
| * @return platForm | |||||
| */ | |||||
| RTS_API rtError_t rtGetPlatformConfig(rtPlatformConfig_t *platForm); | |||||
| /** | /** | ||||
| * @ingroup | * @ingroup | ||||
| * @brief get AI core count | * @brief get AI core count | ||||
| @@ -169,13 +161,6 @@ RTS_API rtError_t rtGetAiCoreMemoryRates(rtAiCoreMemoryRates_t *aiCoreMemoryRate | |||||
| */ | */ | ||||
| RTS_API rtError_t rtGetMemoryConfig(rtMemoryConfig_t *memoryConfig); | RTS_API rtError_t rtGetMemoryConfig(rtMemoryConfig_t *memoryConfig); | ||||
| /** | |||||
| * @ingroup | |||||
| * @brief set platform in gen ctx | |||||
| * @param [in] platForm | |||||
| * @return RT_ERROR_NONE for ok, errno for failed | |||||
| */ | |||||
| RTS_API rtError_t rtSetPlatformType(rtPlatformType_t platformType); | |||||
| /** | /** | ||||
| * @ingroup | * @ingroup | ||||
| @@ -23,6 +23,7 @@ | |||||
| #include <mutex> | #include <mutex> | ||||
| #include "tdt/status.h" | #include "tdt/status.h" | ||||
| #include "tdt/data_common.h" | #include "tdt/data_common.h" | ||||
| #include "toolchain/prof_callback.h" | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| @@ -37,7 +38,7 @@ extern "C" { | |||||
| * Used for the Framework process to communicate with the TSDDaemon process, | * Used for the Framework process to communicate with the TSDDaemon process, | ||||
| * and notify TSD to complete the initialization of other processes | * and notify TSD to complete the initialization of other processes | ||||
| * | * | ||||
| * @param phyDeviceId [IN] type #unsigned int. Physical device ID | |||||
| * @param logicDeviceId [IN] type #unsigned int. Logic device ID | |||||
| * @param rankSize [IN] type #unsigned int. The rankSize of the training. | * @param rankSize [IN] type #unsigned int. The rankSize of the training. | ||||
| * The default value is 1. When rankSize is greater than 1, | * The default value is 1. When rankSize is greater than 1, | ||||
| * HCCP will be pulled to perform set communication related operations. | * HCCP will be pulled to perform set communication related operations. | ||||
| @@ -49,7 +50,7 @@ extern "C" { | |||||
| * @li tsd_client.h: Header file where the interface declaration is located. | * @li tsd_client.h: Header file where the interface declaration is located. | ||||
| * @li data_common.h: Header file where 'TDT_StatusT' defined | * @li data_common.h: Header file where 'TDT_StatusT' defined | ||||
| */ | */ | ||||
| TDT_LIB_EXPORT TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize); | |||||
| TDT_LIB_EXPORT TDT_StatusT TsdOpen(const uint32_t logicDeviceId, const uint32_t rankSize); | |||||
| /** | /** | ||||
| * @ingroup Close | * @ingroup Close | ||||
| @@ -67,7 +68,7 @@ TDT_LIB_EXPORT TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t ra | |||||
| * @li tsd_client.h: Header file where the interface declaration is located. | * @li tsd_client.h: Header file where the interface declaration is located. | ||||
| * @li data_common.h: Header file where 'TDT_StatusT' defined | * @li data_common.h: Header file where 'TDT_StatusT' defined | ||||
| */ | */ | ||||
| TDT_LIB_EXPORT TDT_StatusT TsdClose(const uint32_t phyDeviceId); | |||||
| TDT_LIB_EXPORT TDT_StatusT TsdClose(const uint32_t logicDeviceId); | |||||
| /** | /** | ||||
| * @ingroup UpdateProfilingMode | * @ingroup UpdateProfilingMode | ||||
| @@ -85,7 +86,26 @@ TDT_LIB_EXPORT TDT_StatusT TsdClose(const uint32_t phyDeviceId); | |||||
| * @li tsd_client.h: Header file where the interface declaration is located. | * @li tsd_client.h: Header file where the interface declaration is located. | ||||
| * @li data_common.h: Header file where 'TDT_StatusT' defined | * @li data_common.h: Header file where 'TDT_StatusT' defined | ||||
| */ | */ | ||||
| TDT_LIB_EXPORT TDT_StatusT UpdateProfilingMode(const uint32_t phyDeviceId, const uint32_t flag); | |||||
| TDT_LIB_EXPORT TDT_StatusT UpdateProfilingMode(const uint32_t logicDeviceId, const uint32_t flag); | |||||
| /** | |||||
| * @ingroup TsdSetMsprofReporterCallback | |||||
| * @brief 用于推理场景下设置aicpu的profilng的callback函数 | |||||
| * | |||||
| * @par Function | |||||
| * 设置offline模式下aicpu_sd进程的profiling的callback函数 | |||||
| * | |||||
| * @param callback [IN] type #MsprofReporterCallback. 回调函数 | |||||
| * @retval TDT_OK Success | |||||
| * @retval OtherValues Failure | |||||
| * | |||||
| * @par Dependency | |||||
| * @li libtsdclient.so: Library to which the interface belongs. | |||||
| * @li tsd_client.h: Header file where the interface declaration is located. | |||||
| * @li data_common.h: Header file where 'TDT_StatusT' defined | |||||
| * @li prof_callback.h: Headerfile where 'MsprofReporterCallback' defined | |||||
| */ | |||||
| TDT_LIB_EXPORT TDT_StatusT TsdSetMsprofReporterCallback(MsprofReporterCallback callback); | |||||
| /** | /** | ||||
| * @ingroup CreateCmdParameterObj | * @ingroup CreateCmdParameterObj | ||||
| @@ -17,380 +17,76 @@ | |||||
| #ifndef MSPROFILER_API_PROF_ACL_API_H_ | #ifndef MSPROFILER_API_PROF_ACL_API_H_ | ||||
| #define MSPROFILER_API_PROF_ACL_API_H_ | #define MSPROFILER_API_PROF_ACL_API_H_ | ||||
| #define MSVP_MAX_DEV_NUM 64 | |||||
| #ifndef OS_TYPE | |||||
| #define OS_TYPE 0 | |||||
| #endif // OS_TYPE | |||||
| #if (OS_TYPE != LINUX) | |||||
| #define MSVP_PROF_API __declspec(dllexport) | |||||
| #else | |||||
| #define MSVP_PROF_API __attribute__((visibility("default"))) | |||||
| #endif | |||||
| // DataTypeConfig | // DataTypeConfig | ||||
| #define PROF_ACL_API 0x0001 | |||||
| #define PROF_TASK_TIME 0x0002 | |||||
| #define PROF_AICORE_METRICS 0x0004 | |||||
| #define PROF_AICPU_TRACE 0x0008 | |||||
| #define PROF_MODEL_EXECUTE 0x0010 | |||||
| #define PROF_RUNTIME_API 0x0020 | |||||
| #define PROF_RUNTIME_TRACE 0x0040 | |||||
| #define PROF_SCHEDULE_TIMELINE 0x0080 | |||||
| #define PROF_SCHEDULE_TRACE 0x0100 | |||||
| #define PROF_AIVECTORCORE_METRICS 0x0200 | |||||
| #define PROF_SUBTASK_TIME 0x0400 | |||||
| #define PROF_TRAINING_TRACE 0x0800 | |||||
| #define PROF_HCCL_TRACE 0x1000 | |||||
| #define PROF_DATA_PROCESS 0x2000 | |||||
| #define PROF_TASK_TRACE 0x3842 | |||||
| #define PROF_ACL_API 0x00000001 | |||||
| #define PROF_TASK_TIME 0x00000002 | |||||
| #define PROF_AICORE_METRICS 0x00000004 | |||||
| #define PROF_AICPU_TRACE 0x00000008 | |||||
| #define PROF_MODEL_EXECUTE 0x00000010 | |||||
| #define PROF_RUNTIME_API 0x00000020 | |||||
| #define PROF_RUNTIME_TRACE 0x00000040 | |||||
| #define PROF_SCHEDULE_TIMELINE 0x00000080 | |||||
| #define PROF_SCHEDULE_TRACE 0x00000100 | |||||
| #define PROF_AIVECTORCORE_METRICS 0x00000200 | |||||
| #define PROF_SUBTASK_TIME 0x00000400 | |||||
| #define PROF_TRAINING_TRACE 0x00000800 | |||||
| #define PROF_HCCL_TRACE 0x00001000 | |||||
| #define PROF_TASK_TRACE 0x00001852 | |||||
| // system profilinig switch | |||||
| #define PROF_CPU 0x00010000 | |||||
| #define PROF_HARDWARE_MEMORY 0x00020000 | |||||
| #define PROF_IO 0x00040000 | |||||
| #define PROF_INTER_CONNECTION 0x00080000 | |||||
| #define PROF_DVPP 0x00100000 | |||||
| #define PROF_SYS_AICORE_SAMPLE 0x00200000 | |||||
| #define PROF_AIVECTORCORE_SAMPLE 0x00400000 | |||||
| #define PROF_MODEL_LOAD 0x8000000000000000 | #define PROF_MODEL_LOAD 0x8000000000000000 | ||||
| // DataTypeConfig MASK | // DataTypeConfig MASK | ||||
| #define PROF_ACL_API_MASK 0x0001 | |||||
| #define PROF_TASK_TIME_MASK 0x0002 | |||||
| #define PROF_AICORE_METRICS_MASK 0x0004 | |||||
| #define PROF_AICPU_TRACE_MASK 0x0008 | |||||
| #define PROF_MODEL_EXECUTE_MASK 0x0010 | |||||
| #define PROF_RUNTIME_API_MASK 0x0020 | |||||
| #define PROF_RUNTIME_TRACE_MASK 0x0040 | |||||
| #define PROF_SCHEDULE_TIMELINE_MASK 0x0080 | |||||
| #define PROF_SCHEDULE_TRACE_MASK 0x0100 | |||||
| #define PROF_AIVECTORCORE_METRICS_MASK 0x0200 | |||||
| #define PROF_SUBTASK_TIME_MASK 0x0400 | |||||
| #define PROF_TRAINING_TRACE_MASK 0x0800 | |||||
| #define PROF_HCCL_TRACE_MASK 0x1000 | |||||
| #define PROF_DATA_PROCESS_MASK 0x2000 | |||||
| #define PROF_ACL_API_MASK 0x00000001 | |||||
| #define PROF_TASK_TIME_MASK 0x00000002 | |||||
| #define PROF_AICORE_METRICS_MASK 0x00000004 | |||||
| #define PROF_AICPU_TRACE_MASK 0x00000008 | |||||
| #define PROF_MODEL_EXECUTE_MASK 0x00000010 | |||||
| #define PROF_RUNTIME_API_MASK 0x00000020 | |||||
| #define PROF_RUNTIME_TRACE_MASK 0x00000040 | |||||
| #define PROF_SCHEDULE_TIMELINE_MASK 0x00000080 | |||||
| #define PROF_SCHEDULE_TRACE_MASK 0x00000100 | |||||
| #define PROF_AIVECTORCORE_METRICS_MASK 0x00000200 | |||||
| #define PROF_SUBTASK_TIME_MASK 0x00000400 | |||||
| #define PROF_TRAINING_TRACE_MASK 0x00000800 | |||||
| #define PROF_HCCL_TRACE_MASK 0x00001000 | |||||
| // system profilinig mask | |||||
| #define PROF_CPU_MASK 0x00010000 | |||||
| #define PROF_HARDWARE_MEMORY_MASK 0x00020000 | |||||
| #define PROF_IO_MASK 0x00040000 | |||||
| #define PROF_INTER_CONNECTION_MASK 0x00080000 | |||||
| #define PROF_DVPP_MASK 0x00100000 | |||||
| #define PROF_SYS_AICORE_SAMPLE_MASK 0x00200000 | |||||
| #define PROF_AIVECTORCORE_SAMPLE_MASK 0x00400000 | |||||
| #define PROF_MODEL_LOAD_MASK 0x8000000000000000 | #define PROF_MODEL_LOAD_MASK 0x8000000000000000 | ||||
| #include <cstdint> | #include <cstdint> | ||||
| #include <string> | |||||
| /** | |||||
| * @name ProrErrorCode | |||||
| * @brief error code enum of prof_acl_apis | |||||
| */ | |||||
| enum ProfErrorCode { | |||||
| PROF_ERROR_NONE = 0, // ok | |||||
| PROF_ERROR_PARAM_INVALID, // param invalid, for example nullptr | |||||
| PROF_ERROR_REPEAT_INIT, // profiling has already been inited | |||||
| PROF_ERROR_CONFIG_INVALID, // config invalid, for example invalid json string | |||||
| PROF_ERROR_DIR_NO_ACCESS, // dir is not accessable | |||||
| PROF_ERROR_FAILURE, // failed to init or start profiling | |||||
| PROF_ERROR_NOT_INITED, // profiling has not been inited | |||||
| PROF_ERROR_DEVICE_INVALID, // device id invalid | |||||
| PROF_ERROR_UNSUPPORTED, // unsupported data type or ai core metrics | |||||
| PROF_ERROR_REPEAT_START, // profiilng has already been started | |||||
| PROF_ERROR_NOT_STARTED, // profiling has not been started | |||||
| PROF_ERROR_REPEAT_SUBSCRIBE, // same model id has already been subscribed | |||||
| PROF_ERROR_MODEL_ID_INVALID, // model id does not exist or has not been subscribed | |||||
| PROF_ERROR_API_CONFLICT, // prof ctrl api mode conflicts with subscribe mode | |||||
| }; | |||||
| /** | |||||
| * @brief transfer profiling config in acl.json to sample config | |||||
| * @param aclCfg [IN] profiling json string from acl.json as {"switch":"on", "result_path":"/home",...} | |||||
| * @param sampleCfg [OUT] json string for GE as {"startCfg":[{"deviceID":"all","jobID":"1234",...}]} | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfAclCfgToSampleCfg(const std::string &aclCfg, std::string &sampleCfg); | |||||
| /** | |||||
| * @name ProfInit | |||||
| * @brief init profiling | |||||
| * @param profInitCfg [IN] config of init profiling of json format | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfInit(const std::string &profInitCfg); | |||||
| /** | |||||
| * @name ProfAicoreMetrics | |||||
| * @brief aicore metrics enum | |||||
| */ | |||||
| enum ProfAicoreMetrics { | |||||
| PROF_AICORE_ARITHMATIC_THROUGHPUT = 0, | |||||
| PROF_AICORE_PIPELINE = 1, | |||||
| PROF_AICORE_SYNCHRONIZATION = 2, | |||||
| PROF_AICORE_MEMORY = 3, | |||||
| PROF_AICORE_INTERNAL_MEMORY = 4, | |||||
| PROF_AICORE_STALL = 5, | |||||
| PROF_AICORE_METRICS_COUNT, | |||||
| PROF_AICORE_NONE = 0xff, | |||||
| }; | |||||
| /** | |||||
| * @name ProfConfig | |||||
| * @brief struct of ProfStart | |||||
| */ | |||||
| struct ProfConfig { | |||||
| uint32_t devNums; // length of device id list | |||||
| uint32_t devIdList[MSVP_MAX_DEV_NUM]; // physical device id list | |||||
| ProfAicoreMetrics aicoreMetrics; // aicore metric | |||||
| uint64_t dataTypeConfig; // data type to start profiling | |||||
| }; | |||||
| /** | |||||
| * @name ProfStartProfiling | |||||
| * @brief start profiling | |||||
| * @param profStartCfg [IN] config to start profiling | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfStartProfiling(const ProfConfig *profStartCfg); | |||||
| /** | |||||
| * @name ProfStopProfiling | |||||
| * @brief stop profiling | |||||
| * @param profStopCfg [IN] config to stop profiling | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfStopProfiling(const ProfConfig *profStopCfg); | |||||
| /** | |||||
| * @name ProfFinalize | |||||
| * @brief finalize profiling task | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfFinalize(); | |||||
| /** | |||||
| * @name ProfGetDataTypeConfig | |||||
| * @brief get dataTypeConfig started with of one device | |||||
| * @param deviceId [IN] deviceId to get dataTypeConfig | |||||
| * @param dataTypeConfig [OUT] result get | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfGetDataTypeConfig(uint32_t deviceId, uint64_t &dataTypeConfig); | |||||
| namespace Msprofiler { | namespace Msprofiler { | ||||
| namespace Api { | namespace Api { | ||||
| /** | |||||
| * @brief transfer profiling config in acl.json to sample config | |||||
| * @param aclCfg [IN] profiling json string from acl.json as {"switch":"on", "result_path":"/home",...} | |||||
| * @param sampleCfg [OUT] json string for GE as {"startCfg":[{"deviceID":"all","jobID":"1234",...}]} | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfAclCfgToSampleCfg(const std::string &aclCfg, std::string &sampleCfg); | |||||
| /** | |||||
| * @name ProfInit | |||||
| * @brief init profiling | |||||
| * @param profInitCfg [IN] config of init profiling of json format | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfInit(const std::string &profInitCfg); | |||||
| /** | |||||
| * @name ProfStartProfiling | |||||
| * @brief start profiling | |||||
| * @param profStartCfg [IN] config to start profiling | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfStartProfiling(const ProfConfig *profStartCfg); | |||||
| /** | |||||
| * @name ProfStopProfiling | |||||
| * @brief stop profiling | |||||
| * @param profStopCfg [IN] config to stop profiling | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfStopProfiling(const ProfConfig *profStopCfg); | |||||
| /** | |||||
| * @name ProfFinalize | |||||
| * @brief finalize profiling task | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfFinalize(); | |||||
| /** | |||||
| * @name ProfGetDataTypeConfig | |||||
| * @brief get dataTypeConfig started with of one device | |||||
| * @param deviceId [IN] deviceId to get dataTypeConfig | |||||
| * @param dataTypeConfig [OUT] result get | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfGetDataTypeConfig(uint32_t deviceId, uint64_t &dataTypeConfig); | |||||
| /** | |||||
| * @name WorkMode | |||||
| * @brief profiling api work mode | |||||
| */ | |||||
| enum WorkMode { | |||||
| WORK_MODE_OFF, // profiling not at work | |||||
| WORK_MODE_API_CTRL, // profiling work on api ctrl mode, (ProfInit) | |||||
| WORK_MODE_SUBSCRIBE, // profiling work on subscribe mode | |||||
| }; | |||||
| /** | |||||
| * @name ProfGetApiWorkMode | |||||
| * @brief get profiling api work mode | |||||
| * @return WorkMode | |||||
| */ | |||||
| MSVP_PROF_API WorkMode ProfGetApiWorkMode(); | |||||
| /** | |||||
| * @name ProfSubscribeConfig | |||||
| * @brief config of subscribe api | |||||
| */ | |||||
| struct ProfSubscribeConfig { | |||||
| bool timeInfo; // subscribe op time | |||||
| ProfAicoreMetrics aicoreMetrics; // subscribe ai core metrics | |||||
| void* fd; // pipe fd | |||||
| }; | |||||
| /** | |||||
| * @name ProfGetDataTypeConfig | |||||
| * @brief get DataTypeConfig of subscribe | |||||
| * @param profSubscribeConfig [IN] config to subscribe data | |||||
| * @return DataTypeConfig | |||||
| */ | |||||
| MSVP_PROF_API uint64_t ProfGetDataTypeConfig(const ProfSubscribeConfig *profSubscribeConfig); | |||||
| /** | |||||
| * @name ProfModelSubscribe | |||||
| * @brief subscribe data of one model id | |||||
| * @param modelId [IN] model id to subscribe data | |||||
| * @param devId [IN] device id of model | |||||
| * @param profSubscribeConfig [IN] config to subscribe data | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfModelSubscribe(uint32_t modelId, uint32_t devId, | |||||
| const ProfSubscribeConfig *profSubscribeConfig); | |||||
| /** | |||||
| * @name ProfIsModelSubscribed | |||||
| * @brief check if a model id is subscribed | |||||
| * @param modeiId [IN] modei id to check | |||||
| * @return true: subscribed, false: not | |||||
| */ | |||||
| MSVP_PROF_API bool ProfIsModelSubscribed(uint32_t modelId); | |||||
| /** | |||||
| * @name ProfModelUnSubscribe | |||||
| * @brief unsubscribe a model id | |||||
| * @param modeiId [IN] modei id to unsubscribe | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfModelUnSubscribe(uint32_t modelId); | |||||
| /** | |||||
| * @name ProfGetOpDescSize | |||||
| * @brief get profiling data struct size | |||||
| * @param opDescSize [OUT] bytes of profiling subscribe data struct | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfGetOpDescSize(uint32_t *opDescSize); | |||||
| /** | |||||
| * @name ProfGetOpNum | |||||
| * @brief get how many op data there are in data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param opNum [OUT] number of op in data | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfGetOpNum(const void *data, uint32_t len, uint32_t *opNum); | |||||
| /** | |||||
| * @name ProfGetModelId | |||||
| * @brief get model id of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | |||||
| * @return model id | |||||
| */ | |||||
| MSVP_PROF_API uint32_t ProfGetModelId(const void *data, uint32_t len, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpType | |||||
| * @brief get op type of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param opType [OUT] op type buffer | |||||
| * @param opTypeLen [IN] buffer size of param opType | |||||
| * @param index [IN] index of part(op) | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfGetOpType(const void *data, uint32_t len, char *opType, uint32_t opTypeLen, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpName | |||||
| * @brief get op name of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param opType [OUT] op name buffer | |||||
| * @param opTypeLen [IN] buffer size of param opName | |||||
| * @param index [IN] index of part(op) | |||||
| * @return ProfErrorCode | |||||
| */ | |||||
| MSVP_PROF_API int32_t ProfGetOpName(const void *data, uint32_t len, char *opName, uint32_t opNameLen, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpStart | |||||
| * @brief get op start timestamp of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | |||||
| * @return op start timestamp (us) | |||||
| */ | |||||
| MSVP_PROF_API uint64_t ProfGetOpStart(const void *data, uint32_t len, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpEnd | |||||
| * @brief get op end timestamp of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | |||||
| * @return op end timestamp (us) | |||||
| */ | |||||
| MSVP_PROF_API uint64_t ProfGetOpEnd(const void *data, uint32_t len, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpDuration | |||||
| * @brief get op duration of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | |||||
| * @return op duration (us) | |||||
| */ | |||||
| MSVP_PROF_API uint64_t ProfGetOpDuration(const void *data, uint32_t len, uint32_t index); | |||||
| /** | /** | ||||
| * @name ProfGetOpExecutionTime | * @name ProfGetOpExecutionTime | ||||
| * @brief get op execution time of specific part of data | * @brief get op execution time of specific part of data | ||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | * @param index [IN] index of part(op) | ||||
| * @return op execution time (us) | * @return op execution time (us) | ||||
| */ | */ | ||||
| MSVP_PROF_API uint64_t ProfGetOpExecutionTime(const void *data, uint32_t len, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpCubeOps | |||||
| * @brief get op cube fops of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | |||||
| * @return op cube fops | |||||
| */ | |||||
| MSVP_PROF_API uint64_t ProfGetOpCubeOps(const void *data, uint32_t len, uint32_t index); | |||||
| /** | |||||
| * @name ProfGetOpVectorOps | |||||
| * @brief get op vector fops of specific part of data | |||||
| * @param data [IN] data read from pipe | |||||
| * @param len [IN] data length | |||||
| * @param index [IN] index of part(op) | |||||
| * @return op vector fops | |||||
| */ | |||||
| MSVP_PROF_API uint64_t ProfGetOpVectorOps(const void *data, uint32_t len, uint32_t index); | |||||
| } // namespace Api | |||||
| } // namespace Msprofiler | |||||
| uint64_t ProfGetOpExecutionTime(const void *data, uint32_t len, uint32_t index); | |||||
| } | |||||
| } | |||||
| #endif // MSPROFILER_API_PROF_ACL_API_H_ | #endif // MSPROFILER_API_PROF_ACL_API_H_ | ||||
| @@ -0,0 +1,132 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef MSPROFILER_PROF_CALLBACK_H_ | |||||
| #define MSPROFILER_PROF_CALLBACK_H_ | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif // __cplusplus | |||||
| #include "stddef.h" | |||||
| #include "stdint.h" | |||||
| /** | |||||
| * @name MsprofErrorCode | |||||
| * @brief error code | |||||
| */ | |||||
| enum MsprofErrorCode { | |||||
| MSPROF_ERROR_NONE = 0, | |||||
| MSPROF_ERROR_MEM_NOT_ENOUGH, | |||||
| MSPROF_ERROR_GET_ENV, | |||||
| MSPROF_ERROR_CONFIG_INVALID, | |||||
| MSPROF_ERROR_ACL_JSON_OFF, | |||||
| MSPROF_ERROR, | |||||
| }; | |||||
| #define MSPROF_ENGINE_MAX_TAG_LEN (31) | |||||
| /** | |||||
| * @name ReporterData | |||||
| * @brief struct of data to report | |||||
| */ | |||||
| struct ReporterData { | |||||
| char tag[MSPROF_ENGINE_MAX_TAG_LEN + 1]; // the sub-type of the module, data with different tag will be writen | |||||
| int deviceId; // the index of device | |||||
| size_t dataLen; // the length of send data | |||||
| unsigned char *data; // the data content | |||||
| }; | |||||
| /** | |||||
| * @name MsprofReporterModuleId | |||||
| * @brief module id of data to report | |||||
| */ | |||||
| enum MsprofReporterModuleId { | |||||
| MSPROF_MODULE_DATA_PREPROCESS = 0, // DATA_PREPROCESS | |||||
| MSPROF_MODULE_HCCL, // HCCL | |||||
| MSPROF_MODULE_ACL, // AclModule | |||||
| MSPROF_MODULE_FRAMEWORK, // Framework | |||||
| MSPROF_MODULE_RUNTIME // runtime | |||||
| }; | |||||
| /** | |||||
| * @name MsprofReporterCallbackType | |||||
| * @brief reporter callback request type | |||||
| */ | |||||
| enum MsprofReporterCallbackType { | |||||
| MSPROF_REPORTER_REPORT = 0, // report data | |||||
| MSPROF_REPORTER_INIT, // init reporter | |||||
| MSPROF_REPORTER_UNINIT, // uninit reporter | |||||
| }; | |||||
| /** | |||||
| * @name MsprofReporterCallback | |||||
| * @brief callback to start reporter/stop reporter/report date | |||||
| * @param moduleId [IN] enum MsprofReporterModuleId | |||||
| * @param type [IN] enum MsprofReporterCallbackType | |||||
| * @param data [IN] callback data (nullptr on INTI/UNINIT) | |||||
| * @param len [IN] callback data size (0 on INIT/UNINIT) | |||||
| * @return enum MsprofErrorCode | |||||
| */ | |||||
| typedef int32_t (*MsprofReporterCallback)(uint32_t moduleId, uint32_t type, void *data, uint32_t len); | |||||
| #define MSPROF_OPTIONS_DEF_LEN_MAX (2048) | |||||
| /** | |||||
| * @name MsprofGeOptions | |||||
| * @brief struct of MSPROF_CTRL_INIT_GE_OPTIONS | |||||
| */ | |||||
| struct MsprofGeOptions { | |||||
| char jobId[MSPROF_OPTIONS_DEF_LEN_MAX]; | |||||
| char options[MSPROF_OPTIONS_DEF_LEN_MAX]; | |||||
| }; | |||||
| /** | |||||
| * @name MsprofCtrlCallbackType | |||||
| * @brief ctrl callback request type | |||||
| */ | |||||
| enum MsprofCtrlCallbackType { | |||||
| MSPROF_CTRL_INIT_ACL_ENV = 0, // start profiling with acl env | |||||
| MSPROF_CTRL_INIT_ACL_JSON, // start profiling with acl.json | |||||
| MSPROF_CTRL_INIT_GE_OPTIONS, // start profiling with ge env and options | |||||
| MSPROF_CTRL_FINALIZE // stop profiling | |||||
| }; | |||||
| /** | |||||
| * @name MsprofCtrlCallback | |||||
| * @brief callback to start/stop profiling | |||||
| * @param type [IN] enum MsprofCtrlCallbackType | |||||
| * @param data [IN] callback data | |||||
| * @param len [IN] callback data size | |||||
| * @return enum MsprofErrorCode | |||||
| */ | |||||
| typedef int32_t (*MsprofCtrlCallback)(uint32_t type, void *data, uint32_t len); | |||||
| /** | |||||
| * @name MsprofSetDeviceCallback | |||||
| * @brief callback to notify set/reset device | |||||
| * @param devId [IN] device id | |||||
| * @param isOpenDevice [IN] true: set device, false: reset device | |||||
| */ | |||||
| typedef void (*MsprofSetDeviceCallback)(uint32_t devId, bool isOpenDevice); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif // MSPROFILER_PROF_CALLBACK_H_ | |||||
| @@ -26,6 +26,8 @@ | |||||
| #define MSVP_PROF_API __attribute__((visibility("default"))) | #define MSVP_PROF_API __attribute__((visibility("default"))) | ||||
| #endif | #endif | ||||
| #include "prof_callback.h" | |||||
| /** | /** | ||||
| * @file prof_reporter.h | * @file prof_reporter.h | ||||
| * @defgroup reporter the reporter group | * @defgroup reporter the reporter group | ||||
| @@ -33,20 +35,6 @@ | |||||
| */ | */ | ||||
| namespace Msprof { | namespace Msprof { | ||||
| namespace Engine { | namespace Engine { | ||||
| /// the max tag length | |||||
| #define MSPROF_ENGINE_MAX_TAG_LEN (31) | |||||
| /** | |||||
| * @ingroup reporter | |||||
| * @brief struct ReporterData | |||||
| * the sturct of the data send to libmsprof | |||||
| */ | |||||
| struct ReporterData { | |||||
| char tag[MSPROF_ENGINE_MAX_TAG_LEN + 1]; ///< the sub-type of the module, data with different tag will be writen | |||||
| int deviceId; ///< the physical id of device | |||||
| size_t dataLen; ///< the length of send data | |||||
| unsigned char *data; ///< the data content | |||||
| }; | |||||
| /** | /** | ||||
| * @ingroup reporter | * @ingroup reporter | ||||
| * @brief class Reporter | * @brief class Reporter | ||||