2020-03-06 18:09:57 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-03-19 13:21:57 +08:00
|
|
|
#include "level_zero/core/source/module/module.h"
|
2020-03-06 18:09:57 +08:00
|
|
|
#include <level_zero/ze_api.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleCreate(
|
|
|
|
ze_device_handle_t hDevice,
|
|
|
|
const ze_module_desc_t *desc,
|
|
|
|
ze_module_handle_t *phModule,
|
|
|
|
ze_module_build_log_handle_t *phBuildLog) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Device::fromHandle(hDevice)->createModule(desc, phModule, phBuildLog);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleDestroy(
|
|
|
|
ze_module_handle_t hModule) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Module::fromHandle(hModule)->destroy();
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleBuildLogDestroy(
|
|
|
|
ze_module_build_log_handle_t hModuleBuildLog) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::ModuleBuildLog::fromHandle(hModuleBuildLog)->destroy();
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleBuildLogGetString(
|
|
|
|
ze_module_build_log_handle_t hModuleBuildLog,
|
|
|
|
size_t *pSize,
|
|
|
|
char *pBuildLog) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::ModuleBuildLog::fromHandle(hModuleBuildLog)->getString(pSize, pBuildLog);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleGetNativeBinary(
|
|
|
|
ze_module_handle_t hModule,
|
|
|
|
size_t *pSize,
|
|
|
|
uint8_t *pModuleNativeBinary) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Module::fromHandle(hModule)->getNativeBinary(pSize, pModuleNativeBinary);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleGetGlobalPointer(
|
|
|
|
ze_module_handle_t hModule,
|
|
|
|
const char *pGlobalName,
|
|
|
|
void **pptr) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Module::fromHandle(hModule)->getGlobalPointer(pGlobalName, pptr);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleGetKernelNames(
|
|
|
|
ze_module_handle_t hModule,
|
|
|
|
uint32_t *pCount,
|
|
|
|
const char **pNames) {
|
|
|
|
return L0::Module::fromHandle(hModule)->getKernelNames(pCount, pNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelCreate(
|
|
|
|
ze_module_handle_t hModule,
|
|
|
|
const ze_kernel_desc_t *desc,
|
|
|
|
ze_kernel_handle_t *phFunction) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Module::fromHandle(hModule)->createKernel(desc, phFunction);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelDestroy(
|
|
|
|
ze_kernel_handle_t hKernel) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->destroy();
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeModuleGetFunctionPointer(
|
|
|
|
ze_module_handle_t hModule,
|
|
|
|
const char *pKernelName,
|
|
|
|
void **pfnFunction) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Module::fromHandle(hModule)->getFunctionPointer(pKernelName, pfnFunction);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelSetGroupSize(
|
2020-03-27 07:48:10 +08:00
|
|
|
ze_kernel_handle_t hKernel,
|
2020-03-06 18:09:57 +08:00
|
|
|
uint32_t groupSizeX,
|
|
|
|
uint32_t groupSizeY,
|
|
|
|
uint32_t groupSizeZ) {
|
2020-03-27 07:48:10 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->setGroupSize(groupSizeX, groupSizeY, groupSizeZ);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelSuggestGroupSize(
|
2020-03-27 07:48:10 +08:00
|
|
|
ze_kernel_handle_t hKernel,
|
2020-03-06 18:09:57 +08:00
|
|
|
uint32_t globalSizeX,
|
|
|
|
uint32_t globalSizeY,
|
|
|
|
uint32_t globalSizeZ,
|
|
|
|
uint32_t *groupSizeX,
|
|
|
|
uint32_t *groupSizeY,
|
|
|
|
uint32_t *groupSizeZ) {
|
2020-03-27 07:48:10 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->suggestGroupSize(globalSizeX, globalSizeY, globalSizeZ, groupSizeX, groupSizeY, groupSizeZ);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelSuggestMaxCooperativeGroupCount(
|
|
|
|
ze_kernel_handle_t hKernel,
|
|
|
|
uint32_t *totalGroupCount) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->suggestMaxCooperativeGroupCount(totalGroupCount);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelSetArgumentValue(
|
2020-03-27 07:48:10 +08:00
|
|
|
ze_kernel_handle_t hKernel,
|
2020-03-06 18:09:57 +08:00
|
|
|
uint32_t argIndex,
|
|
|
|
size_t argSize,
|
|
|
|
const void *pArgValue) {
|
2020-03-27 07:48:10 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->setArgumentValue(argIndex, argSize, pArgValue);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelSetAttribute(
|
|
|
|
ze_kernel_handle_t hKernel,
|
|
|
|
ze_kernel_attribute_t attr,
|
|
|
|
uint32_t size,
|
|
|
|
const void *pValue) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->setAttribute(attr, size, pValue);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelGetAttribute(
|
|
|
|
ze_kernel_handle_t hKernel,
|
|
|
|
ze_kernel_attribute_t attr,
|
|
|
|
uint32_t *pSize,
|
|
|
|
void *pValue) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->getAttribute(attr, pSize, pValue);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelSetIntermediateCacheConfig(
|
|
|
|
ze_kernel_handle_t hKernel,
|
|
|
|
ze_cache_config_t cacheConfig) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->setIntermediateCacheConfig(cacheConfig);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeKernelGetProperties(
|
|
|
|
ze_kernel_handle_t hKernel,
|
|
|
|
ze_kernel_properties_t *pKernelProperties) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::Kernel::fromHandle(hKernel)->getProperties(pKernelProperties);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeCommandListAppendLaunchKernel(
|
|
|
|
ze_command_list_handle_t hCommandList,
|
2020-03-27 07:48:10 +08:00
|
|
|
ze_kernel_handle_t hKernel,
|
2020-03-06 18:09:57 +08:00
|
|
|
const ze_group_count_t *pLaunchFuncArgs,
|
|
|
|
ze_event_handle_t hSignalEvent,
|
|
|
|
uint32_t numWaitEvents,
|
|
|
|
ze_event_handle_t *phWaitEvents) {
|
2020-03-27 07:48:10 +08:00
|
|
|
return L0::CommandList::fromHandle(hCommandList)->appendLaunchKernel(hKernel, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeCommandListAppendLaunchCooperativeKernel(
|
|
|
|
ze_command_list_handle_t hCommandList,
|
|
|
|
ze_kernel_handle_t hKernel,
|
|
|
|
const ze_group_count_t *pLaunchFuncArgs,
|
|
|
|
ze_event_handle_t hSignalEvent,
|
|
|
|
uint32_t numWaitEvents,
|
|
|
|
ze_event_handle_t *phWaitEvents) {
|
2020-03-11 14:19:06 +08:00
|
|
|
return L0::CommandList::fromHandle(hCommandList)->appendLaunchCooperativeKernel(hKernel, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeCommandListAppendLaunchKernelIndirect(
|
|
|
|
ze_command_list_handle_t hCommandList,
|
2020-03-27 07:48:10 +08:00
|
|
|
ze_kernel_handle_t hKernel,
|
2020-03-06 18:09:57 +08:00
|
|
|
const ze_group_count_t *pLaunchArgumentsBuffer,
|
|
|
|
ze_event_handle_t hSignalEvent,
|
|
|
|
uint32_t numWaitEvents,
|
|
|
|
ze_event_handle_t *phWaitEvents) {
|
2020-03-27 07:48:10 +08:00
|
|
|
return L0::CommandList::fromHandle(hCommandList)->appendLaunchKernelIndirect(hKernel, pLaunchArgumentsBuffer, hSignalEvent, numWaitEvents, phWaitEvents);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__zedllexport ze_result_t __zecall
|
|
|
|
zeCommandListAppendLaunchMultipleKernelsIndirect(
|
|
|
|
ze_command_list_handle_t hCommandList,
|
2020-03-27 07:48:10 +08:00
|
|
|
uint32_t numKernels,
|
|
|
|
ze_kernel_handle_t *phKernels,
|
2020-03-06 18:09:57 +08:00
|
|
|
const uint32_t *pCountBuffer,
|
|
|
|
const ze_group_count_t *pLaunchArgumentsBuffer,
|
|
|
|
ze_event_handle_t hSignalEvent,
|
|
|
|
uint32_t numWaitEvents,
|
|
|
|
ze_event_handle_t *phWaitEvents) {
|
2020-03-27 07:48:10 +08:00
|
|
|
return L0::CommandList::fromHandle(hCommandList)->appendLaunchMultipleKernelsIndirect(numKernels, phKernels, pCountBuffer, pLaunchArgumentsBuffer, hSignalEvent, numWaitEvents, phWaitEvents);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
2020-03-11 14:19:06 +08:00
|
|
|
|
|
|
|
} // extern "C"
|