/******************************************************************************* * * MIT License * * Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * *******************************************************************************/ #pragma once #include #include #include #include #ifdef Tensile_ENABLE_MARKER #include #endif #include namespace TensileLite { using StringSet = std::set; /** * @brief Common place for defining flags which enable debug behaviour. */ class TENSILELITEHOST_EXPORT Debug : public LazySingleton { public: bool printPropertyEvaluation() const; bool printPredicateEvaluation() const; bool printPredicateEvaluationVerbose() const; bool printDeviceSelection() const; bool printCodeObjectInfo() const; bool printKernelArguments() const; bool printDataInit() const; bool printTensorInfo() const; // print tensor dims, strides, memory sizes bool printTensorModeHex() const; // if tensors are printed, use hexadecimal output format bool printLibraryVersion() const; bool printLookupEfficiency() const; bool printWinningKernelName() const; // Re-reads TENSILE_DB, TENSILE_DB2, and TENSILE_STREAMK5_FORCE_MODE from // the environment and updates cached state. Only these three fields are // refreshed; all other env-driven settings remain at their initial values. // Intended for tests that call setenv() in-process after the singleton has // already been constructed. // // Thread safety: must only be called when no concurrent TensileLite // operations are in flight (e.g., between GEMM calls in a serial test). void reloadDebugBitsForTest(); bool usePredictionLibrary() const; bool printLibraryLogicIndex() const; // Reports the effective Stream-K (SK5 hybrid) scheduling mode selected at // runtime by streamK5EffectiveDynamic(). Gated by TENSILE_DB bit 0x100000. bool printStreamKModeSelection() const; bool naivePropertySearch() const; bool skipKernelLaunch() const; bool useStreamKDataParrallel() const; // SK5 hybrid mode debug override. // Return value semantics: // -1 -> respect the API attribute / GemmPreference setting // 0 -> force the static (SK3) path // 1 -> force the dynamic (SK4) path // Sourced from the TENSILE_STREAMK5_FORCE_MODE environment variable. int streamK5ForceMode() const; int useExperimentalSelection() const; std::string getMetric() const; bool getBenchmark() const; int getSolutionIndex() const; bool printSolutionSelectionTime() const; int getGridbasedTopSols() const; bool printStreamKGridInfo() const; bool gridBasedKDTree() const; bool gridBasedBatchExp() const; bool disableStaggerU() const; StringSet excludedLibFromGetAll() const; void setExcludedLibFromGetAll(StringSet& excludedSet); __attribute__((always_inline)) inline void markerStart(const char* name) const { #ifdef Tensile_ENABLE_MARKER if(m_printMarker) { roctxRangePush(name); } #endif } __attribute__((always_inline)) inline void markerStart(const char* name, const std::string& objPath) const { #ifdef Tensile_ENABLE_MARKER if(m_printMarker) { std::string s = name + std::string(": ") + objPath; roctxRangePush(s.c_str()); } #endif } __attribute__((always_inline)) inline void markerStop() const { #ifdef Tensile_ENABLE_MARKER if(m_printMarker) { roctxRangePop(); } #endif } private: friend LazySingleton; int m_value; int m_value2; bool m_naivePropertySearch = false; bool m_dataParallel = false; int m_experimentSelection = 0; int m_solution_index = -1; bool m_predictionLib = false; std::string m_metric = ""; int m_gridbasedTopSols = 1; bool m_benchmark = false; bool m_gridbasedKdTree = false; bool m_gridbasedBatchExp = false; bool m_printMarker = false; bool m_disableStaggerU = false; // -1 = unset (use API attribute); 0 = force static SK3; 1 = force dynamic SK4 int m_streamK5ForceMode = -1; StringSet m_excludedFromGetAll; Debug(); }; } // namespace TensileLite