summaryrefslogtreecommitdiffstats
path: root/openmp
diff options
context:
space:
mode:
authorJon Chesterfield <jonathanchesterfield@gmail.com>2019-12-19 16:54:27 +0000
committerJon Chesterfield <jonathanchesterfield@gmail.com>2019-12-19 16:54:28 +0000
commit63e2aa5658bd8a4905ae5a85f9046250a5e16a86 (patch)
tree17b45743c2794adc9567c1d8c1b6b0810ed92935 /openmp
parent2520bef865329d4c04e2de30c222ad0d5ad13ccc (diff)
downloadbcm5719-llvm-63e2aa5658bd8a4905ae5a85f9046250a5e16a86.tar.gz
bcm5719-llvm-63e2aa5658bd8a4905ae5a85f9046250a5e16a86.zip
[libomptarget][nfc] Provide target_impl malloc/free
Summary: [libomptarget][nfc] Provide target_impl malloc/free Sufficient to build support.cu for amdgcn Reviewers: jdoerfert, ABataev, grokos Reviewed By: jdoerfert Subscribers: jvesely, mgorny, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D71685
Diffstat (limited to 'openmp')
-rw-r--r--openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt1
-rw-r--r--openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h4
-rw-r--r--openmp/libomptarget/deviceRTLs/common/omptarget.h1
-rw-r--r--openmp/libomptarget/deviceRTLs/common/src/support.cu4
-rw-r--r--openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h6
5 files changed, 13 insertions, 3 deletions
diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
index d3df65b734d..4395ccf80b5 100644
--- a/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
+++ b/openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
@@ -64,6 +64,7 @@ set(cuda_sources
${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
index 9b7b8e3fd95..ec72800cd69 100644
--- 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_set_lock(omp_lock_t *lock);
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
index 8ffa31091d4..8f577f7364d 100644
--- a/openmp/libomptarget/deviceRTLs/common/omptarget.h
+++ b/openmp/libomptarget/deviceRTLs/common/omptarget.h
@@ -17,7 +17,6 @@
// std includes
#include <inttypes.h>
#include <math.h>
-#include <stdlib.h>
// local includes
#include "target_impl.h"
diff --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu
index ea1fc3841ad..d7a0b23667f 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/support.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu
@@ -250,7 +250,7 @@ DEVICE unsigned long PadBytes(unsigned long size,
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 *SafeMalloc(size_t size, const char *msg) // check if success
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
index 6d585288268..c11fe253cc7 100644
--- 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 <cuda.h>
+#include <stdlib.h>
+
#include "nvptx_interface.h"
#define DEVICE __device__
@@ -204,4 +206,8 @@ EXTERN void __kmpc_impl_set_lock(omp_lock_t *lock);
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
OpenPOWER on IntegriCloud