[PATCH] D22701: [test-suite] Bitcode simd tests: align memory to 128.

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 14:10:27 PDT 2016


asbirlea created this revision.
asbirlea added reviewers: llvm-commits, mehdi_amini.

Patch preparing the addition of more tests.
Some require 128 alignment, so update driver to allocate aligned memory.

https://reviews.llvm.org/D22701

Files:
  Bitcode/simd_ops/halide_buffer.h
  Bitcode/simd_ops/simd_ops.cpp

Index: Bitcode/simd_ops/simd_ops.cpp
===================================================================
--- Bitcode/simd_ops/simd_ops.cpp
+++ Bitcode/simd_ops/simd_ops.cpp
@@ -12,7 +12,12 @@
 
 template<typename T>
 buffer_t make_buffer(int w, int h) {
-    T *mem = new T[w*h];
+#if defined(__APPLE__)
+    T *mem;
+    int err = posix_memalign((void **)&mem, 128, w*h*sizeof(T));
+#else
+    T *mem = (T *)memalign(128, w*h*sizeof(T));
+#endif
     buffer_t buf = {0};
     buf.host = (uint8_t *)mem;
     buf.extent[0] = w;
Index: Bitcode/simd_ops/halide_buffer.h
===================================================================
--- Bitcode/simd_ops/halide_buffer.h
+++ Bitcode/simd_ops/halide_buffer.h
@@ -1,6 +1,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
+#if !defined(__APPLE__)
+#include <malloc.h>
+#endif
 #ifndef HALIDE_ATTRIBUTE_ALIGN
   #ifdef _MSC_VER
     #define HALIDE_ATTRIBUTE_ALIGN(x) __declspec(align(x))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22701.65153.patch
Type: text/x-patch
Size: 951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160722/212cbc72/attachment.bin>


More information about the llvm-commits mailing list