MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / ze_executable_object

Method ze_executable_object

src/runtime/ze/ze_code_object.cpp:43–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43ze_executable_object::ze_executable_object(ze_context_handle_t ctx,
44 ze_device_handle_t dev,
45 hcf_object_id source,
46 ze_source_format fmt,
47 const std::string &code_image)
48 : _source{source}, _format{fmt}, _ctx{ctx}, _dev{dev}, _module{nullptr}
49{
50
51 ze_module_desc_t desc;
52 desc.stype = ZE_STRUCTURE_TYPE_MODULE_DESC;
53 desc.pNext = nullptr;
54
55 if(_format == ze_source_format::spirv) {
56 desc.format = ZE_MODULE_FORMAT_IL_SPIRV;
57 } else {
58 _build_status = register_error(
59 __acpp_here(), error_info{"ze_executable_object: Invalid module format"});
60 return;
61 }
62
63 desc.inputSize = code_image.size();
64 desc.pInputModule = reinterpret_cast<const uint8_t *>(code_image.c_str());
65 // TODO: We may want to expose some of the build flags, e.g. to
66 // enable greater than 4GB buffers
67 desc.pBuildFlags = nullptr;
68 desc.pConstants = nullptr;
69
70 ze_module_build_log_handle_t build_log;
71 ze_result_t err = zeModuleCreate(ctx, dev, &desc, &_module, &build_log);
72
73 if(err != ZE_RESULT_SUCCESS) {
74 std::size_t build_log_size;
75 std::string build_log_content;
76
77 if (zeModuleBuildLogGetString(build_log, &build_log_size, nullptr) ==
78 ZE_RESULT_SUCCESS) {
79 std::vector<char> build_log_buffer(build_log_size);
80 if (zeModuleBuildLogGetString(build_log, &build_log_size,
81 build_log_buffer.data()) ==
82 ZE_RESULT_SUCCESS) {
83 build_log_content = std::string{build_log_buffer.data(), build_log_buffer.size()};
84 }
85 }
86
87 std::string msg = "ze_executable_object: Couldn't create module handle";
88 if(!build_log_content.empty()) {
89 msg += "\nBuild log: ";
90 msg += build_log_content;
91 }
92 _build_status = register_error(__acpp_here(),
93 error_info{msg,
94 error_code{"ze", static_cast<int>(err)}});
95 zeModuleBuildLogDestroy(build_log);
96 return;
97 } else {
98 zeModuleBuildLogDestroy(build_log);
99 _build_status = make_success();
100 }

Callers

nothing calls this directly

Calls 5

register_errorFunction · 0.85
make_successFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected