Skip to content

Commit

Permalink
removed internal rtas builder, made EMBREE_SYCL_L0_RTAS_BUILDER the d…
Browse files Browse the repository at this point in the history
…efault
  • Loading branch information
dopitz committed Jan 20, 2025
1 parent 982feab commit 04715ce
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 131 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@ IF (EMBREE_SYCL_SUPPORT)
ENDIF()
ENDIF()

CMAKE_DEPENDENT_OPTION(EMBREE_SYCL_L0_RTAS_BUILDER "Enable Level Zero RTAS builder" ON "EMBREE_SYCL_SUPPORT" OFF)
IF (EMBREE_SYCL_L0_RTAS_BUILDER)
ADD_DEFINITIONS("-DEMBREE_SYCL_L0_RTAS_BUILDER")
ENDIF()

OPTION(EMBREE_RAY_MASK "Enables ray mask support." ON)
OPTION(EMBREE_BACKFACE_CULLING "Enables backface culling.")
OPTION(EMBREE_BACKFACE_CULLING_CURVES "Enables backface culling for curve primitives." OFF)
Expand Down
2 changes: 0 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "AVX512",
"EMBREE_USE_GOOGLE_BENCHMARK": "ON",
Expand Down Expand Up @@ -83,7 +82,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "AVX512"
}
Expand Down
11 changes: 2 additions & 9 deletions kernels/common/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ namespace embree
if (result != ZE_RESULT_SUCCESS)
throw_RTCError(RTC_ERROR_UNKNOWN, "zeDriverGetExtensionProperties failed");

#if defined(EMBREE_SYCL_L0_RTAS_BUILDER)
bool ze_rtas_builder = false;
for (uint32_t i=0; i<extensions.size(); i++)
{
Expand All @@ -672,22 +671,16 @@ namespace embree
if (!ze_rtas_builder)
throw_RTCError(RTC_ERROR_LEVEL_ZERO_RAYTRACING_SUPPORT_MISSING, "ZE_experimental_rtas_builder extension not found. Please install a recent driver. On Linux, make sure that the package intel-level-zero-gpu-raytracing is installed");

result = ZeWrapper::initRTASBuilder(hDriver,ZeWrapper::LEVEL_ZERO);
result = ZeWrapper::initRTASBuilder(hDriver);
if (result == ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE) {
throw_RTCError(RTC_ERROR_LEVEL_ZERO_RAYTRACING_SUPPORT_MISSING, "cannot load ZE_experimental_rtas_builder extension. Please install a recent driver. On Linux, make sure that the package intel-level-zero-gpu-raytracing is installed");
}
if (result != ZE_RESULT_SUCCESS)
throw_RTCError(RTC_ERROR_UNKNOWN, "cannot initialize ZE_experimental_rtas_builder extension");
#else
ZeWrapper::initRTASBuilder(hDriver,ZeWrapper::INTERNAL);
#endif

if (State::verbosity(1))
{
if (ZeWrapper::rtas_builder == ZeWrapper::INTERNAL)
std::cout << " Internal RTAS Builder" << std::endl;
else
std::cout << " Level Zero RTAS Builder" << std::endl;
std::cout << " Level Zero RTAS Builder" << std::endl;
}

/* check if extension library can get loaded */
Expand Down
6 changes: 0 additions & 6 deletions kernels/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ target_include_directories(ze_wrapper INTERFACE $<BUILD_INTERFACE:${CMAKE_CURREN
TARGET_COMPILE_DEFINITIONS(ze_wrapper PRIVATE ZE_LOADER_NAME_LINUX="${EMBREE_ZE_LOADER_RUNTIME_LINK_NAME_LINUX}")
TARGET_COMPILE_DEFINITIONS(ze_wrapper PRIVATE ZE_LOADER_NAME_WINDOWS="${EMBREE_ZE_LOADER_RUNTIME_LINK_NAME_WINDOWS}")

IF (NOT EMBREE_SYCL_L0_RTAS_BUILDER)
TARGET_LINK_LIBRARIES(ze_wrapper PUBLIC embree_rthwif)
ELSE()
TARGET_COMPILE_DEFINITIONS(ze_wrapper PRIVATE ZE_RAYTRACING_DISABLE_INTERNAL_BUILDER)
ENDIF()

SET_PROPERTY(TARGET ze_wrapper PROPERTY FOLDER common)
SET_PROPERTY(TARGET ze_wrapper APPEND PROPERTY COMPILE_FLAGS " ${FLAGS_LOWEST}")

Expand Down
79 changes: 6 additions & 73 deletions kernels/level_zero/ze_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <mutex>
#include <string.h>

ZeWrapper::RTAS_BUILD_MODE ZeWrapper::rtas_builder = ZeWrapper::AUTO;
bool ZeWrapper::rtas_builder_selected = false;

static std::mutex zeWrapperMutex;
static void* handle = nullptr;
Expand Down Expand Up @@ -90,7 +90,8 @@ ZeWrapper::~ZeWrapper() {

ze_result_t selectLevelZeroRTASBuilder(ze_driver_handle_t hDriver)
{
if (ZeWrapper::rtas_builder == ZeWrapper::LEVEL_ZERO)
/* only select rtas builder once! */
if (ZeWrapper::rtas_builder_selected)
return ZE_RESULT_SUCCESS;

auto zeRTASBuilderCreateExpTemp = find_symbol<decltype(zeRTASBuilderCreateExp)*>(handle,"zeRTASBuilderCreateExp");
Expand Down Expand Up @@ -119,33 +120,10 @@ ze_result_t selectLevelZeroRTASBuilder(ze_driver_handle_t hDriver)
zeRTASParallelOperationGetPropertiesExpInternal = find_symbol<decltype(zeRTASParallelOperationGetPropertiesExp)*>(handle,"zeRTASParallelOperationGetPropertiesExp");
zeRTASParallelOperationJoinExpInternal = find_symbol<decltype(zeRTASParallelOperationJoinExp)*>(handle,"zeRTASParallelOperationJoinExp");

ZeWrapper::rtas_builder = ZeWrapper::LEVEL_ZERO;
ZeWrapper::rtas_builder_selected = true;
return ZE_RESULT_SUCCESS;
}

void selectInternalRTASBuilder()
{
#if defined(ZE_RAYTRACING_DISABLE_INTERNAL_BUILDER)
throw std::runtime_error("internal builder disabled at compile time");
#else
if (ZeWrapper::rtas_builder == ZeWrapper::INTERNAL)
return;

zeRTASBuilderCreateExpInternal = &zeRTASBuilderCreateExp;
zeRTASBuilderDestroyExpInternal = &zeRTASBuilderDestroyExp;
zeDriverRTASFormatCompatibilityCheckExpInternal = &zeDriverRTASFormatCompatibilityCheckExp;
zeRTASBuilderGetBuildPropertiesExpInternal = &zeRTASBuilderGetBuildPropertiesExp;
zeRTASBuilderBuildExpInternal = &zeRTASBuilderBuildExp;

zeRTASParallelOperationCreateExpInternal = &zeRTASParallelOperationCreateExp;
zeRTASParallelOperationDestroyExpInternal = &zeRTASParallelOperationDestroyExp;
zeRTASParallelOperationGetPropertiesExpInternal = &zeRTASParallelOperationGetPropertiesExp;
zeRTASParallelOperationJoinExpInternal = &zeRTASParallelOperationJoinExp;

ZeWrapper::rtas_builder = ZeWrapper::INTERNAL;
#endif
}

ze_result_t ZeWrapper::init()
{
std::lock_guard<std::mutex> lock(zeWrapperMutex);
Expand All @@ -169,42 +147,12 @@ ze_result_t ZeWrapper::init()
return ZE_RESULT_SUCCESS;
}

ze_result_t ZeWrapper::initRTASBuilder(ze_driver_handle_t hDriver, RTAS_BUILD_MODE rtas_build_mode)
ze_result_t ZeWrapper::initRTASBuilder(ze_driver_handle_t hDriver)
{
std::lock_guard<std::mutex> lock(zeWrapperMutex);

/* only select rtas builder once! */
if (rtas_builder != RTAS_BUILD_MODE::AUTO)
{
if (rtas_build_mode == RTAS_BUILD_MODE::AUTO)
return ZE_RESULT_SUCCESS;

if (rtas_builder == rtas_build_mode)
return ZE_RESULT_SUCCESS;

return ZE_RESULT_ERROR_UNKNOWN;
}

try {

if (rtas_build_mode == RTAS_BUILD_MODE::AUTO)
{
try {
if (selectLevelZeroRTASBuilder(hDriver) != ZE_RESULT_SUCCESS)
selectInternalRTASBuilder();
} catch (std::exception& e) {
selectInternalRTASBuilder();
}
}

else if (rtas_build_mode == RTAS_BUILD_MODE::INTERNAL)
selectInternalRTASBuilder();

else if (rtas_build_mode == RTAS_BUILD_MODE::LEVEL_ZERO)
return selectLevelZeroRTASBuilder(hDriver);

else
throw std::runtime_error("internal error");
return selectLevelZeroRTASBuilder(hDriver);
}
catch (std::exception& e) {
return ZE_RESULT_ERROR_UNKNOWN;
Expand Down Expand Up @@ -354,21 +302,6 @@ ze_result_t ZeWrapper::zeDeviceGetProperties(ze_device_handle_t ze_handle, ze_de
{
if (!handle || !zeDeviceGetPropertiesInternal)
throw std::runtime_error("ZeWrapper not initialized, call ZeWrapper::init() first.");

if (ZeWrapper::rtas_builder == ZeWrapper::INTERNAL)
{
if (props->pNext && ((ze_base_properties_t*)props->pNext)->stype == ZE_STRUCTURE_TYPE_RTAS_DEVICE_EXP_PROPERTIES)
{
ze_result_t result = zeDeviceGetRTASPropertiesExp(ze_handle, (ze_rtas_device_exp_properties_t*)props->pNext);
if (result != ZE_RESULT_SUCCESS) return result;

void* pNext = props->pNext;
props->pNext = ((ze_base_properties_t*)props->pNext)->pNext;
result = zeDeviceGetPropertiesInternal(ze_handle, props);
props->pNext = pNext;
return result;
}
}

return zeDeviceGetPropertiesInternal(ze_handle, props);
}
Expand Down
10 changes: 2 additions & 8 deletions kernels/level_zero/ze_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ typedef struct _ze_rtas_builder_build_op_debug_exp_desc_t

struct ZeWrapper
{
enum RTAS_BUILD_MODE {
AUTO = 0, // try L0 implementation first and fallback to internal implementation
INTERNAL = 1, // use internal RTAS build implementation
LEVEL_ZERO = 2, // use Level Zero provided RTAS build implementation
};

~ZeWrapper();

static ze_result_t init();
static ze_result_t initRTASBuilder(ze_driver_handle_t hDriver, RTAS_BUILD_MODE rtas_build_mode = RTAS_BUILD_MODE::AUTO);
static ze_result_t initRTASBuilder(ze_driver_handle_t hDriver);

static ze_result_t zeMemFree(ze_context_handle_t, void*);
static ze_result_t zeMemAllocHost(ze_context_handle_t, const ze_host_mem_alloc_desc_t*, size_t, size_t, void**);
Expand Down Expand Up @@ -66,6 +60,6 @@ struct ZeWrapper
static ze_result_t zeRTASParallelOperationGetPropertiesExp( ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ze_rtas_parallel_operation_exp_properties_t* pProperties );
static ze_result_t zeRTASParallelOperationJoinExp( ze_rtas_parallel_operation_exp_handle_t hParallelOperation);

static RTAS_BUILD_MODE rtas_builder;
static bool rtas_builder_selected;
};

6 changes: 0 additions & 6 deletions kernels/sycl/rthwif_embree_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,22 @@ namespace embree
if (result != ZE_RESULT_SUCCESS) return -1;

bool ze_extension_ray_tracing = false;
#if defined(EMBREE_SYCL_L0_RTAS_BUILDER)
bool ze_rtas_builder = false;
#endif
for (uint32_t i=0; i<extensions.size(); i++)
{
//std::cout << extensions[i].name << " version " << extensions[i].version << std::endl;

if (strncmp("ZE_extension_raytracing",extensions[i].name,sizeof(extensions[i].name)) == 0)
ze_extension_ray_tracing = true;

#if defined(EMBREE_SYCL_L0_RTAS_BUILDER)
if (strncmp("ZE_experimental_rtas_builder",extensions[i].name,sizeof(extensions[i].name)) == 0)
ze_rtas_builder = true;
#endif
}
if (!ze_extension_ray_tracing)
return -1;

#if defined(EMBREE_SYCL_L0_RTAS_BUILDER)
if (!ze_rtas_builder)
return -1;
#endif

/* check if ray queries are supported */
ze_device_handle_t hDevice = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(sycl_device);
Expand Down
7 changes: 0 additions & 7 deletions scripts/cmake-presets/continuous.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -33,7 +32,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -51,7 +49,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithAssert",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "AVX512"
}
Expand All @@ -66,7 +63,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithAssert",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -77,7 +73,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithAssert",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -88,7 +83,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -99,7 +93,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand Down
2 changes: 0 additions & 2 deletions scripts/cmake-presets/integrate.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "AVX512"
}
Expand All @@ -127,7 +126,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand Down
7 changes: 0 additions & 7 deletions scripts/cmake-presets/nightly.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2",
"EMBREE_MAX_INSTANCE_LEVEL_COUNT": "2"
Expand All @@ -30,7 +29,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -41,7 +39,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -52,7 +49,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2",
"EMBREE_MAX_INSTANCE_LEVEL_COUNT": "2"
Expand All @@ -64,7 +60,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "SSE2"
}
Expand All @@ -75,7 +70,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "AVX512"
}
Expand All @@ -86,7 +80,6 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "ON",
"EMBREE_SYCL_AOT_DEVICES": "none",
"EMBREE_MAX_ISA": "AVX512"
}
Expand Down
1 change: 0 additions & 1 deletion scripts/cmake-presets/performance.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"EMBREE_SYCL_SUPPORT": "ON",
"EMBREE_SYCL_L0_RTAS_BUILDER" : "OFF",
"EMBREE_SYCL_AOT_DEVICES": "none"
}
}
Expand Down
Loading

0 comments on commit 04715ce

Please sign in to comment.