Skip to content

Commit c8532cc

Browse files
committed
restore memmove-function.cpp
1 parent ad03beb commit c8532cc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===-- lib/flang_rt/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 "../terminator.h"
11+
#include "flang/Runtime/CUDA/common.h"
12+
13+
#include "cuda_runtime.h"
14+
15+
namespace Fortran::runtime::cuda {
16+
17+
void *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+
23+
void *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+
29+
void *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

0 commit comments

Comments
 (0)