/home/runner/work/HiCR/HiCR/include/hicr/backends/ascend/memoryKernel.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/ascend/memoryKernel.hpp Source File
HiCR
memoryKernel.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 Huawei Technologies Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
24#pragma once
25
26#include <acl/acl.h>
31
32namespace HiCR::backend::ascend
33{
39class MemoryKernel final : public Kernel
40{
41 public:
42
54 std::shared_ptr<HiCR::LocalMemorySlot> destination,
55 const size_t destinationOffset,
56 std::shared_ptr<HiCR::LocalMemorySlot> source,
57 const size_t sourceOffset,
58 size_t size)
59 : ascend::Kernel(),
60 _dst(destination),
61 _src(source),
62 _dstOffset(destinationOffset),
63 _srcOffset(sourceOffset),
64 _size(size),
65 _commManager(commManager){};
66
67 MemoryKernel() = delete;
68
73
79 __INLINE__ void start(const aclrtStream stream) override { _commManager->memcpyAsync(_dst, _dstOffset, _src, _srcOffset, _size, stream); }
80
81 private:
82
86 const std::shared_ptr<HiCR::LocalMemorySlot> _dst;
90 const std::shared_ptr<HiCR::LocalMemorySlot> _src;
91
95 const size_t _dstOffset;
96
100 const size_t _srcOffset;
104 const size_t _size;
105
109 ascend::CommunicationManager *const _commManager;
110};
111} // namespace HiCR::backend::ascend
This file implements the Kernel class for the Ascend backend.
This file implements the communication manager class for the Ascend backend.
Definition communicationManager.hpp:49
__INLINE__ void memcpyAsync(const std::shared_ptr< HiCR::LocalMemorySlot > &destination, const size_t dst_offset, const std::shared_ptr< HiCR::LocalMemorySlot > &source, const size_t src_offset, const size_t size, const aclrtStream stream)
Definition communicationManager.hpp:92
Definition kernel.hpp:36
Definition memoryKernel.hpp:40
__INLINE__ void start(const aclrtStream stream) override
Definition memoryKernel.hpp:79
MemoryKernel(ascend::CommunicationManager *commManager, std::shared_ptr< HiCR::LocalMemorySlot > destination, const size_t destinationOffset, std::shared_ptr< HiCR::LocalMemorySlot > source, const size_t sourceOffset, size_t size)
Definition memoryKernel.hpp:53
~MemoryKernel()
Definition memoryKernel.hpp:72
Provides a definition for a HiCR Local Memory Slot class.
Provides a failure model and corresponding exception classes.