diff options
author | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2018-10-01 16:51:04 +0000 |
---|---|---|
committer | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2018-10-01 16:51:04 +0000 |
commit | 564ca71e392f580144a7ded4ac9e3700c848495e (patch) | |
tree | 7d5cafc2305816145c1f55f89effe0397f7ebc34 /Eigen | |
parent | 2088c0897f6ea7175d06de98fe04c71cd453a34d (diff) | |
parent | 94898488a6fe3096a7a44d0bb108e514f0e44699 (diff) |
Merged in deven-amd/eigen/HIP_fixes (pull request PR-518)
PR with HIP specific fixes (for the eigen nightly regression failures in HIP mode)
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/util/ConfigureVectorization.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/util/Memory.h | 18 |
2 files changed, 19 insertions, 5 deletions
diff --git a/Eigen/src/Core/util/ConfigureVectorization.h b/Eigen/src/Core/util/ConfigureVectorization.h index e75c7d89e..a2743624e 100644 --- a/Eigen/src/Core/util/ConfigureVectorization.h +++ b/Eigen/src/Core/util/ConfigureVectorization.h @@ -379,10 +379,12 @@ #include <cuda_fp16.h> #endif -#if defined(EIGEN_HIP_DEVICE_COMPILE) - +#if defined(EIGEN_HIPCC) #define EIGEN_VECTORIZE_GPU #include <hip/hip_vector_types.h> +#endif + +#if defined(EIGEN_HIP_DEVICE_COMPILE) #define EIGEN_HAS_HIP_FP16 #include <hip/hip_fp16.h> diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 9dd2e0252..c624556c5 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -96,10 +96,16 @@ inline void throw_std_bad_alloc() /** \internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned. * Fast, but wastes 16 additional bytes of memory. Does not throw any exception. */ -inline void* handmade_aligned_malloc(std::size_t size, std::size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) +EIGEN_DEVICE_FUNC inline void* handmade_aligned_malloc(std::size_t size, std::size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) { eigen_assert(alignment >= sizeof(void*) && (alignment & -alignment) == alignment && "Alignment must be at least sizeof(void*) and a power of 2"); + +#if defined(EIGEN_HIP_DEVICE_COMPILE) + void *original = ::malloc(size+alignment); +#else void *original = std::malloc(size+alignment); +#endif + if (original == 0) return 0; void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(alignment-1))) + alignment); *(reinterpret_cast<void**>(aligned) - 1) = original; @@ -107,9 +113,15 @@ inline void* handmade_aligned_malloc(std::size_t size, std::size_t alignment = E } /** \internal Frees memory allocated with handmade_aligned_malloc */ -inline void handmade_aligned_free(void *ptr) +EIGEN_DEVICE_FUNC inline void handmade_aligned_free(void *ptr) { - if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1)); + if (ptr) { +#if defined(EIGEN_HIP_DEVICE_COMPILE) + ::free(*(reinterpret_cast<void**>(ptr) - 1)); +#else + std::free(*(reinterpret_cast<void**>(ptr) - 1)); +#endif + } } /** \internal |