Skip to content

Commit

Permalink
Workaround for SWDEV-203031: set default limit for MP Winograd worksp…
Browse files Browse the repository at this point in the history
…ace usage (#2090)

* wa-swdev-203031(01) MP Winograd: set the default limit of workspace usage.
* wa-swdev-203031(03) Lower limit for gfx900 and gfx906/60 down to ~1.862 GiB. Remove limit for other devices.
  • Loading branch information
atamazov authored and Daniel Lowell committed Sep 18, 2019
1 parent d47501c commit a5a4129
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/solver/conv_multipass_wino3x3WrW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
#include <limits>
#include <cassert>
#include <miopen/gcn_asm_utils.hpp>
#include <miopen/stringutils.hpp>
#include <miopen/env.hpp>
#include <miopen/logger.hpp>
#include <miopen/handle.hpp>
#include <miopen/generic_search.hpp>
#include <miopen/tensor.hpp>
#include <miopen/solver.hpp>

#include "miopen/solver.hpp"
#if(MIOPEN_BACKEND_HIP && MIOPEN_USE_ROCBLAS)
#define WORKAROUND_SWDEV_203031 1 // See also issues #2075, #2067
#endif

namespace miopen {
namespace solver {
Expand Down Expand Up @@ -193,7 +197,7 @@ struct FilterTransform
{
return false;
}
return (params.IsFp32() || params.IsFp16() || params.IsBfp16())
return (params.IsFp32() || params.IsFp16() || params.IsBfp16())
&& params.Is2d()
&& H < u16limit
&& W < u16limit
Expand Down Expand Up @@ -375,14 +379,33 @@ bool ConvWinograd3x3MultipassWrW<WinoDataW, WinoFilterW>::IsApplicable(
return false;

const std::string name = params.GetStream().GetDeviceName();
if(name.find("gfx8") == std::string::npos && name.find("gfx9") == std::string::npos)
{
if(!(StartsWith(name, "gfx8") || StartsWith(name, "gfx9")))
return false;

{
std::size_t limit = miopen::Value(MIOPEN_DEBUG_AMD_WINOGRAD_MPASS_WORKSPACE_MAX{});
#if WORKAROUND_SWDEV_203031
if(limit == 0)
{
if(name == "gfx900" ||
(name == "gfx906" && params.GetStream().GetMaxComputeUnits() <= 60))
limit = 2000000000ULL; // ~1.862 GiB
else
limit = std::numeric_limits<std::size_t>::max();
}
#else
if(limit == 0)
limit = std::numeric_limits<std::size_t>::max();
#endif
if(limit != std::numeric_limits<std::size_t>::max())
{
const auto required = GetWorkspaceSize(params);
MIOPEN_LOG_I2("Workspace required: " << required << ", limit: " << limit);
if(required > limit)
return false;
}
}
if(miopen::Value(MIOPEN_DEBUG_AMD_WINOGRAD_MPASS_WORKSPACE_MAX{}) != 0)
if(miopen::Value(MIOPEN_DEBUG_AMD_WINOGRAD_MPASS_WORKSPACE_MAX{}) <
GetWorkspaceSize(params))
return false;

// int offset for Workspace buffers.
if((InTransform<WinoDataW, WinoFilterW>::GetBufferSize(params) /
GetTypeSize(params.in_data_type) +
Expand Down

0 comments on commit a5a4129

Please sign in to comment.