|
| 1 | +/******************************************************************************* |
| 2 | +* Copyright 2025 Intel Corporation |
| 3 | +* |
| 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +* you may not use this file except in compliance with the License. |
| 6 | +* You may obtain a copy of the License at |
| 7 | +* |
| 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +* |
| 10 | +* Unless required by applicable law or agreed to in writing, software |
| 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +* See the License for the specific language governing permissions and |
| 14 | +* limitations under the License. |
| 15 | +*******************************************************************************/ |
| 16 | + |
| 17 | +#include "dnnl_test_common.hpp" |
| 18 | +#include "gtest/gtest.h" |
| 19 | + |
| 20 | +#include "oneapi/dnnl/dnnl.hpp" |
| 21 | + |
| 22 | +#include <cstdlib> |
| 23 | +#include <iostream> |
| 24 | + |
| 25 | +extern "C" const char *dnnl_impl_gpu_intel_get_isa_name(dnnl_engine_t engine); |
| 26 | + |
| 27 | +namespace dnnl { |
| 28 | + |
| 29 | +struct conv_params_t { |
| 30 | + memory::dim MB, IC, OC, IH, OH, KH; |
| 31 | +}; |
| 32 | + |
| 33 | +// This is a regression test for PVC write-after-read hardware bug workaround. |
| 34 | +// The bug manifests as a page fault caused by WAR-related corruption of the |
| 35 | +// send header. The test doesn't include any validation, the expected failure |
| 36 | +// is a GPU page fault and test segfault. |
| 37 | +class test_regression_conv_pvc_war_t |
| 38 | + : public ::testing::TestWithParam<conv_params_t> { |
| 39 | + conv_params_t params; |
| 40 | + engine eng; |
| 41 | + |
| 42 | +protected: |
| 43 | + void SetUp() override { |
| 44 | + SKIP_IF_CUDA(true, "Unsupported test for CUDA."); |
| 45 | + SKIP_IF_HIP(true, "Unsupported test for HIP."); |
| 46 | + SKIP_IF_GENERIC(true, "Unsupported test for generic GPU."); |
| 47 | + SKIP_IF(engine::get_count(engine::kind::gpu) == 0, |
| 48 | + "GPU engine not found."); |
| 49 | + |
| 50 | + eng = engine(engine::kind::gpu, 0); |
| 51 | + SKIP_IF(dnnl_impl_gpu_intel_get_isa_name(eng.get()) |
| 52 | + != std::string("xe_hpc"), |
| 53 | + "Test is for PVC only"); |
| 54 | + |
| 55 | + params = ::testing::TestWithParam<decltype(params)>::GetParam(); |
| 56 | + Test(); |
| 57 | + } |
| 58 | + |
| 59 | + void Test() { |
| 60 | + memory::dims src_dims = {params.MB, params.IC, params.IH, params.IH}; |
| 61 | + memory::dims wei_dims = {params.OC, params.IC, params.KH, params.KH}; |
| 62 | + memory::dims dst_dims = {params.MB, params.OC, params.OH, params.OH}; |
| 63 | + memory::dims strides = {1, 1}; |
| 64 | + memory::dims padding = {1, 1}; |
| 65 | + |
| 66 | + memory::desc src_md( |
| 67 | + src_dims, memory::data_type::f64, memory::format_tag::nchw); |
| 68 | + memory::desc wei_md( |
| 69 | + wei_dims, memory::data_type::f64, memory::format_tag::oihw); |
| 70 | + memory::desc dst_md( |
| 71 | + dst_dims, memory::data_type::f64, memory::format_tag::nchw); |
| 72 | + |
| 73 | + convolution_forward::primitive_desc hint_fwd_pd(eng, |
| 74 | + prop_kind::forward_training, algorithm::convolution_direct, |
| 75 | + src_md, wei_md, dst_md, strides, padding, padding); |
| 76 | + convolution_backward_data::primitive_desc pd(eng, |
| 77 | + algorithm::convolution_direct, src_md, wei_md, dst_md, strides, |
| 78 | + padding, padding, hint_fwd_pd); |
| 79 | + convolution_backward_data prim(pd); |
| 80 | + |
| 81 | + auto dst_mem_desc = pd.diff_dst_desc(); |
| 82 | + auto wei_mem_desc = pd.weights_desc(); |
| 83 | + auto src_mem_desc = pd.diff_src_desc(); |
| 84 | + |
| 85 | + memory dst_mem(dst_mem_desc, eng); |
| 86 | + memory wei_mem(wei_mem_desc, eng); |
| 87 | + memory src_mem(src_mem_desc, eng); |
| 88 | + |
| 89 | + stream strm(eng); |
| 90 | + |
| 91 | + const int REPEATS = 10; |
| 92 | + for (int i = 0; i < REPEATS; ++i) { |
| 93 | + prim.execute(strm, |
| 94 | + {{DNNL_ARG_DIFF_DST, dst_mem}, {DNNL_ARG_WEIGHTS, wei_mem}, |
| 95 | + {DNNL_ARG_DIFF_SRC, src_mem}}); |
| 96 | + } |
| 97 | + strm.wait(); |
| 98 | + } |
| 99 | +}; |
| 100 | + |
| 101 | +TEST_P(test_regression_conv_pvc_war_t, Tests) {} |
| 102 | + |
| 103 | +GPU_INSTANTIATE_TEST_SUITE_P(All, test_regression_conv_pvc_war_t, |
| 104 | + ::testing::Values(conv_params_t {8, 32, 64, 128, 128, 3}, |
| 105 | + conv_params_t {1, 64, 64, 256, 256, 3})); |
| 106 | + |
| 107 | +} // namespace dnnl |
0 commit comments