oneapi-src / level-zero

oneAPI Level Zero Specification Headers and Loader
https://spec.oneapi.com/versions/latest/elements/l0/source/index.html
MIT License
218 stars 96 forks source link

Usage of _ze_module_desc_t #6

Closed aarontcopal2 closed 4 years ago

aarontcopal2 commented 4 years ago

To create a Module, you need to pass a module description. (link)

typedef struct _ze_module_desc_t
{
    ze_module_desc_version_t version;
    ze_module_format_t format;
    size_t inputSize;                               ///< [in] size of input IL or ISA from pInputModule.
    const uint8_t* pInputModule;                    ///< [in] pointer to IL or ISA
    const char* pBuildFlags;
    const ze_module_constants_t* pConstants;
} ze_module_desc_t;

I'm having trouble determining the 3rd and 4th argument. Could someone provide me code samples of ze_module_desc_t for both "ZE_MODULE_FORMAT_IL_SPIRV" and "ZE_MODULE_FORMAT_NATIVE" format.

jandres742 commented 4 years ago

pInputModule should point to the either the SPIRV or BIN code of the kernel you want to offload to the GPU, and with format you indicate the format you are passing. The SPIRV or BIN code is generated, for instance, using clang, as described here https://github.com/KhronosGroup/SPIR/tree/spirv-1.1.

We are planning to release samples that can be used as reference. Please keep an eye on https://github.com/oneapi-src/level-zero-tests, for Level Zero content

aarontcopal2 commented 4 years ago

Thank you. Could you close the issue when the samples are pushed to the repo?

jandres742 commented 4 years ago

Sure. Once they are available, I will paste here a link to a sample and we can close it.

jandres742 commented 4 years ago

https://github.com/oneapi-src/level-zero-tests contains now samples you can use as reference. In your case, please take a look at test_module.cpp

aarontcopal2 commented 4 years ago

@jandres742 , thanks for the link. You can close the issue :)