From 460e3f7e748c6a2fab5c0db330bb8643885eca5a Mon Sep 17 00:00:00 2001 From: "Murillo Rojas, Luis" Date: Thu, 14 Nov 2024 14:57:07 -0800 Subject: [PATCH] Move enable JIT cache function to SYCL utils --- cpp/open3d/core/SYCLUtils.cpp | 10 ++++++++++ cpp/open3d/core/SYCLUtils.h | 3 +++ cpp/open3d/t/geometry/RaycastingScene.cpp | 14 -------------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cpp/open3d/core/SYCLUtils.cpp b/cpp/open3d/core/SYCLUtils.cpp index ae8ccf63b7d..5f7acaac964 100644 --- a/cpp/open3d/core/SYCLUtils.cpp +++ b/cpp/open3d/core/SYCLUtils.cpp @@ -225,6 +225,16 @@ std::vector GetAvailableSYCLDevices() { #endif } +void enablePersistentJITCache() { +#if defined(_WIN32) + _putenv_s("SYCL_CACHE_PERSISTENT", "1"); + _putenv_s("SYCL_CACHE_DIR", "cache"); +#else + setenv("SYCL_CACHE_PERSISTENT", "1", 1); + setenv("SYCL_CACHE_DIR", "cache", 1); +#endif +} + } // namespace sy } // namespace core } // namespace open3d diff --git a/cpp/open3d/core/SYCLUtils.h b/cpp/open3d/core/SYCLUtils.h index a1cb74426fb..a149bb7dcb5 100644 --- a/cpp/open3d/core/SYCLUtils.h +++ b/cpp/open3d/core/SYCLUtils.h @@ -40,6 +40,9 @@ bool IsDeviceAvailable(const Device& device); /// Return a list of available SYCL devices. std::vector GetAvailableSYCLDevices(); +/// Enables the JIT cache for SYCL. +void enablePersistentJITCache(); + } // namespace sy } // namespace core } // namespace open3d diff --git a/cpp/open3d/t/geometry/RaycastingScene.cpp b/cpp/open3d/t/geometry/RaycastingScene.cpp index f9ebbd6219a..9bd07f2bea7 100644 --- a/cpp/open3d/t/geometry/RaycastingScene.cpp +++ b/cpp/open3d/t/geometry/RaycastingScene.cpp @@ -170,18 +170,6 @@ typedef Eigen::AlignedVector3 Vec3fa; typedef Eigen::Matrix Vec2f; typedef Eigen::Vector3f Vec3f; -#ifdef BUILD_SYCL_MODULE -void enablePersistentJITCache() { -#if defined(_WIN32) - _putenv_s("SYCL_CACHE_PERSISTENT", "1"); - _putenv_s("SYCL_CACHE_DIR", "cache"); -#else - setenv("SYCL_CACHE_PERSISTENT", "1", 1); - setenv("SYCL_CACHE_DIR", "cache", 1); -#endif -} -#endif - // Error function called by embree. void ErrorFunction(void* userPtr, enum RTCError error, const char* str) { open3d::utility::LogError("Embree error: {} {}", rtcGetErrorString(error), @@ -452,8 +440,6 @@ struct RaycastingScene::SYCLImpl : public RaycastingScene::Impl { sycl::device sycl_device_; void InitializeDevice() { - enablePersistentJITCache(); - try { sycl_device_ = sycl::device(rtcSYCLDeviceSelector); } catch (std::exception& e) {