summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorBlaž Tomažič <[email protected]>2012-09-13 14:51:46 +0000
committerTom Stellard <[email protected]>2012-09-25 14:27:47 +0000
commite59505e34bdea772bb439cb42f2ef20ec495de03 (patch)
tree9773c891af33c2a7d60190cb12499f093c3fc59d /src/gallium/state_trackers
parent68a4bb553bcd51d336d95b0c845c0dc63adc3bd3 (diff)
clover: Handle multiple kernels in the same program v2
v2: Tom Stellard - Use pc parameter of launch_grid() Reviewed-by: Francisco Jerez <[email protected]> Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/clover/llvm/invocation.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index be15e960b18..6ab9025f209 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -199,41 +199,42 @@ namespace {
llvm::WriteBitcodeToFile(mod, bitcode_ostream);
bitcode_ostream.flush();
- llvm::Function *kernel_func;
- std::string kernel_name;
- compat::vector<module::argument> args;
-
- // XXX: Support more than one kernel
- assert(kernels.size() == 1);
-
- kernel_func = kernels[0];
- kernel_name = kernel_func->getName();
-
- for (llvm::Function::arg_iterator I = kernel_func->arg_begin(),
- E = kernel_func->arg_end(); I != E; ++I) {
- llvm::Argument &arg = *I;
- llvm::Type *arg_type = arg.getType();
- llvm::TargetData TD(kernel_func->getParent());
- unsigned arg_size = TD.getTypeStoreSize(arg_type);
-
- if (llvm::isa<llvm::PointerType>(arg_type) && arg.hasByValAttr()) {
- arg_type =
- llvm::dyn_cast<llvm::PointerType>(arg_type)->getElementType();
- }
+ for (unsigned i = 0; i < kernels.size(); ++i) {
+ llvm::Function *kernel_func;
+ std::string kernel_name;
+ compat::vector<module::argument> args;
+
+ kernel_func = kernels[i];
+ kernel_name = kernel_func->getName();
+
+ for (llvm::Function::arg_iterator I = kernel_func->arg_begin(),
+ E = kernel_func->arg_end(); I != E; ++I) {
+ llvm::Argument &arg = *I;
+ llvm::Type *arg_type = arg.getType();
+ llvm::TargetData TD(kernel_func->getParent());
+ unsigned arg_size = TD.getTypeStoreSize(arg_type);
+
+ if (llvm::isa<llvm::PointerType>(arg_type) && arg.hasByValAttr()) {
+ arg_type =
+ llvm::dyn_cast<llvm::PointerType>(arg_type)->getElementType();
+ }
- if (arg_type->isPointerTy()) {
- // XXX: Figure out LLVM->OpenCL address space mappings for each
- // target. I think we need to ask clang what these are. For now,
- // pretend everything is in the global address space.
- unsigned address_space = llvm::cast<llvm::PointerType>(arg_type)->getAddressSpace();
- switch (address_space) {
- default:
- args.push_back(module::argument(module::argument::global, arg_size));
- break;
+ if (arg_type->isPointerTy()) {
+ // XXX: Figure out LLVM->OpenCL address space mappings for each
+ // target. I think we need to ask clang what these are. For now,
+ // pretend everything is in the global address space.
+ unsigned address_space = llvm::cast<llvm::PointerType>(arg_type)->getAddressSpace();
+ switch (address_space) {
+ default:
+ args.push_back(module::argument(module::argument::global, arg_size));
+ break;
+ }
+ } else {
+ args.push_back(module::argument(module::argument::scalar, arg_size));
}
- } else {
- args.push_back(module::argument(module::argument::scalar, arg_size));
}
+
+ m.syms.push_back(module::symbol(kernel_name, 0, i, args ));
}
header.num_bytes = llvm_bitcode.size();
@@ -241,7 +242,6 @@ namespace {
data.insert(0, (char*)(&header), sizeof(header));
data.insert(data.end(), llvm_bitcode.begin(),
llvm_bitcode.end());
- m.syms.push_back(module::symbol(kernel_name, 0, 0, args ));
m.secs.push_back(module::section(0, module::section::text,
header.num_bytes, data));