clover: Handle multiple kernels in the same program v2

v2: Tom Stellard
  - Use pc parameter of launch_grid()

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
Blaž Tomažič
2012-09-13 14:51:46 +00:00
committed by Tom Stellard
parent 68a4bb553b
commit e59505e34b
2 changed files with 35 additions and 31 deletions

View File

@@ -507,6 +507,10 @@ struct pipe_context {
* grid (in block units) and working block (in thread units) to be * grid (in block units) and working block (in thread units) to be
* used, respectively. * used, respectively.
* *
* \a pc For drivers that use PIPE_SHADER_IR_LLVM as their prefered IR,
* this value will be the index of the kernel in the opencl.kernels
* metadata list.
*
* \a input will be used to initialize the INPUT resource, and it * \a input will be used to initialize the INPUT resource, and it
* should point to a buffer of at least * should point to a buffer of at least
* pipe_compute_state::req_input_mem bytes. * pipe_compute_state::req_input_mem bytes.

View File

@@ -199,14 +199,12 @@ namespace {
llvm::WriteBitcodeToFile(mod, bitcode_ostream); llvm::WriteBitcodeToFile(mod, bitcode_ostream);
bitcode_ostream.flush(); bitcode_ostream.flush();
for (unsigned i = 0; i < kernels.size(); ++i) {
llvm::Function *kernel_func; llvm::Function *kernel_func;
std::string kernel_name; std::string kernel_name;
compat::vector<module::argument> args; compat::vector<module::argument> args;
// XXX: Support more than one kernel kernel_func = kernels[i];
assert(kernels.size() == 1);
kernel_func = kernels[0];
kernel_name = kernel_func->getName(); kernel_name = kernel_func->getName();
for (llvm::Function::arg_iterator I = kernel_func->arg_begin(), for (llvm::Function::arg_iterator I = kernel_func->arg_begin(),
@@ -236,12 +234,14 @@ namespace {
} }
} }
m.syms.push_back(module::symbol(kernel_name, 0, i, args ));
}
header.num_bytes = llvm_bitcode.size(); header.num_bytes = llvm_bitcode.size();
std::string data; std::string data;
data.insert(0, (char*)(&header), sizeof(header)); data.insert(0, (char*)(&header), sizeof(header));
data.insert(data.end(), llvm_bitcode.begin(), data.insert(data.end(), llvm_bitcode.begin(),
llvm_bitcode.end()); llvm_bitcode.end());
m.syms.push_back(module::symbol(kernel_name, 0, 0, args ));
m.secs.push_back(module::section(0, module::section::text, m.secs.push_back(module::section(0, module::section::text,
header.num_bytes, data)); header.num_bytes, data));