diff options
author | Gil Pitney <gil.pitney@linaro.org> | 2015-07-22 20:40:41 +0000 |
---|---|---|
committer | Gil Pitney <gil.pitney@linaro.org> | 2015-07-22 20:40:41 +0000 |
commit | 0d99b82aae804520c1fedef4d78a5f4437512fe0 (patch) | |
tree | 4c06a0cbf00ec1a0648df236a818265122eb28d3 | |
parent | 6d46320dcbf891a15fbe0ce4954afdaf2bfc4a54 (diff) |
Update Kernel::reqdWorkGroupSize() to search all meta node operands.
With an update of LLVM to 3.6+, the reqd_work_group_size attribute is no
longer sitting in the first operand position of the function's meta data
node. It now can be anywhere.
This patch iterates through all the metanode operands searching for the
reqd_work_group_size attribute.
This enables the Khronos test:
% test_api kernel_required_group_size
to PASS.
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r-- | src/core/kernel.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/kernel.cpp b/src/core/kernel.cpp index e2133cf..92a0cca 100644 --- a/src/core/kernel.cpp +++ b/src/core/kernel.cpp @@ -723,16 +723,18 @@ boost::tuple<uint,uint,uint> Kernel::reqdWorkGroupSize(llvm::Module *module) con if (node->getNumOperands() <= 1) return zeros; - llvm::MDNode *meta = llvm::cast<llvm::MDNode>(node->getOperand(1)); - std::string meta_name = llvm::cast<MDString>(meta->getOperand(0))->getString().str(); - if ((meta->getNumOperands() == 4) && (meta_name == "reqd_work_group_size")) - { - // See comments in http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantInt.html - auto x = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(1))->getLimitedValue(); - auto y = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(2))->getLimitedValue(); - auto z = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(3))->getLimitedValue(); + for (int i = 1, numOperands = node->getNumOperands(); i < numOperands; i++) { + llvm::MDNode *meta = llvm::cast<llvm::MDNode>(node->getOperand(i)); + std::string meta_name = llvm::cast<MDString>(meta->getOperand(0))->getString().str(); + if ((meta->getNumOperands() == 4) && (meta_name == "reqd_work_group_size")) + { + // See comments in http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantInt.html + auto x = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(1))->getLimitedValue(); + auto y = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(2))->getLimitedValue(); + auto z = llvm::mdconst::dyn_extract<ConstantInt>(meta->getOperand(3))->getLimitedValue(); - return boost::tuple<uint,uint,uint> (x,y,z); + return boost::tuple<uint,uint,uint> (x,y,z); + } } return zeros; } |