Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] Don't get kernel #127

Open
muzhailong opened this issue Nov 17, 2023 · 1 comment
Open

[Error] Don't get kernel #127

muzhailong opened this issue Nov 17, 2023 · 1 comment

Comments

@muzhailong
Copy link

muzhailong commented Nov 17, 2023

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;
@eero-t
Copy link

eero-t commented Nov 21, 2023

This issue may belong to the L0 backend implementation you're using [1], rather than here in the frontend/loader project.

[1] For Intel HW, L0 backend is implemented in following project: https://github.com/intel/compute-runtime/

PS. You may need to state the versions of components in the stack you're using (HW, FW, kernel and user space driver versions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants