xref: /llvm-project/libc/src/stdlib/gpu/malloc.cpp (revision 256f40d0e6b2beb0e951b0f5f836847223c5695c)
1a6213088SJoseph Huber //===-- GPU Implementation of malloc --------------------------------------===//
2a6213088SJoseph Huber //
3a6213088SJoseph Huber // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4a6213088SJoseph Huber // See https://llvm.org/LICENSE.txt for license information.
5a6213088SJoseph Huber // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a6213088SJoseph Huber //
7a6213088SJoseph Huber //===----------------------------------------------------------------------===//
8a6213088SJoseph Huber 
9a6213088SJoseph Huber #include "src/stdlib/malloc.h"
10ea697dccSJoseph Huber 
11ea697dccSJoseph Huber #include "src/__support/GPU/allocator.h"
12a6213088SJoseph Huber #include "src/__support/common.h"
135ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
14a6213088SJoseph Huber 
155ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
16a6213088SJoseph Huber 
17*256f40d0SJoseph Huber // FIXME: For now we just default to the NVIDIA device allocator which is
18*256f40d0SJoseph Huber // always available on NVPTX targets. This will be implemented fully later.
19*256f40d0SJoseph Huber #ifndef LIBC_TARGET_ARCH_IS_NVPTX
20a6213088SJoseph Huber LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) {
21ea697dccSJoseph Huber   return gpu::allocate(size);
22a6213088SJoseph Huber }
23*256f40d0SJoseph Huber #endif
24a6213088SJoseph Huber 
255ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
26