oneapi-src / oneapi-src/level-zero

[Error] Don't get kernel

Open
#127 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
335
Forks
140
Avg merge
12h 32m
Merged PRs (30d)
5

Description

I use the following spirv code, then I use spirv-tools library to compile the source code into binary by core.Assemble(new_code, &binary). Creating L0 Module is ok, I use zeModuleGetKernelNames to get all kernle names, but the func return 0, don't find kernle name. why?

    ; SPIR-V
    ; Version: 1.2
    ; Generator: Khronos; 22
    ; Bound: 3
    ; Schema: 0
                   OpCapability Addresses
                   OpCapability Kernel
                   OpCapability VectorAnyINTEL
                   OpCapability VectorComputeINTEL
                   OpCapability FunctionPointersINTEL
                   OpCapability FloatingPointModeINTEL
                   OpCapability Int64
                   OpCapability Vector16
                   OpCapability Int8
                   OpCapability Int16
                   OpExtension "SPV_INTEL_float_controls2"
                   OpExtension "SPV_INTEL_function_pointers"
                   OpExtension "SPV_INTEL_vector_compute"
            %ext = OpExtInstImport "OpenCL.std"
                   OpMemoryModel Physical64 OpenCL
                   OpEntryPoint Kernel %easy_func "easy_func"
           %void = OpTypeVoid
              %1 = OpTypeFunction %void
      %easy_func = OpFunction %void DontInline %1
              %2 = OpLabel
                   OpReturn
                   OpFunctionEnd

The c++ code is:

 binary.clear();
    if (!core.Assemble(new_code, &binary)) { std::cout << "assemble failure "; }
    std::cout << new_code;
    // binary = bins;

    std::ostringstream oss {std::ofstream::binary};
    oss.write(reinterpret_cast<const char *>(binary.data()),
               sizeof(binary[0]) * binary.size())
            .flush();
    isa_code_ = oss.str();

... init, create L0

ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC, nullptr,
            ZE_MODULE_FORMAT_IL_SPIRV, isa_code.size(),
            (const uint8_t *)isa_code.c_str(), "-vc-codegen -g", nullptr};

    ze_module_build_log_handle_t buildlog;
    L0_SAFE_CALL(
            zeModuleCreate(context, device, &moduleDesc, &program_, &buildlog));
    // Only save build logs for module creation errors.
    {
        size_t szLog = 0;
        std::vector<char> str_log(szLog);
        zeModuleBuildLogGetString(buildlog, &szLog, str_log.data());
        std::string build_log(str_log.data(), str_log.size());
        std::cout << "build log: \n" << build_log;
    }
    zeModuleBuildLogDestroy(buildlog);
    uint32_t pCount;
    const char *pName = nullptr;
    zeModuleGetKernelNames(program_, &pCount, &pName);
    std::cout << "kernel number: " << pCount;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided SPIR-V assembly and module creation flow using core.Assemble, zeModuleCreate, and zeModuleGetKernelNames. Inspect the module build log and the returned kernel count and name pointer; done means identifying why the entry point is not enumerated or documenting the required correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.