|
| 1 | +//===-- include/flang/Runtime/CUDA/memory.h ---------------------*- 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 | +#ifndef FORTRAN_RUNTIME_CUDA_MEMORY_H_ |
| 10 | +#define FORTRAN_RUNTIME_CUDA_MEMORY_H_ |
| 11 | + |
| 12 | +#include "flang/Runtime/descriptor.h" |
| 13 | +#include "flang/Runtime/entry-names.h" |
| 14 | +#include <cstddef> |
| 15 | + |
| 16 | +static constexpr unsigned kHostToDevice = 0; |
| 17 | +static constexpr unsigned kDeviceToHost = 1; |
| 18 | +static constexpr unsigned kDeviceToDevice = 2; |
| 19 | + |
| 20 | +namespace Fortran::runtime::cuda { |
| 21 | + |
| 22 | +extern "C" { |
| 23 | + |
| 24 | +/// Set value to the data hold by a descriptor. The \p value pointer must be |
| 25 | +/// addressable to the same amount of bytes specified by the element size of |
| 26 | +/// the descriptor \p desc. |
| 27 | +void RTDECL(CUFMemsetDescriptor)(const Descriptor &desc, void *value, |
| 28 | + const char *sourceFile = nullptr, int sourceLine = 0); |
| 29 | + |
| 30 | +/// Data transfer from a pointer to a descriptor. |
| 31 | +void RTDECL(CUFDataTransferDescPtr)(const Descriptor &dst, void *src, |
| 32 | + std::size_t bytes, unsigned mode, const char *sourceFile = nullptr, |
| 33 | + int sourceLine = 0); |
| 34 | + |
| 35 | +/// Data transfer from a descriptor to a pointer. |
| 36 | +void RTDECL(CUFDataTransferPtrDesc)(void *dst, const Descriptor &src, |
| 37 | + std::size_t bytes, unsigned mode, const char *sourceFile = nullptr, |
| 38 | + int sourceLine = 0); |
| 39 | + |
| 40 | +/// Data transfer from a descriptor to a descriptor. |
| 41 | +void RTDECL(CUFDataTransferDescDesc)(const Descriptor &dst, |
| 42 | + const Descriptor &src, unsigned mode, const char *sourceFile = nullptr, |
| 43 | + int sourceLine = 0); |
| 44 | + |
| 45 | +} // extern "C" |
| 46 | +} // namespace Fortran::runtime::cuda |
| 47 | +#endif // FORTRAN_RUNTIME_CUDA_MEMORY_H_ |
0 commit comments