[flang-commits] [flang] [flang][cuda] Add new entry points function for data transfer (PR #108244)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Wed Sep 11 11:28:49 PDT 2024


================
@@ -0,0 +1,45 @@
+//===-- include/flang/Runtime/CUDA/memory.h ---------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_RUNTIME_CUDA_MEMORY_H_
+#define FORTRAN_RUNTIME_CUDA_MEMORY_H_
+
+#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/entry-names.h"
+#include <cstddef>
+
+static constexpr unsigned kHostToDevice = 0;
+static constexpr unsigned kDeviceToHost = 1;
+static constexpr unsigned kDeviceToDevice = 2;
+
+namespace Fortran::runtime::cuda {
+
+extern "C" {
+
+// Set value to the data hold by a descriptor.
+void RTDECL(CUFMemsetDescriptor)(const Descriptor &desc, void *value,
+    const char *sourceFile = nullptr, int sourceLine = 0);
+
+// Data transfer from a pointer to a descriptor.
+void RTDECL(CUFDataTransferDescPtr)(const Descriptor &dst, void *src,
+    std::size_t bytes, unsigned mode, const char *sourceFile = nullptr,
+    int sourceLine = 0);
+
+// Data transfer from a descriptor to a pointer.
+void RTDECL(CUFDataTransferPtrDesc)(void *dst, const Descriptor &src,
+    std::size_t bytes, unsigned mode, const char *sourceFile = nullptr,
+    int sourceLine = 0);
+
+// Data transfer from a descriptor to a descriptor.
+void RTDECL(CUFDataTransferDescDesc)(const Descriptor &dst,
+    const Descriptor &src, unsigned mode, const char *sourceFile = nullptr,
----------------
clementval wrote:

Do you mean smth like
```
module m
  type :: t1
    integer, allocatable :: a(:)
  end type
end

program p
  use m
  type(t1) :: h
  type(t1), device :: d

  h = d
end
```

This is allowed

https://github.com/llvm/llvm-project/pull/108244


More information about the flang-commits mailing list