1//===-- lib/cuda/memmove-function.cpp ---------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "flang/Runtime/CUDA/memmove-function.h"
10#include "flang-rt/runtime/terminator.h"
11#include "flang/Runtime/CUDA/common.h"
12
13#include "cuda_runtime.h"
14
15namespace Fortran::runtime::cuda {
16
17void *MemmoveHostToDevice(void *dst, const void *src, std::size_t count) {
18 // TODO: Use cudaMemcpyAsync when we have support for stream.
19 CUDA_REPORT_IF_ERROR(cudaMemcpy(dst, src, count, cudaMemcpyHostToDevice));
20 return dst;
21}
22
23void *MemmoveDeviceToHost(void *dst, const void *src, std::size_t count) {
24 // TODO: Use cudaMemcpyAsync when we have support for stream.
25 CUDA_REPORT_IF_ERROR(cudaMemcpy(dst, src, count, cudaMemcpyDeviceToHost));
26 return dst;
27}
28
29void *MemmoveDeviceToDevice(void *dst, const void *src, std::size_t count) {
30 // TODO: Use cudaMemcpyAsync when we have support for stream.
31 CUDA_REPORT_IF_ERROR(cudaMemcpy(dst, src, count, cudaMemcpyDeviceToDevice));
32 return dst;
33}
34
35} // namespace Fortran::runtime::cuda
36

source code of flang-rt/lib/cuda/memmove-function.cpp