1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
/*
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/rtas/rtas.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/string.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
namespace L0 {
const std::string zeRTASBuilderCreateExpImpl = "zeRTASBuilderCreateExpImpl";
const std::string zeRTASBuilderDestroyExpImpl = "zeRTASBuilderDestroyExpImpl";
const std::string zeRTASBuilderGetBuildPropertiesExpImpl = "zeRTASBuilderGetBuildPropertiesExpImpl";
const std::string zeRTASBuilderBuildExpImpl = "zeRTASBuilderBuildExpImpl";
const std::string zeDriverRTASFormatCompatibilityCheckExpImpl = "zeDriverRTASFormatCompatibilityCheckExpImpl";
const std::string zeRTASParallelOperationCreateExpImpl = "zeRTASParallelOperationCreateExpImpl";
const std::string zeRTASParallelOperationDestroyExpImpl = "zeRTASParallelOperationDestroyExpImpl";
const std::string zeRTASParallelOperationGetPropertiesExpImpl = "zeRTASParallelOperationGetPropertiesExpImpl";
const std::string zeRTASParallelOperationJoinExpImpl = "zeRTASParallelOperationJoinExpImpl";
pRTASBuilderCreateExpImpl builderCreateExpImpl;
pRTASBuilderDestroyExpImpl builderDestroyExpImpl;
pRTASBuilderGetBuildPropertiesExpImpl builderGetBuildPropertiesExpImpl;
pRTASBuilderBuildExpImpl builderBuildExpImpl;
pDriverRTASFormatCompatibilityCheckExpImpl formatCompatibilityCheckExpImpl;
pRTASParallelOperationCreateExpImpl parallelOperationCreateExpImpl;
pRTASParallelOperationDestroyExpImpl parallelOperationDestroyExpImpl;
pRTASParallelOperationGetPropertiesExpImpl parallelOperationGetPropertiesExpImpl;
pRTASParallelOperationJoinExpImpl parallelOperationJoinExpImpl;
bool RTASBuilder::loadEntryPoints(NEO::OsLibrary *libraryHandle) {
bool ok = getSymbolAddr(libraryHandle, zeRTASBuilderCreateExpImpl, builderCreateExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderDestroyExpImpl, builderDestroyExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderGetBuildPropertiesExpImpl, builderGetBuildPropertiesExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderBuildExpImpl, builderBuildExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeDriverRTASFormatCompatibilityCheckExpImpl, formatCompatibilityCheckExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationCreateExpImpl, parallelOperationCreateExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationDestroyExpImpl, parallelOperationDestroyExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationGetPropertiesExpImpl, parallelOperationGetPropertiesExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationJoinExpImpl, parallelOperationJoinExpImpl);
return ok;
}
ze_result_t RTASBuilder::getProperties(const ze_rtas_builder_build_op_exp_desc_t *args,
ze_rtas_builder_exp_properties_t *pProp) {
return builderGetBuildPropertiesExpImpl(this->handleImpl, args, pProp);
}
ze_result_t RTASBuilder::build(const ze_rtas_builder_build_op_exp_desc_t *args,
void *pScratchBuffer, size_t scratchBufferSizeBytes,
void *pRtasBuffer, size_t rtasBufferSizeBytes,
ze_rtas_parallel_operation_exp_handle_t hParallelOperation,
void *pBuildUserPtr, ze_rtas_aabb_exp_t *pBounds,
size_t *pRtasBufferSizeBytes) {
RTASParallelOperation *parallelOperation = RTASParallelOperation::fromHandle(hParallelOperation);
return builderBuildExpImpl(this->handleImpl,
args,
pScratchBuffer, scratchBufferSizeBytes,
pRtasBuffer, rtasBufferSizeBytes,
parallelOperation->handleImpl,
pBuildUserPtr, pBounds,
pRtasBufferSizeBytes);
}
ze_result_t DriverHandleImp::formatRTASCompatibilityCheck(ze_rtas_format_exp_t rtasFormatA,
ze_rtas_format_exp_t rtasFormatB) {
ze_result_t result = this->loadRTASLibrary();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
return formatCompatibilityCheckExpImpl(this->toHandle(), rtasFormatA, rtasFormatB);
}
ze_result_t DriverHandleImp::createRTASBuilder(const ze_rtas_builder_exp_desc_t *desc,
ze_rtas_builder_exp_handle_t *phBuilder) {
ze_result_t result = this->loadRTASLibrary();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
auto pRTASBuilder = std::make_unique<RTASBuilder>();
result = builderCreateExpImpl(this->toHandle(), desc, &pRTASBuilder->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*phBuilder = pRTASBuilder.release();
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASBuilder::destroy() {
ze_result_t result = builderDestroyExpImpl(this->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
delete this;
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::loadRTASLibrary() {
std::lock_guard<std::mutex> lock(this->rtasLock);
if (this->rtasLibraryUnavailable == true) {
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
}
if (this->rtasLibraryHandle == nullptr) {
this->rtasLibraryHandle = std::unique_ptr<NEO::OsLibrary>(NEO::OsLibrary::loadFunc(RTASBuilder::rtasLibraryName));
if (this->rtasLibraryHandle == nullptr || RTASBuilder::loadEntryPoints(this->rtasLibraryHandle.get()) == false) {
this->rtasLibraryUnavailable = true;
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Failed to load Ray Tracing Support Library %s\n", RTASBuilder::rtasLibraryName.c_str());
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
}
}
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::createRTASParallelOperation(ze_rtas_parallel_operation_exp_handle_t *phParallelOperation) {
ze_result_t result = this->loadRTASLibrary();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
auto pRTASParallelOperation = std::make_unique<RTASParallelOperation>();
result = parallelOperationCreateExpImpl(this->toHandle(), &pRTASParallelOperation->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*phParallelOperation = pRTASParallelOperation.release();
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASParallelOperation::destroy() {
ze_result_t result = parallelOperationDestroyExpImpl(this->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
delete this;
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASParallelOperation::getProperties(ze_rtas_parallel_operation_exp_properties_t *pProperties) {
return parallelOperationGetPropertiesExpImpl(this->handleImpl, pProperties);
}
ze_result_t RTASParallelOperation::join() {
return parallelOperationJoinExpImpl(this->handleImpl);
}
} // namespace L0
|