[Mesa-dev] [PATCH 1/1] clover: Align kernel argument sizes to nearest power of 2

Jan Vesely jan.vesely at rutgers.edu
Thu Apr 24 14:21:06 PDT 2014


Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---

Hi,

this is the alternative (power of 2) approach to hadling kernel args,
as discussed in this thread:
http://lists.freedesktop.org/archives/mesa-dev/2014-April/thread.html#58209

Jan

 src/gallium/state_trackers/clover/llvm/invocation.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index a81bdf8..8e5b49b 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -64,6 +64,7 @@
 
 #include "pipe/p_state.h"
 #include "util/u_memory.h"
+#include "util/u_math.h"
 
 #include <iostream>
 #include <iomanip>
@@ -309,6 +310,9 @@ namespace {
 
             llvm::Type *arg_type = arg.getType();
             unsigned arg_size = TD.getTypeStoreSize(arg_type);
+            if (!util_is_power_of_two(arg_size)) {
+              arg_size = util_next_power_of_two(arg_size);
+            }
 
             llvm::Type *target_type = arg_type->isIntegerTy() ?
                TD.getSmallestLegalIntType(mod->getContext(), arg_size * 8) :
-- 
1.9.0



More information about the mesa-dev mailing list