clover: implements clGetKernelWorkGroupInfo CL_KERNEL_COMPILE_WORK_GROUP_SIZE

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4974>
This commit is contained in:
Serge Martin
2020-09-27 15:45:33 +02:00
committed by Marge Bot
parent aadd134081
commit c04d5e7efa
6 changed files with 22 additions and 4 deletions

View File

@@ -140,7 +140,7 @@ kernel::optimal_block_size(const command_queue &q,
std::vector<size_t>
kernel::required_block_size() const {
return { 0, 0, 0 };
return find(name_equals(_name), program().symbols()).reqd_work_group_size;
}
kernel::argument_range

View File

@@ -191,6 +191,7 @@ namespace {
proc(S &s, QT &x) {
_proc(s, x.name);
_proc(s, x.attributes);
_proc(s, x.reqd_work_group_size);
_proc(s, x.section);
_proc(s, x.offset);
_proc(s, x.args);

View File

@@ -129,15 +129,19 @@ namespace clover {
struct symbol {
symbol(const std::string &name, const std::string &attributes,
const std::vector<::size_t> &reqd_work_group_size,
resource_id section, size_t offset,
const std::vector<argument> &args) :
name(name), attributes(attributes),
reqd_work_group_size(reqd_work_group_size),
section(section),
offset(offset), args(args) { }
symbol() : name(), attributes(), section(0), offset(0), args() { }
symbol() : name(), attributes(), reqd_work_group_size({0, 0, 0}),
section(0), offset(0), args() { }
std::string name;
std::string attributes;
std::vector<::size_t> reqd_work_group_size;
resource_id section;
size_t offset;
std::vector<argument> args;

View File

@@ -103,6 +103,16 @@ namespace {
cl_address_qualifier, cl_access_qualifier);
}
std::vector<size_t>
get_reqd_work_group_size(const Module &mod,
const std::string &kernel_name) {
const Function &f = *mod.getFunction(kernel_name);
auto vector_metadata = get_uint_vector_kernel_metadata(f, "reqd_work_group_size");
return vector_metadata.empty() ? std::vector<size_t>({0, 0, 0}) : vector_metadata;
}
std::string
kernel_attributes(const Module &mod, const std::string &kernel_name) {
std::vector<std::string> attributes;
@@ -285,6 +295,7 @@ clover::llvm::build_module_common(const Module &mod,
const ::std::string name(llvm_name);
if (offsets.count(name))
m.syms.emplace_back(name, kernel_attributes(mod, name),
get_reqd_work_group_size(mod, name),
0, offsets.at(name),
make_kernel_args(mod, name, c));
}

View File

@@ -390,7 +390,8 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
reinterpret_cast<const char *>(&header) + sizeof(header));
text.data.insert(text.data.end(), blob.data, blob.data + blob.size);
m.syms.emplace_back(sym.name, std::string(), section_id, 0, args);
m.syms.emplace_back(sym.name, std::string(),
std::vector<size_t>(), section_id, 0, args);
m.secs.push_back(text);
section_id++;
}

View File

@@ -346,7 +346,8 @@ namespace {
case SpvOpFunctionEnd:
if (kernel_name.empty())
break;
m.syms.emplace_back(kernel_name, std::string(), 0, kernel_nb, args);
m.syms.emplace_back(kernel_name, std::string(),
std::vector<size_t>(), 0, kernel_nb, args);
++kernel_nb;
kernel_name.clear();
args.clear();