From 54eddfc8f09d22e5205e538dcb6c20a0b26ae2aa Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Thu, 17 Oct 2019 18:58:32 -0400 Subject: [PATCH] _aligned_malloc() on Windows first takes size, then alignment, which is the opposite of how the similar function behaves on Linux. Memory allocated by it also has to be freed using _aligned_free(), unlike Linux where we can use regular free(). Edit aligned_alloc() macro and add a aligned_free() one to align with the above behaviour. [ROCm/clr commit: f4440817cbfc83c2fea31442d939bf8eabeecb92] --- .../hipamd/tests/src/runtimeApi/memory/hipMemcpy_simple.cpp | 4 ++-- projects/clr/hipamd/tests/src/test_common.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy_simple.cpp b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy_simple.cpp index 8ce02d6164..4aacfa866d 100644 --- a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy_simple.cpp +++ b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy_simple.cpp @@ -120,8 +120,8 @@ void simpleTest2(size_t numElements, bool usePinnedHost) { HIPCHECK(hipHostFree(A_h1)); HIPCHECK(hipHostFree(A_h2)); } else { - free(A_h1); - free(A_h2); + aligned_free(A_h1); + aligned_free(A_h2); } } diff --git a/projects/clr/hipamd/tests/src/test_common.h b/projects/clr/hipamd/tests/src/test_common.h index 73a952b0d1..dd77cd64a3 100644 --- a/projects/clr/hipamd/tests/src/test_common.h +++ b/projects/clr/hipamd/tests/src/test_common.h @@ -99,11 +99,15 @@ THE SOFTWARE. #ifdef _WIN64 #include -#define aligned_alloc _aligned_malloc +#define aligned_alloc(x,y) _aligned_malloc(y,x) +#define aligned_free(x) _aligned_free(x) #define popen(x,y) _popen(x,y) #define pclose(x) _pclose(x) #define setenv(x,y,z) _putenv_s(x,y) #endif +#else +#define aligned_free(x) free(x) +#endif // standard command-line variables: extern size_t N;