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 % 48 48
Test Date: 2026-08-06 15:29:52 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)
      19              : {
      20            3 :     return ::aclrtSynchronizeDeviceWithTimeout(timeout);
      21              : }
      22              : 
      23            1 : static inline aclError aclrtSynchronizeStream(aclrtStream stream, int32_t timeout)
      24              : {
      25            1 :     return ::aclrtSynchronizeStreamWithTimeout(stream, timeout);
      26              : }
      27              : 
      28            1 : static inline aclError aclrtSynchronizeEvent(aclrtEvent event, int32_t timeout)
      29              : {
      30            1 :     return ::aclrtSynchronizeEventWithTimeout(event, timeout);
      31              : }
      32              : 
      33            1 : static inline aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event, int32_t timeout)
      34              : {
      35            1 :     return ::aclrtStreamWaitEventWithTimeout(stream, event, timeout);
      36              : }
      37              : 
      38              : static inline aclError aclrtCreateStream(aclrtStream *stream, uint32_t priority, uint32_t flag)
      39              : {
      40              :     return ::aclrtCreateStreamWithConfig(stream, priority, flag);
      41              : }
      42              : 
      43              : static inline aclError aclrtSetOpExecuteTimeOut(uint64_t timeout, uint64_t *actualTimeout)
      44              : {
      45              :     return ::aclrtSetOpExecuteTimeOutV2(timeout, actualTimeout);
      46              : }
      47              : 
      48            1 : static inline aclError aclrtCreateEvent(aclrtEvent *event, uint32_t flag)
      49              : {
      50            1 :     return ::aclrtCreateEventExWithFlag(event, flag);
      51              : }
      52              : 
      53              : template <typename T>
      54            2 : static inline aclError aclrtMalloc(T **devPtr, size_t size, aclrtMallocConfig *cfg = nullptr)
      55              : {
      56            2 :     return ::aclrtMallocWithCfg(reinterpret_cast<void **>(devPtr), size, ACL_MEM_MALLOC_HUGE_FIRST, cfg);
      57              : }
      58              : 
      59              : template <typename T>
      60            1 : static inline aclError aclrtMalloc(T **devPtr, size_t size, aclrtMemMallocPolicy policy, aclrtMallocConfig *cfg = nullptr)
      61              : {
      62            1 :     return ::aclrtMallocWithCfg(reinterpret_cast<void **>(devPtr), size, policy, cfg);
      63              : }
      64              : 
      65              : template <typename T>
      66            1 : static inline aclError aclrtMallocHost(T **hostPtr, size_t size, aclrtMallocConfig *cfg = nullptr)
      67              : {
      68            1 :     return ::aclrtMallocHostWithCfg(reinterpret_cast<void **>(hostPtr), static_cast<uint64_t>(size), cfg);
      69              : }
      70              : 
      71              : template <typename T, typename U>
      72            9 : static inline aclError aclrtMemcpy(T *dst, size_t destMax, const U *src, size_t count, aclrtMemcpyKind kind)
      73              : {
      74            9 :     return ::aclrtMemcpy(static_cast<void *>(dst), destMax, static_cast<const void *>(src), count, kind);
      75              : }
      76              : 
      77              : template <typename T, typename U>
      78            1 : static inline aclError aclrtMemcpyAsync(T *dst, size_t destMax, const U *src, size_t count,
      79              :                                         aclrtMemcpyKind kind, aclrtStream stream)
      80              : {
      81            1 :     return ::aclrtMemcpyAsync(static_cast<void *>(dst), destMax, static_cast<const void *>(src), count, kind, stream);
      82              : }
      83              : 
      84              : template <typename T, typename U>
      85            1 : static inline aclError aclrtMemcpy2d(T *dst, size_t dpitch, const U *src, size_t spitch,
      86              :                                      size_t width, size_t height, aclrtMemcpyKind kind)
      87              : {
      88            1 :     return ::aclrtMemcpy2d(static_cast<void *>(dst), dpitch, static_cast<const void *>(src),
      89            1 :                            spitch, width, height, kind);
      90              : }
      91              : 
      92              : template <typename T, typename U>
      93            1 : static inline aclError aclrtMemcpy2dAsync(T *dst, size_t dpitch, const U *src, size_t spitch,
      94              :                                           size_t width, size_t height, aclrtMemcpyKind kind, aclrtStream stream)
      95              : {
      96            1 :     return ::aclrtMemcpy2dAsync(static_cast<void *>(dst), dpitch, static_cast<const void *>(src),
      97            1 :                                 spitch, width, height, kind, stream);
      98              : }
      99              : 
     100              : template <typename T, typename U>
     101              : static inline aclError aclrtMemcpyBatch(T **dsts, size_t *destMaxs, U **srcs, size_t *sizes,
     102              :                                         size_t numBatches, aclrtMemcpyBatchAttr attr, size_t *failIndex = nullptr)
     103              : {
     104              :     (void)failIndex;
     105              :     aclrtMemcpyBatchAttr attrs[1] = {attr};
     106              :     size_t attrsIndexes[1] = {0};
     107              :     return ::aclrtMemcpyBatchV2(reinterpret_cast<void **>(dsts), destMaxs, reinterpret_cast<void **>(srcs),
     108              :                                 sizes, numBatches, attrs, attrsIndexes, 1);
     109              : }
     110              : 
     111              : template <typename T, typename U>
     112              : static inline aclError aclrtMemcpyBatch(T **dsts, size_t *destMaxs, U **srcs, size_t *sizes,
     113              :                                         size_t numBatches, aclrtMemcpyBatchAttr *attrs,
     114              :                                         size_t *attrsIndexes, size_t numAttrs, size_t *failIndex = nullptr)
     115              : {
     116              :     (void)failIndex;
     117              :     return ::aclrtMemcpyBatchV2(reinterpret_cast<void **>(dsts), destMaxs, reinterpret_cast<void **>(srcs),
     118              :                                 sizes, numBatches, attrs, attrsIndexes, numAttrs);
     119              : }
     120              : 
     121              : template <typename T, typename U>
     122              : static inline aclError aclrtMemcpyBatchAsync(T **dsts, size_t *destMaxs, U **srcs, size_t *sizes,
     123              :                                              size_t numBatches, aclrtMemcpyBatchAttr attr, aclrtStream stream)
     124              : {
     125              :     aclrtMemcpyBatchAttr attrs[1] = {attr};
     126              :     size_t attrsIndexes[1] = {0};
     127              :     return ::aclrtMemcpyBatchAsyncV2(reinterpret_cast<void **>(dsts), destMaxs, reinterpret_cast<void **>(srcs),
     128              :                                      sizes, numBatches, attrs, attrsIndexes, 1, stream);
     129              : }
     130              : 
     131              : template <typename T, typename U>
     132              : static inline aclError aclrtMemcpyBatchAsync(T **dsts, size_t *destMaxs, U **srcs, size_t *sizes,
     133              :                                              size_t numBatches, aclrtMemcpyBatchAttr *attrs,
     134              :                                              size_t *attrsIndexes, size_t numAttrs, aclrtStream stream)
     135              : {
     136              :     return ::aclrtMemcpyBatchAsyncV2(reinterpret_cast<void **>(dsts), destMaxs, reinterpret_cast<void **>(srcs),
     137              :                                      sizes, numBatches, attrs, attrsIndexes, numAttrs, stream);
     138              : }
     139              : 
     140              : template <typename T, typename U>
     141              : static inline aclError aclrtMemcpyBatchAsync(T **dsts, size_t *destMaxs, U **srcs, size_t *sizes,
     142              :                                              size_t numBatches, aclrtMemcpyBatchAttr attr,
     143              :                                              size_t *failIndex, aclrtStream stream)
     144              : {
     145              :     aclrtMemcpyBatchAttr attrs[1] = {attr};
     146              :     size_t attrsIndexes[1] = {0};
     147              :     return ::aclrtMemcpyBatchAsync(reinterpret_cast<void **>(dsts), destMaxs, reinterpret_cast<void **>(srcs),
     148              :                                    sizes, numBatches, attrs, attrsIndexes, 1, failIndex, stream);
     149              : }
     150              : 
     151              : template <typename T, typename U>
     152              : static inline aclError aclrtMemcpyBatchAsync(T **dsts, size_t *destMaxs, U **srcs, size_t *sizes,
     153              :                                              size_t numBatches, aclrtMemcpyBatchAttr *attrs,
     154              :                                              size_t *attrsIndexes, size_t numAttrs, size_t *failIndex, aclrtStream stream)
     155              : {
     156              :     return ::aclrtMemcpyBatchAsync(reinterpret_cast<void **>(dsts), destMaxs, reinterpret_cast<void **>(srcs),
     157              :                                    sizes, numBatches, attrs, attrsIndexes, numAttrs, failIndex, stream);
     158              : }
     159              : 
     160              : template <typename T>
     161            1 : static inline aclError aclrtPointerGetAttributes(const T *ptr, aclrtPtrAttributes *attributes)
     162              : {
     163            1 :     return ::aclrtPointerGetAttributes(static_cast<const void *>(ptr), attributes);
     164              : }
     165              : 
     166              : template <typename T>
     167            1 : static inline aclError aclrtHostRegister(T *ptr, uint64_t size, aclrtHostRegisterType type, T **devPtr)
     168              : {
     169            1 :     return ::aclrtHostRegister(static_cast<void *>(ptr), size, type, reinterpret_cast<void **>(devPtr));
     170              : }
     171              : 
     172              : template <typename T>
     173            1 : static inline aclError aclrtHostRegister(T *ptr, uint64_t size, uint32_t flag)
     174              : {
     175            1 :     return ::aclrtHostRegisterV2(static_cast<void *>(ptr), size, flag);
     176              : }
     177              : 
     178              : template <typename T>
     179            1 : static inline aclError aclrtHostGetDevicePointer(T *pHost, T **pDevice, uint32_t flag)
     180              : {
     181            1 :     return ::aclrtHostGetDevicePointer(static_cast<void *>(pHost), reinterpret_cast<void **>(pDevice), flag);
     182              : }
     183              : 
     184              : template <typename T>
     185            1 : static inline aclError aclrtHostUnregister(T *ptr)
     186              : {
     187            1 :     return ::aclrtHostUnregister(static_cast<void *>(ptr));
     188              : }
     189              : 
     190              : template <typename T>
     191            2 : static inline aclError aclrtMemAllocManaged(T **devPtr, size_t size, uint32_t flags = ACL_RT_MEM_ATTACH_GLOBAL)
     192              : {
     193            2 :     return ::aclrtMemAllocManaged(reinterpret_cast<void **>(devPtr), static_cast<uint64_t>(size), flags);
     194              : }
     195              : 
     196              : template <typename T>
     197              : static inline aclError aclrtMemManagedPrefetchAsync(const T *ptr, size_t size,
     198              :                                                     aclrtMemManagedLocation location, uint32_t flags, aclrtStream stream)
     199              : {
     200              :     return ::aclrtMemManagedPrefetchAsync(static_cast<const void *>(ptr), size, location, flags, stream);
     201              : }
     202              : 
     203              : template <typename T>
     204              : static inline aclError aclrtMemManagedPrefetchBatchAsync(const T **ptrs, size_t *sizes, size_t count,
     205              :                                                          aclrtMemManagedLocation prefetchLoc,
     206              :                                                          uint64_t flags, aclrtStream stream)
     207              : {
     208              :     aclrtMemManagedLocation prefetchLocs[1] = {prefetchLoc};
     209              :     size_t prefetchLocIdxs[1] = {0};
     210              :     return ::aclrtMemManagedPrefetchBatchAsync(reinterpret_cast<const void **>(ptrs), sizes, count,
     211              :                                                 prefetchLocs, prefetchLocIdxs, 1, flags, stream);
     212              : }
     213              : 
     214              : template <typename T>
     215              : static inline aclError aclrtMemManagedPrefetchBatchAsync(const T **ptrs, size_t *sizes, size_t count,
     216              :                                                          aclrtMemManagedLocation *prefetchLocs,
     217              :                                                          size_t *prefetchLocIdxs, size_t numPrefetchLocs,
     218              :                                                          uint64_t flags, aclrtStream stream)
     219              : {
     220              :     return ::aclrtMemManagedPrefetchBatchAsync(reinterpret_cast<const void **>(ptrs), sizes, count,
     221              :                                                 prefetchLocs, prefetchLocIdxs, numPrefetchLocs, flags, stream);
     222              : }
     223              : 
     224              : template <typename T>
     225            3 : static inline aclError aclrtGetSymbolAddress(const T &symbol, void **devPtr)
     226              : {
     227            3 :     return ::aclrtGetSymbolAddress(static_cast<const void*>(&symbol), devPtr);
     228              : }
     229              : 
     230              : template <typename T>
     231              : static inline aclError aclrtGetSymbolSize(const T &symbol, size_t *size)
     232              : {
     233              :     return ::aclrtGetSymbolSize(static_cast<const void*>(&symbol), size);
     234              : }
     235              : 
     236              : template <typename T>
     237           10 : static inline aclError aclrtMemcpyFromSymbol(void *dst, size_t dstMax, const T &symbol,
     238              :                                             size_t count, size_t offset, aclrtMemcpyKind kind)
     239              : {
     240           10 :     return ::aclrtMemcpyFromSymbol(dst, dstMax, static_cast<const void*>(&symbol), count, offset, kind);
     241              : }
     242              : 
     243              : template <typename T>
     244           11 : static inline aclError aclrtMemcpyFromSymbolAsync(void *dst, size_t dstMax, const T &symbol,
     245              :                                                  size_t count, size_t offset, aclrtMemcpyKind kind,
     246              :                                                  aclrtStream stream)
     247              : {
     248           11 :     return ::aclrtMemcpyFromSymbolAsync(dst, dstMax, static_cast<const void*>(&symbol), count, offset, kind, stream);
     249              : }
     250              : 
     251              : template <typename T>
     252            9 : static inline aclError aclrtMemcpyToSymbol(const T &symbol, const void *src,
     253              :                                           size_t count, size_t offset, aclrtMemcpyKind kind)
     254              : {
     255            9 :     return ::aclrtMemcpyToSymbol(static_cast<const void*>(&symbol), src, count, offset, kind);
     256              : }
     257              : 
     258              : template <typename T>
     259           10 : static inline aclError aclrtMemcpyToSymbolAsync(const T &symbol, const void *src,
     260              :                                                size_t count, size_t offset, aclrtMemcpyKind kind,
     261              :                                                aclrtStream stream)
     262              : {
     263           10 :     return ::aclrtMemcpyToSymbolAsync(static_cast<const void*>(&symbol), src, count, offset, kind, stream);
     264              : }
     265              : 
     266              : #endif // __cplusplus
     267              : 
     268              : #endif // INC_EXTERNAL_ACL_ACL_RT_API_H_
        

Generated by: LCOV version 2.0-1