memcpy.h 2.1 KB
Newer Older
1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

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. */

#pragma once

17
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
Y
Yi Wang 已提交
18
#include "paddle/fluid/platform/place.h"
F
fwenguang 已提交
19 20 21
#ifdef PADDLE_WITH_MLU
#include "paddle/fluid/platform/device/mlu/device_context.h"
#endif
22 23 24 25

namespace paddle {
namespace memory {

26 27 28 29 30 31 32 33 34 35
/**
 * \brief   Copy memory from one place to another place.
 *
 * \param[in]  DstPlace Destination allocation place (CPU).
 * \param[in]  dst      Destination memory address.
 * \param[in]  SrcPlace Source allocation place (CPU).
 * \param[in]  src      Source memory address.
 * \param[in]  num      memory size in bytes to copy.
 *
 */
36 37 38
template <typename DstPlace, typename SrcPlace>
void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num);

F
fwenguang 已提交
39 40 41
/**
 * \brief   Copy memory from one place to another place.
 *
42 43
 * \param[in]  DstPlace Destination allocation place (CPU or GPU or XPU or
 * CustomDevice).
F
fwenguang 已提交
44
 * \param[in]  dst      Destination memory address.
45 46
 * \param[in]  SrcPlace Source allocation place (CPU or GPU or XPU or
 * CustomDevice).
F
fwenguang 已提交
47 48
 * \param[in]  src      Source memory address.
 * \param[in]  num      memory size in bytes to copy.
49
 * \param[in]  stream   stream for asynchronously memory copy.
F
fwenguang 已提交
50
 *
51 52 53
 * \note    For GPU/XPU/CustomDevice memory copy, stream need to be specified
 *          for asynchronously memory copy, and type is restored in the
 *          implementation.
F
fwenguang 已提交
54 55 56 57
 *
 */
template <typename DstPlace, typename SrcPlace>
void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num,
58
          void* stream);
59 60
}  // namespace memory
}  // namespace paddle