Warning: This file is not a C or C++ file. It does not have highlighting.
| 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 | //===----------------------------------------------------------------------===// |
| 11 | |
| 12 | #ifndef OMPTARGET_ALLOCATOR_H |
| 13 | #define OMPTARGET_ALLOCATOR_H |
| 14 | |
| 15 | #include "DeviceTypes.h" |
| 16 | |
| 17 | // Forward declaration. |
| 18 | struct KernelEnvironmentTy; |
| 19 | |
| 20 | namespace ompx { |
| 21 | |
| 22 | namespace allocator { |
| 23 | |
| 24 | static uint64_t constexpr ALIGNMENT = 16; |
| 25 | |
| 26 | /// Initialize the allocator according to \p KernelEnvironment |
| 27 | void init(bool IsSPMD, KernelEnvironmentTy &KernelEnvironment); |
| 28 | |
| 29 | /// Allocate \p Size bytes. |
| 30 | [[gnu::alloc_size(1), gnu::assume_aligned(ALIGNMENT), gnu::malloc]] void * |
| 31 | alloc(uint64_t Size); |
| 32 | |
| 33 | /// Free the allocation pointed to by \p Ptr. |
| 34 | void free(void *Ptr); |
| 35 | |
| 36 | } // namespace allocator |
| 37 | |
| 38 | } // namespace ompx |
| 39 | |
| 40 | extern "C" { |
| 41 | [[gnu::weak]] void *malloc(size_t Size); |
| 42 | [[gnu::weak]] void free(void *Ptr); |
| 43 | } |
| 44 | |
| 45 | #endif |
| 46 |
Warning: This file is not a C or C++ file. It does not have highlighting.
