aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2015-03-31 22:52:46 +0000
committerGil Pitney <gil.pitney@linaro.org>2015-03-31 22:52:46 +0000
commit441c89fbd0cfeccd8cd790a44d4c5365c563720c (patch)
tree1d5a80b486430799514bfa794590d71b7eec550c
parent7779a842e5fabb7223354a676af36c80eaacfc0d (diff)
Update clGetProgramInfo() for library program objects.
Added: clGetProgramInfo( program, CL_PROGRAM_BINARY_SIZES, ...) clGetProgramInfo( program, CL_PROGRAM_BINARIES, ...) to return binaries for library program objects. Previously, this was only returning binaries for executables. This enables the Khronos v1.2 conformance test to pass: - % test_compiler execute_after_serialize_reload_library Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/core/program.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/core/program.cpp b/src/core/program.cpp
index 5d32840..f5e9b64 100644
--- a/src/core/program.cpp
+++ b/src/core/program.cpp
@@ -105,6 +105,7 @@ void Program::resetDeviceDependent()
delete dep.compiler;
delete dep.program;
delete dep.linked_module;
+ dep.unlinked_binary.clear();
p_device_dependent.pop_back();
}
@@ -123,6 +124,7 @@ void Program::setDevices(cl_uint num_devices, DeviceInterface * const*devices)
dep.is_native_binary = false;
dep.linked_module = 0;
dep.compiler = new Compiler(dep.device);
+ dep.unlinked_binary.clear();
}
}
@@ -956,9 +958,21 @@ cl_int Program::info(cl_program_info param_name,
case CL_PROGRAM_BINARY_SIZES:
for (size_t i=0; i<p_device_dependent.size(); ++i)
{
- const DeviceDependent &dep = p_device_dependent[i];
+ DeviceDependent &dep = const_cast<Coal::Program::DeviceDependent&>
+ (p_device_dependent[i]);
- binary_sizes.push_back(dep.unlinked_binary.size());
+ if (!dep.linked_module) {
+ binary_sizes.push_back(0);
+ }
+ else if (dep.unlinked_binary.empty()) {
+ llvm::raw_string_ostream ostream(dep.unlinked_binary);
+ llvm::WriteBitcodeToFile(dep.linked_module, ostream);
+ ostream.flush();
+ binary_sizes.push_back(dep.unlinked_binary.size());
+ }
+ else {
+ binary_sizes.push_back(dep.unlinked_binary.size());
+ }
}
value = binary_sizes.data();
@@ -977,12 +991,19 @@ cl_int Program::info(cl_program_info param_name,
if (param_value && param_value_size >= value_length)
for (size_t i=0; i<p_device_dependent.size(); ++i)
{
- const DeviceDependent &dep = p_device_dependent[i];
+ DeviceDependent &dep = const_cast<Coal::Program::DeviceDependent&>
+ (p_device_dependent[i]);
unsigned char *dest = binaries[i];
if (!dest)
continue;
+ if (dep.unlinked_binary.empty()) {
+ llvm::raw_string_ostream ostream(dep.unlinked_binary);
+ llvm::WriteBitcodeToFile(dep.linked_module, ostream);
+ ostream.flush();
+ }
+
std::memcpy(dest, dep.unlinked_binary.data(),
dep.unlinked_binary.size());
}