1 //===-------- Allocator.h - OpenMP memory allocator interface ---- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 #ifndef OMPTARGET_ALLOCATOR_H
13 #define OMPTARGET_ALLOCATOR_H
15 #include "DeviceTypes.h"
17 // Forward declaration.
18 struct KernelEnvironmentTy
;
20 #pragma omp begin declare target device_type(nohost)
26 static uint64_t constexpr ALIGNMENT
= 16;
28 /// Initialize the allocator according to \p KernelEnvironment
29 void init(bool IsSPMD
, KernelEnvironmentTy
&KernelEnvironment
);
31 /// Allocate \p Size bytes.
32 [[gnu::alloc_size(1), gnu::assume_aligned(ALIGNMENT
), gnu::malloc
]] void *
35 /// Free the allocation pointed to by \p Ptr.
38 } // namespace allocator
43 [[gnu::weak
]] void *malloc(size_t Size
);
44 [[gnu::weak
]] void free(void *Ptr
);
47 #pragma omp end declare target