88#include < cstring>
99#include < fstream>
1010#include < sstream>
11+ #include < string>
1112
1213#include " ur_api.h"
1314#include " ur_filesystem_resolved.hpp"
@@ -190,23 +191,20 @@ KernelsEnvironment::parseKernelOptions(int argc, char **argv,
190191 return options;
191192}
192193
193- std::string KernelsEnvironment::getTargetName (ur_platform_handle_t platform) {
194- std::stringstream IL;
195-
194+ std::string
195+ KernelsEnvironment::getDefaultTargetName (ur_platform_handle_t platform) {
196196 if (instance->GetDevices ().size () == 0 ) {
197197 error = " no devices available on the platform" ;
198198 return {};
199199 }
200200
201- // special case for AMD as it doesn't support IL.
202201 ur_platform_backend_t backend;
203202 if (urPlatformGetInfo (platform, UR_PLATFORM_INFO_BACKEND, sizeof (backend),
204203 &backend, nullptr )) {
205204 error = " failed to get backend from platform." ;
206205 return {};
207206 }
208207
209- std::string target = " " ;
210208 switch (backend) {
211209 case UR_PLATFORM_BACKEND_OPENCL:
212210 case UR_PLATFORM_BACKEND_LEVEL_ZERO:
@@ -226,17 +224,10 @@ std::string KernelsEnvironment::getTargetName(ur_platform_handle_t platform) {
226224
227225std::string
228226KernelsEnvironment::getKernelSourcePath (const std::string &kernel_name,
229- ur_platform_handle_t platform ) {
227+ const std::string &target_name ) {
230228 std::stringstream path;
231- path << kernel_options.kernel_directory << " /" << kernel_name;
232-
233- std::string target_name = getTargetName (platform);
234- if (target_name.empty ()) {
235- return {};
236- }
237-
238- path << " /" << target_name << " .bin.0" ;
239-
229+ path << kernel_options.kernel_directory << " /" << kernel_name << " /"
230+ << target_name << " .bin.0" ;
240231 return path.str ();
241232}
242233
@@ -246,13 +237,20 @@ void KernelsEnvironment::LoadSource(
246237 // We don't have a way to build device code for native cpu yet.
247238 UUR_KNOWN_FAILURE_ON_PARAM (platform, uur::NativeCPU{});
248239
249- std::string source_path =
250- instance->getKernelSourcePath (kernel_name, platform);
251-
252- if (source_path.empty ()) {
240+ std::string target_name = getDefaultTargetName (platform);
241+ if (target_name.empty ()) {
253242 FAIL () << error;
254243 }
255244
245+ return LoadSource (kernel_name, target_name, binary_out);
246+ }
247+
248+ void KernelsEnvironment::LoadSource (
249+ const std::string &kernel_name, const std::string &target_name,
250+ std::shared_ptr<std::vector<char >> &binary_out) {
251+ std::string source_path =
252+ instance->getKernelSourcePath (kernel_name, target_name);
253+
256254 if (cached_kernels.find (source_path) != cached_kernels.end ()) {
257255 binary_out = cached_kernels[source_path];
258256 return ;
@@ -263,7 +261,10 @@ void KernelsEnvironment::LoadSource(
263261 std::ios::binary | std::ios::in | std::ios::ate);
264262
265263 if (!source_file.is_open ()) {
266- FAIL () << " failed opening kernel path: " + source_path;
264+ FAIL () << " failed opening kernel path: " + source_path
265+ << " \n Note: make sure that UR_CONFORMANCE_TARGET_TRIPLES includes "
266+ << ' \' ' << target_name << ' \' '
267+ << " and that device binaries have been built." ;
267268 }
268269
269270 size_t source_size = static_cast <size_t >(source_file.tellg ());
0 commit comments