Fix MIOpen build failure
This is charrypick of 9ead991784
and https://github.com/ROCm-Developer-Tools/HIP/pull/2009
Fix cmake config file
Removed cmake target files under packaging directory.
Merged cmake config .in files for HIP-Clang and HCC as one.
Use cmake generated target files in both install and packaging.
This makes cmake config file consistent for make install and
make package.
Let device side malloc/free return nullptr and trap
Change-Id: I448f3ea2d4934648089bad371debc203f895cba6
This commit is contained in:
@@ -27,7 +27,7 @@ THE SOFTWARE.
|
||||
// HIP heap is implemented as a global array with fixed size. Users may define
|
||||
// __HIP_SIZE_OF_PAGE and __HIP_NUM_PAGES to have a larger heap.
|
||||
|
||||
#if __HCC__ || __HIP__
|
||||
#if (__HCC__ || __HIP__) && __HIP_ENABLE_MALLOC__
|
||||
|
||||
// Size of page in bytes.
|
||||
#ifndef __HIP_SIZE_OF_PAGE
|
||||
|
||||
@@ -44,6 +44,11 @@ THE SOFTWARE.
|
||||
#include <stddef.h>
|
||||
#endif //__cplusplus
|
||||
|
||||
// __hip_malloc is not working. Disable it by default.
|
||||
#ifndef __HIP_ENABLE_MALLOC__
|
||||
#define __HIP_ENABLE_MALLOC__ 0
|
||||
#endif
|
||||
|
||||
#if __HCC_OR_HIP_CLANG__
|
||||
|
||||
#if __HIP__
|
||||
@@ -308,11 +313,15 @@ static constexpr Coordinates<hip_impl::WorkitemId> threadIdx{};
|
||||
|
||||
#endif // defined __HCC__
|
||||
#if __HCC_OR_HIP_CLANG__
|
||||
#if __HIP_ENABLE_MALLOC__
|
||||
extern "C" __device__ void* __hip_malloc(size_t);
|
||||
extern "C" __device__ void* __hip_free(void* ptr);
|
||||
|
||||
static inline __device__ void* malloc(size_t size) { return __hip_malloc(size); }
|
||||
static inline __device__ void* free(void* ptr) { return __hip_free(ptr); }
|
||||
#else
|
||||
static inline __device__ void* malloc(size_t size) { __builtin_trap(); return nullptr; }
|
||||
static inline __device__ void* free(void* ptr) { __builtin_trap(); return nullptr; }
|
||||
#endif
|
||||
|
||||
#endif //__HCC_OR_HIP_CLANG__
|
||||
|
||||
|
||||
Reference in New Issue
Block a user