LCOV - code coverage report
Current view: top level - /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/ut/include/external/acl - acl_rt_api.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 46 46
Test Date: 2026-07-28 10:53:01 Functions: 100.0 % 24 24

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #ifndef INC_EXTERNAL_ACL_ACL_RT_API_H_
      12              : #define INC_EXTERNAL_ACL_ACL_RT_API_H_
      13              : 
      14              : #include "acl_rt.h"
      15              : 
      16              : #ifdef __cplusplus
      17              : 
      18            3 : static inline aclError aclrtSynchronizeDevice(int32_t timeout) { return ::aclrtSynchronizeDeviceWithTimeout(timeout); }
      19              : 
      20            1 : static inline aclError aclrtSynchronizeStream(aclrtStream stream, int32_t timeout)
      21              : {
      22            1 :     return ::aclrtSynchronizeStreamWithTimeout(stream, timeout);
      23              : }
      24              : 
      25            1 : static inline aclError aclrtSynchronizeEvent(aclrtEvent event, int32_t timeout)
      26              : {
      27            1 :     return ::aclrtSynchronizeEventWithTimeout(event, timeout);
      28              : }
      29              : 
      30            1 : static inline aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event, int32_t timeout)
      31              : {
      32            1 :     return ::aclrtStreamWaitEventWithTimeout(stream, event, timeout);
      33              : }
      34              : 
      35              : static inline aclError aclrtCreateStream(aclrtStream* stream, uint32_t priority, uint32_t flag)
      36              : {
      37              :     return ::aclrtCreateStreamWithConfig(stream, priority, flag);
      38              : }
      39              : 
      40              : static inline aclError aclrtSetOpExecuteTimeOut(uint64_t timeout, uint64_t* actualTimeout)
      41              : {
      42              :     return ::aclrtSetOpExecuteTimeOutV2(timeout, actualTimeout);
      43              : }
      44              : 
      45            1 : static inline aclError aclrtCreateEvent(aclrtEvent* event, uint32_t flag)
      46              : {
      47            1 :     return ::aclrtCreateEventExWithFlag(event, flag);
      48              : }
      49              : 
      50              : template <typename T>
      51            2 : static inline aclError aclrtMalloc(T** devPtr, size_t size, aclrtMallocConfig* cfg = nullptr)
      52              : {
      53            2 :     return ::aclrtMallocWithCfg(reinterpret_cast<void**>(devPtr), size, ACL_MEM_MALLOC_HUGE_FIRST, cfg);
      54              : }
      55              : 
      56              : template <typename T>
      57            1 : static inline aclError aclrtMalloc(
      58              :     T** devPtr, size_t size, aclrtMemMallocPolicy policy, aclrtMallocConfig* cfg = nullptr)
      59              : {
      60            1 :     return ::aclrtMallocWithCfg(reinterpret_cast<void**>(devPtr), size, policy, cfg);
      61              : }
      62              : 
      63              : template <typename T>
      64            1 : static inline aclError aclrtMallocHost(T** hostPtr, size_t size, aclrtMallocConfig* cfg = nullptr)
      65              : {
      66            1 :     return ::aclrtMallocHostWithCfg(reinterpret_cast<void**>(hostPtr), static_cast<uint64_t>(size), cfg);
      67              : }
      68              : 
      69              : template <typename T, typename U>
      70            9 : static inline aclError aclrtMemcpy(T* dst, size_t destMax, const U* src, size_t count, aclrtMemcpyKind kind)
      71              : {
      72            9 :     return ::aclrtMemcpy(static_cast<void*>(dst), destMax, static_cast<const void*>(src), count, kind);
      73              : }
      74              : 
      75              : template <typename T, typename U>
      76            1 : static inline aclError aclrtMemcpyAsync(
      77              :     T* dst, size_t destMax, const U* src, size_t count, aclrtMemcpyKind kind, aclrtStream stream)
      78              : {
      79            1 :     return ::aclrtMemcpyAsync(static_cast<void*>(dst), destMax, static_cast<const void*>(src), count, kind, stream);
      80              : }
      81              : 
      82              : template <typename T, typename U>
      83            1 : static inline aclError aclrtMemcpy2d(
      84              :     T* dst, size_t dpitch, const U* src, size_t spitch, size_t width, size_t height, aclrtMemcpyKind kind)
      85              : {
      86            1 :     return ::aclrtMemcpy2d(static_cast<void*>(dst), dpitch, static_cast<const void*>(src), spitch, width, height, kind);
      87              : }
      88              : 
      89              : template <typename T, typename U>
      90            1 : static inline aclError aclrtMemcpy2dAsync(
      91              :     T* dst, size_t dpitch, const U* src, size_t spitch, size_t width, size_t height, aclrtMemcpyKind kind,
      92              :     aclrtStream stream)
      93              : {
      94            1 :     return ::aclrtMemcpy2dAsync(
      95            1 :         static_cast<void*>(dst), dpitch, static_cast<const void*>(src), spitch, width, height, kind, stream);
      96              : }
      97              : 
      98              : template <typename T, typename U>
      99              : static inline aclError aclrtMemcpyBatch(
     100              :     T** dsts, size_t* destMaxs, U** srcs, size_t* sizes, size_t numBatches, aclrtMemcpyBatchAttr attr,
     101              :     size_t* failIndex = nullptr)
     102              : {
     103              :     (void)failIndex;
     104              :     aclrtMemcpyBatchAttr attrs[1] = {attr};
     105              :     size_t attrsIndexes[1] = {0};
     106              :     return ::aclrtMemcpyBatchV2(
     107              :         reinterpret_cast<void**>(dsts), destMaxs, reinterpret_cast<void**>(srcs), sizes, numBatches, attrs,
     108              :         attrsIndexes, 1);
     109              : }
     110              : 
     111              : template <typename T, typename U>
     112              : static inline aclError aclrtMemcpyBatch(
     113              :     T** dsts, size_t* destMaxs, U** srcs, size_t* sizes, size_t numBatches, aclrtMemcpyBatchAttr* attrs,
     114              :     size_t* attrsIndexes, size_t numAttrs, size_t* failIndex = nullptr)
     115              : {
     116              :     (void)failIndex;
     117              :     return ::aclrtMemcpyBatchV2(
     118              :         reinterpret_cast<void**>(dsts), destMaxs, reinterpret_cast<void**>(srcs), sizes, numBatches, attrs,
     119              :         attrsIndexes, numAttrs);
     120              : }
     121              : 
     122              : template <typename T, typename U>
     123              : static inline aclError aclrtMemcpyBatchAsync(
     124              :     T** dsts, size_t* destMaxs, U** srcs, size_t* sizes, size_t numBatches, aclrtMemcpyBatchAttr attr,
     125              :     aclrtStream stream)
     126              : {
     127              :     aclrtMemcpyBatchAttr attrs[1] = {attr};
     128              :     size_t attrsIndexes[1] = {0};
     129              :     return ::aclrtMemcpyBatchAsyncV2(
     130              :         reinterpret_cast<void**>(dsts), destMaxs, reinterpret_cast<void**>(srcs), sizes, numBatches, attrs,
     131              :         attrsIndexes, 1, stream);
     132              : }
     133              : 
     134              : template <typename T, typename U>
     135              : static inline aclError aclrtMemcpyBatchAsync(
     136              :     T** dsts, size_t* destMaxs, U** srcs, size_t* sizes, size_t numBatches, aclrtMemcpyBatchAttr* attrs,
     137              :     size_t* attrsIndexes, size_t numAttrs, aclrtStream stream)
     138              : {
     139              :     return ::aclrtMemcpyBatchAsyncV2(
     140              :         reinterpret_cast<void**>(dsts), destMaxs, reinterpret_cast<void**>(srcs), sizes, numBatches, attrs,
     141              :         attrsIndexes, numAttrs, stream);
     142              : }
     143              : 
     144              : template <typename T, typename U>
     145              : static inline aclError aclrtMemcpyBatchAsync(
     146              :     T** dsts, size_t* destMaxs, U** srcs, size_t* sizes, size_t numBatches, aclrtMemcpyBatchAttr attr,
     147              :     size_t* failIndex, aclrtStream stream)
     148              : {
     149              :     aclrtMemcpyBatchAttr attrs[1] = {attr};
     150              :     size_t attrsIndexes[1] = {0};
     151              :     return ::aclrtMemcpyBatchAsync(
     152              :         reinterpret_cast<void**>(dsts), destMaxs, reinterpret_cast<void**>(srcs), sizes, numBatches, attrs,
     153              :         attrsIndexes, 1, failIndex, stream);
     154              : }
     155              : 
     156              : template <typename T, typename U>
     157              : static inline aclError aclrtMemcpyBatchAsync(
     158              :     T** dsts, size_t* destMaxs, U** srcs, size_t* sizes, size_t numBatches, aclrtMemcpyBatchAttr* attrs,
     159              :     size_t* attrsIndexes, size_t numAttrs, size_t* failIndex, aclrtStream stream)
     160              : {
     161              :     return ::aclrtMemcpyBatchAsync(
     162              :         reinterpret_cast<void**>(dsts), destMaxs, reinterpret_cast<void**>(srcs), sizes, numBatches, attrs,
     163              :         attrsIndexes, numAttrs, failIndex, stream);
     164              : }
     165              : 
     166              : template <typename T>
     167            1 : static inline aclError aclrtPointerGetAttributes(const T* ptr, aclrtPtrAttributes* attributes)
     168              : {
     169            1 :     return ::aclrtPointerGetAttributes(static_cast<const void*>(ptr), attributes);
     170              : }
     171              : 
     172              : template <typename T>
     173            1 : static inline aclError aclrtHostRegister(T* ptr, uint64_t size, aclrtHostRegisterType type, T** devPtr)
     174              : {
     175            1 :     return ::aclrtHostRegister(static_cast<void*>(ptr), size, type, reinterpret_cast<void**>(devPtr));
     176              : }
     177              : 
     178              : template <typename T>
     179            1 : static inline aclError aclrtHostRegister(T* ptr, uint64_t size, uint32_t flag)
     180              : {
     181            1 :     return ::aclrtHostRegisterV2(static_cast<void*>(ptr), size, flag);
     182              : }
     183              : 
     184              : template <typename T>
     185            1 : static inline aclError aclrtHostGetDevicePointer(T* pHost, T** pDevice, uint32_t flag)
     186              : {
     187            1 :     return ::aclrtHostGetDevicePointer(static_cast<void*>(pHost), reinterpret_cast<void**>(pDevice), flag);
     188              : }
     189              : 
     190              : template <typename T>
     191            1 : static inline aclError aclrtHostUnregister(T* ptr)
     192              : {
     193            1 :     return ::aclrtHostUnregister(static_cast<void*>(ptr));
     194              : }
     195              : 
     196              : template <typename T>
     197            2 : static inline aclError aclrtMemAllocManaged(T** devPtr, size_t size, uint32_t flags = ACL_RT_MEM_ATTACH_GLOBAL)
     198              : {
     199            2 :     return ::aclrtMemAllocManaged(reinterpret_cast<void**>(devPtr), static_cast<uint64_t>(size), flags);
     200              : }
     201              : 
     202              : template <typename T>
     203              : static inline aclError aclrtMemManagedPrefetchAsync(
     204              :     const T* ptr, size_t size, aclrtMemManagedLocation location, uint32_t flags, aclrtStream stream)
     205              : {
     206              :     return ::aclrtMemManagedPrefetchAsync(static_cast<const void*>(ptr), size, location, flags, stream);
     207              : }
     208              : 
     209              : template <typename T>
     210              : static inline aclError aclrtMemManagedPrefetchBatchAsync(
     211              :     const T** ptrs, size_t* sizes, size_t count, aclrtMemManagedLocation prefetchLoc, uint64_t flags,
     212              :     aclrtStream stream)
     213              : {
     214              :     aclrtMemManagedLocation prefetchLocs[1] = {prefetchLoc};
     215              :     size_t prefetchLocIdxs[1] = {0};
     216              :     return ::aclrtMemManagedPrefetchBatchAsync(
     217              :         reinterpret_cast<const void**>(ptrs), sizes, count, prefetchLocs, prefetchLocIdxs, 1, flags, stream);
     218              : }
     219              : 
     220              : template <typename T>
     221              : static inline aclError aclrtMemManagedPrefetchBatchAsync(
     222              :     const T** ptrs, size_t* sizes, size_t count, aclrtMemManagedLocation* prefetchLocs, size_t* prefetchLocIdxs,
     223              :     size_t numPrefetchLocs, uint64_t flags, aclrtStream stream)
     224              : {
     225              :     return ::aclrtMemManagedPrefetchBatchAsync(
     226              :         reinterpret_cast<const void**>(ptrs), sizes, count, prefetchLocs, prefetchLocIdxs, numPrefetchLocs, flags,
     227              :         stream);
     228              : }
     229              : 
     230              : template <typename T>
     231            3 : static inline aclError aclrtGetSymbolAddress(const T& symbol, void** devPtr)
     232              : {
     233            3 :     return ::aclrtGetSymbolAddress(static_cast<const void*>(&symbol), devPtr);
     234              : }
     235              : 
     236              : template <typename T>
     237              : static inline aclError aclrtGetSymbolSize(const T& symbol, size_t* size)
     238              : {
     239              :     return ::aclrtGetSymbolSize(static_cast<const void*>(&symbol), size);
     240              : }
     241              : 
     242              : template <typename T>
     243           10 : static inline aclError aclrtMemcpyFromSymbol(
     244              :     void* dst, size_t dstMax, const T& symbol, size_t count, size_t offset, aclrtMemcpyKind kind)
     245              : {
     246           10 :     return ::aclrtMemcpyFromSymbol(dst, dstMax, static_cast<const void*>(&symbol), count, offset, kind);
     247              : }
     248              : 
     249              : template <typename T>
     250           11 : static inline aclError aclrtMemcpyFromSymbolAsync(
     251              :     void* dst, size_t dstMax, const T& symbol, size_t count, size_t offset, aclrtMemcpyKind kind, aclrtStream stream)
     252              : {
     253           11 :     return ::aclrtMemcpyFromSymbolAsync(dst, dstMax, static_cast<const void*>(&symbol), count, offset, kind, stream);
     254              : }
     255              : 
     256              : template <typename T>
     257            9 : static inline aclError aclrtMemcpyToSymbol(
     258              :     const T& symbol, const void* src, size_t count, size_t offset, aclrtMemcpyKind kind)
     259              : {
     260            9 :     return ::aclrtMemcpyToSymbol(static_cast<const void*>(&symbol), src, count, offset, kind);
     261              : }
     262              : 
     263              : template <typename T>
     264           10 : static inline aclError aclrtMemcpyToSymbolAsync(
     265              :     const T& symbol, const void* src, size_t count, size_t offset, aclrtMemcpyKind kind, aclrtStream stream)
     266              : {
     267           10 :     return ::aclrtMemcpyToSymbolAsync(static_cast<const void*>(&symbol), src, count, offset, kind, stream);
     268              : }
     269              : 
     270              : #endif // __cplusplus
     271              : 
     272              : #endif // INC_EXTERNAL_ACL_ACL_RT_API_H_
        

Generated by: LCOV version 2.0-1