aboutsummaryrefslogtreecommitdiff
path: root/flang-rt/lib/cuda/memmove-function.cpp
blob: a7eb0cf1a3e7adf2739107092ca9744e602de797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//===-- lib/cuda/memmove-function.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "flang/Runtime/CUDA/memmove-function.h"
#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"

#include "cuda_runtime.h"

namespace Fortran::runtime::cuda {

void *MemmoveHostToDevice(void *dst, const void *src, std::size_t count) {
  // TODO: Use cudaMemcpyAsync when we have support for stream.
  CUDA_REPORT_IF_ERROR(cudaMemcpy(dst, src, count, cudaMemcpyHostToDevice));
  return dst;
}

void *MemmoveDeviceToHost(void *dst, const void *src, std::size_t count) {
  // TODO: Use cudaMemcpyAsync when we have support for stream.
  CUDA_REPORT_IF_ERROR(cudaMemcpy(dst, src, count, cudaMemcpyDeviceToHost));
  return dst;
}

void *MemmoveDeviceToDevice(void *dst, const void *src, std::size_t count) {
  // TODO: Use cudaMemcpyAsync when we have support for stream.
  CUDA_REPORT_IF_ERROR(cudaMemcpy(dst, src, count, cudaMemcpyDeviceToDevice));
  return dst;
}

} // namespace Fortran::runtime::cuda