diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt --- a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +++ b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt @@ -64,6 +64,7 @@ ${devicertl_base_directory}/common/src/omptarget.cu ${devicertl_base_directory}/common/src/parallel.cu ${devicertl_base_directory}/common/src/reduction.cu + ${devicertl_base_directory}/common/src/support.cu ${devicertl_base_directory}/common/src/sync.cu ${devicertl_base_directory}/common/src/task.cu) diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h --- a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h @@ -164,6 +164,10 @@ EXTERN void __kmpc_impl_unset_lock(omp_lock_t *lock); EXTERN int __kmpc_impl_test_lock(omp_lock_t *lock); +// Memory +EXTERN void *__kmpc_impl_malloc(size_t x); +EXTERN void __kmpc_impl_free(void *x); + // DEVICE versions of part of libc extern "C" { DEVICE __attribute__((noreturn)) void diff --git a/openmp/libomptarget/deviceRTLs/common/omptarget.h b/openmp/libomptarget/deviceRTLs/common/omptarget.h --- a/openmp/libomptarget/deviceRTLs/common/omptarget.h +++ b/openmp/libomptarget/deviceRTLs/common/omptarget.h @@ -17,7 +17,6 @@ // std includes #include #include -#include // local includes #include "target_impl.h" diff --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu --- a/openmp/libomptarget/deviceRTLs/common/src/support.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu @@ -250,7 +250,7 @@ DEVICE void *SafeMalloc(size_t size, const char *msg) // check if success { - void *ptr = malloc(size); + void *ptr = __kmpc_impl_malloc(size); PRINT(LD_MEM, "malloc data of size %llu for %s: 0x%llx\n", (unsigned long long)size, msg, (unsigned long long)ptr); return ptr; @@ -258,7 +258,7 @@ DEVICE void *SafeFree(void *ptr, const char *msg) { PRINT(LD_MEM, "free data ptr 0x%llx for %s\n", (unsigned long long)ptr, msg); - free(ptr); + __kmpc_impl_free(ptr); return NULL; } diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h --- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h @@ -13,6 +13,8 @@ #define _TARGET_IMPL_H_ #include +#include + #include "nvptx_interface.h" #define DEVICE __device__ @@ -204,4 +206,8 @@ EXTERN void __kmpc_impl_unset_lock(omp_lock_t *lock); EXTERN int __kmpc_impl_test_lock(omp_lock_t *lock); +// Memory +INLINE void *__kmpc_impl_malloc(size_t x) { return malloc(x); } +INLINE void __kmpc_impl_free(void *x) { free(x); } + #endif