llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-amdgpu Author: A. Cauble (accauble) <details> <summary>Changes</summary> ## Summary Revert PR #<!-- -->224688. * PR #<!-- -->224688 introduced a temporary patch to consume env var `HSA_DISABLE_GFX12_STRICT` which would remove "-strict" by default. * The env var is no longer on by default and reverting entirely --- Full diff: https://github.com/llvm/llvm-project/pull/239345.diff 2 Files Affected: - (modified) clang/tools/offload-arch/lib/AMDGPUArchByKFD.cpp (+1-12) - (modified) clang/unittests/tools/offload-arch/OffloadArchTest.cpp (-60) ``````````diff diff --git a/clang/tools/offload-arch/lib/AMDGPUArchByKFD.cpp b/clang/tools/offload-arch/lib/AMDGPUArchByKFD.cpp index 1dc41906f40ac9..315c87b75eb23b 100644 --- a/clang/tools/offload-arch/lib/AMDGPUArchByKFD.cpp +++ b/clang/tools/offload-arch/lib/AMDGPUArchByKFD.cpp @@ -17,7 +17,6 @@ #include "llvm/Support/LineIterator.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" -#include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" #include <memory> @@ -33,19 +32,9 @@ constexpr static long getMajor(long Ver) { return (Ver / 10000) % 100; } constexpr static long getMinor(long Ver) { return (Ver / 100) % 100; } constexpr static long getStep(long Ver) { return Ver % 100; } -// A temporary patch in ROCr has ISA defaulting to gfx1250 on A0 and enabling -// the "-strict" suffix with HSA_DISABLE_GFX12_STRICT=0 -static bool isStrictEnabled() { - auto EnableEnvVar = sys::Process::GetEnv("HSA_DISABLE_GFX12_STRICT"); - return (EnableEnvVar.has_value() && EnableEnvVar.value() == "0"); -} - // For A0, print gfx1250-strict to match rocminfo static StringRef getRevisionSuffix(long GFXVersion, long ASICRevision) { - return (GFXVersion == GFX1250_VERSION && ASICRevision == 0 && - isStrictEnabled()) - ? "-strict" - : ""; + return (GFXVersion == GFX1250_VERSION && ASICRevision == 0) ? "-strict" : ""; } // Exposed for testing diff --git a/clang/unittests/tools/offload-arch/OffloadArchTest.cpp b/clang/unittests/tools/offload-arch/OffloadArchTest.cpp index 67b98a96bd3a09..a62e597c2b1801 100644 --- a/clang/unittests/tools/offload-arch/OffloadArchTest.cpp +++ b/clang/unittests/tools/offload-arch/OffloadArchTest.cpp @@ -10,14 +10,11 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Testing/Support/SupportHelpers.h" #include "gtest/gtest.h" #include <algorithm> #include <cassert> -#include <cstdlib> -#include <optional> #include <string> // Defined in AMDGPUArchByHIP.cpp (non-static, linked via clangOffloadArch). @@ -168,38 +165,6 @@ int printGPUsByKFDCapturingStdout(StringRef NodePath, std::string &Output) { return Result; } -// RAII helper to set an environment variable for the duration of a test -// Based on the class of the same name in llvm's Jobserver unit tests -class ScopedEnvironment { - std::string Name; - std::optional<std::string> OldValue; - - static void setEnv(const std::string &Name, std::optional<StringRef> Value) { -#if defined(_WIN32) - // On Windows, setting an environment variable to the empty string - // unsets it, so getenv() returns NULL - _putenv_s(Name.c_str(), Value ? Value->str().c_str() : ""); -#else - if (Value) - setenv(Name.c_str(), Value->str().c_str(), 1); - else - unsetenv(Name.c_str()); -#endif - } - -public: - ScopedEnvironment(StringRef Name, std::optional<StringRef> Value) - : Name(Name.str()), OldValue(sys::Process::GetEnv(Name)) { - setEnv(this->Name, Value); - } - - ~ScopedEnvironment() { - setEnv(Name, OldValue ? std::optional<StringRef>(*OldValue) : std::nullopt); - } - - ScopedEnvironment(const ScopedEnvironment &) = delete; - ScopedEnvironment &operator=(const ScopedEnvironment &) = delete; -}; } // namespace // A topology directory that cannot be opened must be reported as a failure, so @@ -262,8 +227,6 @@ TEST(KFDTopology, MultipleGPUsArePrintedInNodeOrder) { // ASIC revision is 0. Also tests to make sure other properties that look like // capability (like capability2) are not read instead. TEST(KFDTopology, GFX1250A0IsPrintedAsStrict) { - // A temporary patch in ROCr requires this env var to be 0 - ScopedEnvironment Env("HSA_DISABLE_GFX12_STRICT", "0"); unittest::TempDir Dir("kfd-topology", /*Unique=*/true); addGPUNodeWithCapability(Dir.path(), 0, "120500", /*Capability=*/0xF837A280, /*Capability2=*/0xFFFFFFFF); @@ -272,31 +235,8 @@ TEST(KFDTopology, GFX1250A0IsPrintedAsStrict) { EXPECT_EQ(Output, "gfx1250-strict\n"); } -// HSA_DISABLE_GFX12_STRICT=1 suppresses the suffix on A0. -TEST(KFDTopology, GFX1250A0StrictSuppressedByEnvVar) { - ScopedEnvironment Env("HSA_DISABLE_GFX12_STRICT", "1"); - unittest::TempDir Dir("kfd-topology", /*Unique=*/true); - addGPUNodeWithCapability(Dir.path(), 0, "120500", /*Capability=*/0xF837A280, - /*Capability2=*/0xFFFFFFFF); - std::string Output; - EXPECT_EQ(printGPUsByKFDCapturingStdout(Dir.path(), Output), 0); - EXPECT_EQ(Output, "gfx1250\n"); -} - -// Temporary test: Only the exact value "0" enables the suffix. -TEST(KFDTopology, GFX1250A0StrictIgnoresOtherEnvValues) { - ScopedEnvironment Env("HSA_DISABLE_GFX12_STRICT", std::nullopt); - unittest::TempDir Dir("kfd-topology", /*Unique=*/true); - addGPUNodeWithCapability(Dir.path(), 0, "120500", /*Capability=*/0xF837A280, - /*Capability2=*/0xFFFFFFFF); - std::string Output; - EXPECT_EQ(printGPUsByKFDCapturingStdout(Dir.path(), Output), 0); - EXPECT_EQ(Output, "gfx1250\n"); -} - // Make sure any other version of gfx1250 is printed as gfx1250. TEST(KFDTopology, GFX1250NonA0IsPrintedPlain) { - ScopedEnvironment Env("HSA_DISABLE_GFX12_STRICT", "0"); unittest::TempDir Dir("kfd-topology", /*Unique=*/true); addGPUNodeWithCapability(Dir.path(), 0, "120500", /*Capability=*/0xF877A280, /*Capability2=*/0x00000000); `````````` </details> https://github.com/llvm/llvm-project/pull/239345 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
