FLANG
allocator.h
1//===-- include/flang/Runtime/CUDA/allocator.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_ALLOCATOR_H_
10#define FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
11
12#include "common.h"
13#include "flang/Runtime/descriptor-consts.h"
14#include "flang/Runtime/entry-names.h"
15
16#include "cuda_runtime.h"
17
18namespace Fortran::runtime {
19class Lock;
20}
21
22namespace Fortran::runtime::cuda {
23
24extern "C" {
25cudaStream_t RTDECL(CUFGetAssociatedStream)(void *);
26int RTDECL(CUFSetAssociatedStream)(void *, cudaStream_t);
27void RTDECL(CUFRegisterAllocator)();
28}
29
30void CUFResetStream(cudaStream_t stream);
31
32extern Lock asyncDeviceAllocationTableLock;
33
34int findAsyncDeviceAllocation(void *ptr);
35void insertAsyncDeviceAllocation(
36 void *ptr, std::size_t size, cudaStream_t stream);
37cudaStream_t getAsyncDeviceAllocationStream(int pos);
38void eraseAsyncDeviceAllocation(int pos);
39
40void *CUFAllocPinned(std::size_t, std::size_t, std::int64_t *);
41void CUFFreePinned(void *);
42
43void *CUFAllocDevice(std::size_t, std::size_t, std::int64_t *);
44void CUFFreeDevice(void *);
45
46void *CUFAllocManaged(std::size_t, std::size_t, std::int64_t *);
47void CUFFreeManaged(void *);
48
49void *CUFAllocUnified(std::size_t, std::size_t, std::int64_t *);
50void CUFFreeUnified(void *);
51
52} // namespace Fortran::runtime::cuda
53#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_