From 1dd8ea1665a19ccd77159363a34f131562283935 Mon Sep 17 00:00:00 2001 From: Julian Oppermann Date: Wed, 24 Jan 2024 04:07:34 -1000 Subject: [PATCH 1/3] [SYCL][Fusion][NoSTL] Use free functions for configuration management (#12445) Untangle the interaction between options and the `Config` class, and hide `Config` (which needs to store options in a map) from the KF interface. The idea is to introduce free functions to interact with the `thread_local` instance of `Config` held by the existing `ConfigHelper` class, instead of letting the client construct the `Config` object and handing it to over `ConfigHelper` for storing it. _This PR is part of a series of changes to remove uses of STL classes in the kernel fusion interface to prevent ABI issues in the future._ Signed-off-by: Julian Oppermann --- .../jit-compiler/include/KernelFusion.h | 27 +++++-- sycl-fusion/jit-compiler/include/Options.h | 70 +++++-------------- sycl-fusion/jit-compiler/lib/KernelFusion.cpp | 11 +-- .../jit-compiler/lib/helper/ConfigHelper.h | 35 +++++++++- sycl/source/detail/jit_compiler.cpp | 14 ++-- 5 files changed, 87 insertions(+), 70 deletions(-) diff --git a/sycl-fusion/jit-compiler/include/KernelFusion.h b/sycl-fusion/jit-compiler/include/KernelFusion.h index b305ddf7d9801..26166290d1348 100644 --- a/sycl-fusion/jit-compiler/include/KernelFusion.h +++ b/sycl-fusion/jit-compiler/include/KernelFusion.h @@ -54,13 +54,26 @@ class FusionResult { class KernelFusion { public: - static FusionResult fuseKernels( - Config &&JITConfig, const std::vector &KernelInformation, - const char *FusedKernelName, jit_compiler::ParamIdentList &Identities, - BarrierFlags BarriersFlags, - const std::vector - &Internalization, - const std::vector &JITConstants); + static FusionResult + fuseKernels(const std::vector &KernelInformation, + const char *FusedKernelName, + jit_compiler::ParamIdentList &Identities, + BarrierFlags BarriersFlags, + const std::vector + &Internalization, + const std::vector &JITConstants); + + /// Clear all previously set options. + static void resetConfiguration(); + + /// Set \p Opt to the value built in-place by \p As. + template static void set(Args &&...As) { + set(new Opt{std::forward(As)...}); + } + +private: + /// Take ownership of \p Option and include it in the current configuration. + static void set(OptionPtrBase *Option); }; } // namespace jit_compiler diff --git a/sycl-fusion/jit-compiler/include/Options.h b/sycl-fusion/jit-compiler/include/Options.h index 9707a72c9bc64..117e5ea68db02 100644 --- a/sycl-fusion/jit-compiler/include/Options.h +++ b/sycl-fusion/jit-compiler/include/Options.h @@ -11,77 +11,43 @@ #include "Kernel.h" -#include -#include - namespace jit_compiler { enum OptionID { VerboseOutput, EnableCaching, TargetDeviceInfo }; -class OptionPtrBase {}; - -class Config { +class OptionPtrBase { +protected: + explicit OptionPtrBase(OptionID Id) : Id(Id) {} public: - template void set(typename Opt::ValueType Value) { - Opt::set(*this, Value); - } - - template typename Opt::ValueType get() { - return Opt::get(*this); - } - -private: - std::unordered_map> OptionValues; - - void set(OptionID ID, std::unique_ptr Value) { - OptionValues[ID] = std::move(Value); - } - - OptionPtrBase *get(OptionID ID) { - if (OptionValues.count(ID)) { - return OptionValues.at(ID).get(); - } - return nullptr; - } - - template friend class OptionBase; + const OptionID Id; }; -template class OptionBase : public OptionPtrBase { -public: +template struct OptionBase : public OptionPtrBase { + static constexpr OptionID Id = ID; using ValueType = T; -protected: - static void set(Config &Cfg, T Value) { - Cfg.set(ID, - std::unique_ptr>{new OptionBase{Value}}); - } - - static const T get(Config &Cfg) { - auto *ConfigValue = Cfg.get(ID); - if (!ConfigValue) { - return T{}; - } - return static_cast *>(ConfigValue)->Value; - } + template + explicit OptionBase(Args &&...As) + : OptionPtrBase{ID}, Value{std::forward(As)...} {} -private: T Value; - - OptionBase(T Val) : Value{Val} {} - - friend Config; }; namespace option { -struct JITEnableVerbose : public OptionBase {}; +struct JITEnableVerbose : public OptionBase { + using OptionBase::OptionBase; +}; -struct JITEnableCaching : public OptionBase {}; +struct JITEnableCaching : public OptionBase { + using OptionBase::OptionBase; +}; struct JITTargetInfo - : public OptionBase {}; + : public OptionBase { + using OptionBase::OptionBase; +}; } // namespace option } // namespace jit_compiler diff --git a/sycl-fusion/jit-compiler/lib/KernelFusion.cpp b/sycl-fusion/jit-compiler/lib/KernelFusion.cpp index 052563e328b94..3f7691ed0fadf 100644 --- a/sycl-fusion/jit-compiler/lib/KernelFusion.cpp +++ b/sycl-fusion/jit-compiler/lib/KernelFusion.cpp @@ -71,14 +71,11 @@ static bool isTargetFormatSupported(BinaryFormat TargetFormat) { } FusionResult KernelFusion::fuseKernels( - Config &&JITConfig, const std::vector &KernelInformation, + const std::vector &KernelInformation, const char *FusedKernelName, ParamIdentList &Identities, BarrierFlags BarriersFlags, const std::vector &Internalization, const std::vector &Constants) { - // Initialize the configuration helper to make the options for this invocation - // available (on a per-thread basis). - ConfigHelper::setConfig(std::move(JITConfig)); std::vector KernelsToFuse; llvm::transform(KernelInformation, std::back_inserter(KernelsToFuse), @@ -194,3 +191,9 @@ FusionResult KernelFusion::fuseKernels( return FusionResult{FusedKernelInfo}; } + +void KernelFusion::resetConfiguration() { ConfigHelper::reset(); } + +void KernelFusion::set(OptionPtrBase *Option) { + ConfigHelper::getConfig().set(Option); +} diff --git a/sycl-fusion/jit-compiler/lib/helper/ConfigHelper.h b/sycl-fusion/jit-compiler/lib/helper/ConfigHelper.h index 57aad92a456a3..abc5e3507ad4a 100644 --- a/sycl-fusion/jit-compiler/lib/helper/ConfigHelper.h +++ b/sycl-fusion/jit-compiler/lib/helper/ConfigHelper.h @@ -11,11 +11,44 @@ #include "Options.h" +#include +#include + namespace jit_compiler { +class Config { + +public: + template typename Opt::ValueType get() const { + using T = typename Opt::ValueType; + + auto *ConfigValue = get(Opt::Id); + if (!ConfigValue) { + return T{}; + } + return static_cast *>(ConfigValue)->Value; + } + + void set(OptionPtrBase *Option) { + OptionValues[Option->Id] = std::unique_ptr(Option); + } + +private: + std::unordered_map> OptionValues; + + const OptionPtrBase *get(OptionID ID) const { + const auto Iter = OptionValues.find(ID); + if (Iter == OptionValues.end()) { + return nullptr; + } + return Iter->second.get(); + } +}; + class ConfigHelper { public: - static void setConfig(Config &&JITConfig) { Cfg = std::move(JITConfig); } + static void reset() { Cfg = {}; } + static Config &getConfig() { return Cfg; } template static typename Opt::ValueType get() { return Cfg.get(); diff --git a/sycl/source/detail/jit_compiler.cpp b/sycl/source/detail/jit_compiler.cpp index 6b06b83e1c413..46b907060c018 100644 --- a/sycl/source/detail/jit_compiler.cpp +++ b/sycl/source/detail/jit_compiler.cpp @@ -823,20 +823,22 @@ jit_compiler::fuseKernels(QueueImplPtr Queue, static size_t FusedKernelNameIndex = 0; auto FusedKernelName = "fused_" + std::to_string(FusedKernelNameIndex++); - ::jit_compiler::Config JITConfig; + ::jit_compiler::KernelFusion::resetConfiguration(); bool DebugEnabled = detail::SYCLConfig::get() > 0; - JITConfig.set<::jit_compiler::option::JITEnableVerbose>(DebugEnabled); - JITConfig.set<::jit_compiler::option::JITEnableCaching>( + ::jit_compiler::KernelFusion::set<::jit_compiler::option::JITEnableVerbose>( + DebugEnabled); + ::jit_compiler::KernelFusion::set<::jit_compiler::option::JITEnableCaching>( detail::SYCLConfig::get()); ::jit_compiler::TargetInfo TargetInfo = getTargetInfo(Queue); ::jit_compiler::BinaryFormat TargetFormat = TargetInfo.getFormat(); - JITConfig.set<::jit_compiler::option::JITTargetInfo>(TargetInfo); + ::jit_compiler::KernelFusion::set<::jit_compiler::option::JITTargetInfo>( + std::move(TargetInfo)); auto FusionResult = ::jit_compiler::KernelFusion::fuseKernels( - std::move(JITConfig), InputKernelInfo, FusedKernelName.c_str(), - ParamIdentities, BarrierFlags, InternalizeParams, JITConstants); + InputKernelInfo, FusedKernelName.c_str(), ParamIdentities, BarrierFlags, + InternalizeParams, JITConstants); if (FusionResult.failed()) { if (DebugEnabled) { From 02dee981711c8ebd93af7c8d6cb88db3d50a54bc Mon Sep 17 00:00:00 2001 From: Buildbot for SYCL Date: Thu, 25 Jan 2024 00:15:18 +0800 Subject: [PATCH 2/3] [GHA] Uplift Linux GPU RT version to 23.43.27642.18 (#12463) Scheduled drivers uplift Co-authored-by: GitHub Actions --- devops/dependencies.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/devops/dependencies.json b/devops/dependencies.json index acd2fd4f0caf0..09eccfeb72821 100644 --- a/devops/dependencies.json +++ b/devops/dependencies.json @@ -1,15 +1,15 @@ { "linux": { "compute_runtime": { - "github_tag": "23.30.26918.9", - "version": "23.30.26918.9", - "url": "https://github.com/intel/compute-runtime/releases/tag/23.30.26918.9", + "github_tag": "23.43.27642.18", + "version": "23.43.27642.18", + "url": "https://github.com/intel/compute-runtime/releases/tag/23.43.27642.18", "root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu" }, "igc": { - "github_tag": "igc-1.0.14828.8", - "version": "1.0.14828.8", - "url": "https://github.com/intel/intel-graphics-compiler/releases/tag/igc-1.0.14828.8", + "github_tag": "igc-1.0.15468.11", + "version": "1.0.15468.11", + "url": "https://github.com/intel/intel-graphics-compiler/releases/tag/igc-1.0.15468.11", "root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu" }, "cm": { @@ -19,9 +19,9 @@ "root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu" }, "level_zero": { - "github_tag": "v1.14.0", - "version": "v1.14.0", - "url": "https://github.com/oneapi-src/level-zero/releases/tag/v1.14.0", + "github_tag": "v1.15.8", + "version": "v1.15.8", + "url": "https://github.com/oneapi-src/level-zero/releases/tag/v1.15.8", "root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu" }, "tbb": { From 2414a156c5e4f15c8b4b90d8e75fedf671b7187c Mon Sep 17 00:00:00 2001 From: Nick Sarnie Date: Wed, 24 Jan 2024 17:04:39 +0000 Subject: [PATCH 3/3] [SYCL][ESIMD][E2E] Disable matrix_transpose_glb.cpp (#12482) It's failing in postcommit, we need this to fix the CI. Signed-off-by: Sarnie, Nick --- sycl/test-e2e/ESIMD/matrix_transpose_glb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test-e2e/ESIMD/matrix_transpose_glb.cpp b/sycl/test-e2e/ESIMD/matrix_transpose_glb.cpp index 95823841cc2e3..847750a1f307d 100644 --- a/sycl/test-e2e/ESIMD/matrix_transpose_glb.cpp +++ b/sycl/test-e2e/ESIMD/matrix_transpose_glb.cpp @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +// UNSUPPORTED: * // Use -O2 to avoid huge stack usage under -O0. // RUN: %{build} -O2 -o %t.out // RUN: %{run} %t.out