The generated triton MaxPool2d kernel has poor performance on amd vega20/60
Labels: triaged, module: inductor, rocm

I conducted maxpool2d forward kernel testing on some platforms and found that the new triton kernel improved performance on some platforms, mainly due to the efficient use of L1 Cache. However, on some platforms with different L1 cache architectures, the performance decreased compared to the native kernel.

 When I was running resnet50, I found that it did not perform well on the AMD card.  I tested the performance of the following code separately:
```
import torch
import torch._dynamo as dynamo
from torch.nn import BatchNorm2d, ReLU, MaxPool2d

def timed(fn):
    start = torch.cuda.Event(enable_timing=True)
    end = torch.cuda.Event(enable_timing=True)
    start.record()
    result = fn()
    end.record()
    torch.cuda.synchronize()
    return result, start.elapsed_time(end)

def generate_data(b):
    return (
        torch.randn(b, 64, 256, 256).to(torch.float32).cuda(),
        torch.randint(1000, (b,)).cuda(),
    )

N_ITERS = 10

def eval(inp):
    bn = BatchNorm2d(64).cuda()
    n = ReLU().cuda()
    m = MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False).cuda()
    x1 = bn(inp)
    x2 = n(x1)
    x3 = m(x2)
    return x3

eval_opt = dynamo.optimize("inductor")(eval)

inp = generate_data(32)[0]

out, time1 = timed(lambda: eval(inp))
out_opt, time2 = timed(lambda: eval_opt(inp))

assert torch.allclose(out, out_opt)

eager_times = []
dynamo_times = []
for i in range(N_ITERS):
    inp = generate_data(32)[0]
    _, eager_time = timed(lambda: eval(inp))
    eager_times.append(eager_time)
    print(f"eager eval time {i}: {eager_time}")

dynamo_times = []

for i in range(N_ITERS):
    inp = generate_data(32)[0]
    _, dynamo_time = timed(lambda: eval_opt(inp))
    dynamo_times.append(dynamo_time)
    print(f"dynamo eval time {i}: {dynamo_time}")

import numpy as np
eager_med = np.median(eager_times)
dynamo_med = np.median(dynamo_times)
speedup = eager_med / dynamo_med
print(f"(eval) eager median: {eager_med}, dynamo median: {dynamo_med}, speedup: {speedup}x")

```
I commented out the following code to disable lowering maxpool2d
```
# _inductor/lowering.py
# line no: 2689
#@register_lowering(aten.max_pool2d_with_indices, type_promotion_kind=None)
```
time(ms)
|  env  | eager time  | dynamo time | dynamo  time (disable lowering maxpool2d )|
|  ----  | ----  |  ----  | ----  | 
|torch2.0  CUDA11.7  RTX3080  |  6.789| 6.984 | 5.589 | 
| torch2.0 ROCM5.2 Vega20/60  | 12.893| **19.626** | 12.884 |

It can be seen that there has been a decrease in the performance of the lowing maxpool2d to triton kernel on the vega20 platform.
I tested the Maxpool2d  triton kernel separately and the same results were obtained.
I found that MaxPool2dWithIndices is regarded as a pointwise op in torch. As the size of the parameter stride changes, there will be significant changes in data loading performance. 
Is this an issue for discussion？




cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @ngimel @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov