[clang-tidy][NFC]remove deps of clang in clang tidy test (#116588)
[llvm-project.git] / offload / DeviceRTL / include / Allocator.h
blob475f6a21bb47ebf93e64c8ad7fb8661314264bd1
1 //===-------- Allocator.h - OpenMP memory allocator interface ---- 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 //
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)
22 namespace ompx {
24 namespace allocator {
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 *
33 alloc(uint64_t Size);
35 /// Free the allocation pointed to by \p Ptr.
36 void free(void *Ptr);
38 } // namespace allocator
40 } // namespace ompx
42 extern "C" {
43 [[gnu::weak]] void *malloc(size_t Size);
44 [[gnu::weak]] void free(void *Ptr);
47 #pragma omp end declare target
49 #endif