Skip to content

Commit

Permalink
[gfx12] add support of gfx12 platforms (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
cderb authored Jul 17, 2024
1 parent aa175c7 commit 845c1f4
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
defined(CK_AMD_GPU_GFX940) || defined(CK_AMD_GPU_GFX908) || defined(CK_AMD_GPU_GFX90A) || \
defined(CK_AMD_GPU_GFX941) || defined(CK_AMD_GPU_GFX942) || defined(CK_AMD_GPU_GFX1030) || \
defined(CK_AMD_GPU_GFX1031) || defined(CK_AMD_GPU_GFX1100) || defined(CK_AMD_GPU_GFX1101) || \
defined(CK_AMD_GPU_GFX1102))
defined(CK_AMD_GPU_GFX1102) || defined(CK_AMD_GPU_GFX1200) || defined(CK_AMD_GPU_GFX1201))
#error Need to define (only) one GPU target
#endif

Expand All @@ -35,7 +35,8 @@
defined(CK_AMD_GPU_GFX908) || defined(CK_AMD_GPU_GFX90A)
#define CK_BUFFER_RESOURCE_3RD_DWORD 0x00020000
#elif defined(CK_AMD_GPU_GFX1030) || defined(CK_AMD_GPU_GFX1031) || defined(CK_AMD_GPU_GFX1100) || \
defined(CK_AMD_GPU_GFX1101) || defined(CK_AMD_GPU_GFX1102)
defined(CK_AMD_GPU_GFX1101) || defined(CK_AMD_GPU_GFX1102) || defined(CK_AMD_GPU_GFX1200) || \
defined(CK_AMD_GPU_GFX1201)
#define CK_BUFFER_RESOURCE_3RD_DWORD 0x31014000
#endif

Expand All @@ -45,7 +46,8 @@
#elif defined(CK_AMD_GPU_GFX906) || defined(CK_AMD_GPU_GFX908) || defined(CK_AMD_GPU_GFX90a) || \
defined(CK_AMD_GPU_GFX941) || defined(CK_AMD_GPU_GFX942) || defined(CK_AMD_GPU_GFX940) || \
defined(CK_AMD_GPU_GFX1030) || defined(CK_AMD_GPU_GFX1031) || defined(CK_AMD_GPU_GFX1100) || \
defined(CK_AMD_GPU_GFX1101) || defined(CK_AMD_GPU_GFX1102)
defined(CK_AMD_GPU_GFX1101) || defined(CK_AMD_GPU_GFX1102) || defined(CK_AMD_GPU_GFX1200) || \
defined(CK_AMD_GPU_GFX1201)
#define CK_USE_AMD_V_FMAC_F32
#define CK_USE_AMD_V_DOT2_F32_F16
#define CK_USE_AMD_V_DOT4_I32_I8
Expand Down
8 changes: 7 additions & 1 deletion src/include/miopen/solver/ck_utility_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ static inline bool is_ck_supported_hardware(const Handle& handle)
StartsWith(handle.GetDeviceName(), "gfx1031") ||
StartsWith(handle.GetDeviceName(), "gfx1100") ||
StartsWith(handle.GetDeviceName(), "gfx1101") ||
StartsWith(handle.GetDeviceName(), "gfx1102");
StartsWith(handle.GetDeviceName(), "gfx1102") ||
StartsWith(handle.GetDeviceName(), "gfx1200") ||
StartsWith(handle.GetDeviceName(), "gfx1201");
}

// MI100 : gfx908
Expand Down Expand Up @@ -121,6 +123,10 @@ static inline auto get_ck_common_compiler_flag(const Handle& handle)
compiler_flag << " -DCK_AMD_GPU_GFX1101";
else if(StartsWith(device_name, "gfx1102"))
compiler_flag << " -DCK_AMD_GPU_GFX1102";
else if(StartsWith(device_name, "gfx1200"))
compiler_flag << " -DCK_AMD_GPU_GFX1200";
else if(StartsWith(device_name, "gfx1201"))
compiler_flag << " -DCK_AMD_GPU_GFX1201";
// NOLINTEND(*-braces-around-statements)

// buffer atomic-fadd
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MIOpenBatchNormActivBwdPerAct.cl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

#define MIOPEN_USE_AMDGCN 0
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X)
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X || MIO_BN_GFX120X)
#undef MIOPEN_USE_AMDGCN
#define MIOPEN_USE_AMDGCN 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MIOpenBatchNormActivBwdSpatial.cl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif

#define MIOPEN_USE_AMDGCN 0
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X)
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X || MIO_BN_GFX120X)
#undef MIOPEN_USE_AMDGCN
#define MIOPEN_USE_AMDGCN 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MIOpenBatchNormActivFwdTrainSpatial.cl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#define MIOPEN_USE_AMDGCN 0
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X)
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X || MIO_BN_GFX120X)
#undef MIOPEN_USE_AMDGCN
#define MIOPEN_USE_AMDGCN 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MIOpenBatchNormBwdSpatial.cl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#define MIOPEN_USE_AMDGCN 0
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X)
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X || MIO_BN_GFX120X)
#undef MIOPEN_USE_AMDGCN
#define MIOPEN_USE_AMDGCN 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MIOpenBatchNormFwdTrainSpatial.cl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#define MIOPEN_USE_AMDGCN 0
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X)
#if defined(__AMDGCN__) && !(MIO_BN_GFX103X || MIO_BN_GFX110X || MIO_BN_GFX120X)
#undef MIOPEN_USE_AMDGCN
#define MIOPEN_USE_AMDGCN 1
#endif
Expand Down
9 changes: 7 additions & 2 deletions src/kernels/batchnorm_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@
// TODO: Spaghetti code!!!
// MIOPEN_USE_AMDGCN may be defined before this header.
#ifndef MIOPEN_USE_AMDGCN
#if defined(__AMDGCN__) && \
!((defined(MIO_BN_GFX103X) && MIO_BN_GFX103X) || (defined(MIO_BN_GFX110X) && MIO_BN_GFX110X))
#if defined(__AMDGCN__) && \
!((defined(MIO_BN_GFX103X) && MIO_BN_GFX103X) || \
(defined(MIO_BN_GFX110X) && MIO_BN_GFX110X) || (defined(MIO_BN_GFX120X) && MIO_BN_GFX120X))
#define MIOPEN_USE_AMDGCN 1
#else
#define MIOPEN_USE_AMDGCN 0
Expand Down Expand Up @@ -165,6 +166,10 @@
#define MIO_BN_GFX110X 0
#endif

#ifndef MIO_BN_GFX120X
#define MIO_BN_GFX120X 0
#endif

#define UNUSED __attribute__((__unused__))

#if(MIO_BN_VARIANT != 4)
Expand Down
3 changes: 2 additions & 1 deletion src/solver/batchnorm/backward_per_activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ BnBwdTrainingPerActivation::GetSolution(const ExecutionContext& context,
{"MIO_BN_GRP0", xlocalsize},
{"MIO_BN_GRP1", ylocalsize},
{"MIO_BN_GRP2", zlocalsize},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
};

kernel.comp_options = build_params.GenerateFor(kbp::OpenCL{});
Expand Down
1 change: 1 addition & 0 deletions src/solver/batchnorm/backward_per_activation_fused.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ ConvSolution BnBwdTrgActivationFused::GetSolution(const FusionContext& context,
{"MIO_BN_VARIANT", static_cast<int>(variant)},
{"MIO_BN_GFX103X", static_cast<int>(StartsWith(handle.GetDeviceName(), "gfx103"))},
{"MIO_BN_GFX110X", static_cast<int>(StartsWith(handle.GetDeviceName(), "gfx110"))},
{"MIO_BN_GFX120X", static_cast<int>(StartsWith(handle.GetDeviceName(), "gfx120"))},
{"MIO_BN_CBA_WRITE_INTERMEDIATE", static_cast<int>(0)},
{"MIOPEN_YES_ACTIV", static_cast<int>(1)},
{"MIOPEN_NRN_OP_ID", static_cast<int>(activ_op.activMode)},
Expand Down
1 change: 1 addition & 0 deletions src/solver/batchnorm/backward_spatial_multiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ ConvSolution BnBwdTrainingSpatialMultiple::GetSolution(
{"MIO_BN_GRP2", zlocalsize},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
{"MIO_LAYOUT_NHWC", static_cast<int>(problem.IsLayoutNHWC())},
};

Expand Down
3 changes: 2 additions & 1 deletion src/solver/batchnorm/backward_spatial_single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ BnBwdTrainingSpatialSingle::GetSolution(const ExecutionContext& context,
kernel.kernel_name = "MIOpenBatchNormBwdSpatial";

build_params << KernelBuildParameters{
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
};

kernel.comp_options = build_params.GenerateFor(kbp::OpenCL{});
Expand Down
3 changes: 2 additions & 1 deletion src/solver/batchnorm/forward_inference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ ConvSolution BnFwdInference::GetSolution(const ExecutionContext& context,
{"MIO_BN_GRP0", xlocalsize},
{"MIO_BN_GRP1", ylocalsize},
{"MIO_BN_GRP2", zlocalsize},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
};

kernel.comp_options = build_params.GenerateFor(kbp::OpenCL{});
Expand Down
3 changes: 2 additions & 1 deletion src/solver/batchnorm/forward_per_activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ BnFwdTrainingPerActivation::GetSolution(const ExecutionContext& context,
{"MIO_BN_GRP0", xlocalsize},
{"MIO_BN_GRP1", ylocalsize},
{"MIO_BN_GRP2", zlocalsize},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
};

auto kernel = KernelInfo{};
Expand Down
1 change: 1 addition & 0 deletions src/solver/batchnorm/forward_per_activation_fused.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ ConvSolution BnFwdTrgActivationFused::GetSolution(const FusionContext& context,
{"MIO_BN_VARIANT", static_cast<int>(variant)},
{"MIO_BN_GFX103X", static_cast<int>(StartsWith(handle.GetDeviceName(), "gfx103"))},
{"MIO_BN_GFX110X", static_cast<int>(StartsWith(handle.GetDeviceName(), "gfx110"))},
{"MIO_BN_GFX120X", static_cast<int>(StartsWith(handle.GetDeviceName(), "gfx120"))},
{"MIOPEN_YES_ACTIV", static_cast<int>(1)},
{"MIOPEN_NRN_OP_ID", static_cast<int>(activ_op.activMode)},
{"MIOPEN_USE_FP16", static_cast<int>(input_desc.GetType() == miopenHalf)},
Expand Down
1 change: 1 addition & 0 deletions src/solver/batchnorm/forward_spatial_multiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ ConvSolution BnFwdTrainingSpatialMultiple::GetSolution(
{"MIO_BN_GRP2", zlocalsize},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
{"MIO_LAYOUT_NHWC", static_cast<int>(problem.IsLayoutNHWC())},
};

Expand Down
1 change: 1 addition & 0 deletions src/solver/batchnorm/forward_spatial_single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ BnFwdTrainingSpatialSingle::GetSolution(const ExecutionContext& context,
{"MIO_BN_GRP2", zlocalsize},
{"MIO_BN_GFX103X", (StartsWith(handle.GetDeviceName(), "gfx103") ? "1" : "0")},
{"MIO_BN_GFX110X", (StartsWith(handle.GetDeviceName(), "gfx110") ? "1" : "0")},
{"MIO_BN_GFX120X", (StartsWith(handle.GetDeviceName(), "gfx120") ? "1" : "0")},
{"MIO_LAYOUT_NHWC", static_cast<int>(problem.IsLayoutNHWC())},
};

Expand Down
8 changes: 7 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ option( MIOPEN_TEST_GFX900 "Test on Vega10 (gfx900)" OFF )
option( MIOPEN_TEST_GFX906 "Test on Vega20 (gfx906)" OFF )
option( MIOPEN_TEST_GFX103X "Test on Navi21/22 (gfx1030/31)" OFF )
option( MIOPEN_TEST_GFX110X "Test on Navi31/32 (gfx1100/02)" OFF )
option( MIOPEN_TEST_GFX120X "Test on gfx1200/01" OFF )
option( MIOPEN_TEST_GPU_XNACK_ENABLED "Test as if XNACK mode is enabled" OFF )
option( MIOPEN_TEST_CONV "" OFF)
option( MIOPEN_TEST_DEEPBENCH "" OFF)
Expand Down Expand Up @@ -98,7 +99,7 @@ endif()
# Also we do not detect GPU when target GPU for testing is specified explicitly.
set(MIOPEN_TEST_GPU_DETECTION_FAILED FALSE)
set(MIOPEN_NO_GPU FALSE)
if(NOT (MIOPEN_TEST_GFX900 OR MIOPEN_TEST_GFX906 OR MIOPEN_TEST_GFX908 OR MIOPEN_TEST_GFX90A OR MIOPEN_TEST_GFX94X OR MIOPEN_TEST_GFX103X OR MIOPEN_TEST_GFX110X OR MIOPEN_TEST_HIP_NOGPU))
if(NOT (MIOPEN_TEST_GFX900 OR MIOPEN_TEST_GFX906 OR MIOPEN_TEST_GFX908 OR MIOPEN_TEST_GFX90A OR MIOPEN_TEST_GFX94X OR MIOPEN_TEST_GFX103X OR MIOPEN_TEST_GFX110X OR MIOPEN_TEST_GFX120X OR MIOPEN_TEST_HIP_NOGPU))
find_program(ROCMINFO
NAMES rocminfo
PATHS
Expand Down Expand Up @@ -130,6 +131,10 @@ if(NOT (MIOPEN_TEST_GFX900 OR MIOPEN_TEST_GFX906 OR MIOPEN_TEST_GFX908 OR MIOPEN
set(MIOPEN_TEST_GFX110X ON)
elseif(ROCMINFO_OUTPUT MATCHES "gfx1102")
set(MIOPEN_TEST_GFX110X ON)
elseif(ROCMINFO_OUTPUT MATCHES "gfx1200")
set(MIOPEN_TEST_GFX120X ON)
elseif(ROCMINFO_OUTPUT MATCHES "gfx1201")
set(MIOPEN_TEST_GFX120X ON)
elseif(ROCMINFO_OUTPUT MATCHES "gfx900")
set(MIOPEN_TEST_GFX900 ON)
elseif(ROCMINFO_OUTPUT MATCHES "gfx906")
Expand Down Expand Up @@ -175,6 +180,7 @@ message(STATUS "MIOPEN_TEST_GFX90A ${MIOPEN_TEST_GFX90A}")
message(STATUS "MIOPEN_TEST_GFX94X ${MIOPEN_TEST_GFX94X}")
message(STATUS "MIOPEN_TEST_GFX103X ${MIOPEN_TEST_GFX103X}")
message(STATUS "MIOPEN_TEST_GFX110X ${MIOPEN_TEST_GFX110X}")
message(STATUS "MIOPEN_TEST_GFX120X ${MIOPEN_TEST_GFX120X}")
message(STATUS "MIOPEN_TEST_GPU_XNACK_ENABLED ${MIOPEN_TEST_GPU_XNACK_ENABLED}")
message(STATUS "MIOPEN_TEST_GPU_DETECTION_FAILED ${MIOPEN_TEST_GPU_DETECTION_FAILED}")
message(STATUS "MIOPEN_TEST_WITH_MIOPENDRIVER ${MIOPEN_TEST_WITH_MIOPENDRIVER}")
Expand Down
4 changes: 3 additions & 1 deletion test/handle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ void test_arch_name()
"gfx1031",
"gfx1100",
"gfx1101",
"gfx1102"};
"gfx1102",
"gfx1200",
"gfx1201"};
auto this_arch = h.GetDeviceName();
EXPECT(std::any_of(
known_arch.begin(), known_arch.end(), [&](std::string arch) { return arch == this_arch; }));
Expand Down

0 comments on commit 845c1f4

Please sign in to comment.