Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libc/src/stdlib/gpu/free.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

namespace LIBC_NAMESPACE_DECL {

// FIXME: For now we just default to the NVIDIA device allocator which is
// always available on NVPTX targets. This will be implemented fully later.
#ifndef LIBC_TARGET_ARCH_IS_NVPTX
LLVM_LIBC_FUNCTION(void, free, (void *ptr)) { gpu::deallocate(ptr); }
#endif

} // namespace LIBC_NAMESPACE_DECL
4 changes: 4 additions & 0 deletions libc/src/stdlib/gpu/malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

namespace LIBC_NAMESPACE_DECL {

// FIXME: For now we just default to the NVIDIA device allocator which is
// always available on NVPTX targets. This will be implemented fully later.
#ifndef LIBC_TARGET_ARCH_IS_NVPTX
LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) {
return gpu::allocate(size);
}
#endif

} // namespace LIBC_NAMESPACE_DECL
3 changes: 2 additions & 1 deletion libc/test/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ if(LLVM_LIBC_FULL_BUILD)
)

# Only baremetal and GPU has an in-tree 'malloc' implementation.
if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU)
if((LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU) AND
NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
add_libc_test(
malloc_test
HERMETIC_TEST_ONLY
Expand Down
Loading