1/*******************************************************************************
2* Copyright 2020 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#ifndef CPU_GEMM_GEMM_MSAN_UNPOISON_HPP
18#define CPU_GEMM_GEMM_MSAN_UNPOISON_HPP
19
20namespace dnnl {
21namespace impl {
22namespace cpu {
23
24inline void msan_unpoison_matrix(
25 void *C, dim_t M, dim_t N, dim_t LDC, size_t typesize) {
26 assert(C != nullptr && LDC >= M && typesize);
27 if (msan_enabled && C != nullptr) {
28 if ((M <= 0) || (N <= 0)) return;
29
30 size_t col_size = M * typesize;
31 size_t col_stride = LDC * typesize;
32 uint8_t *col = (uint8_t *)C;
33 for (dim_t j = 0; j < N; j++) {
34 msan_unpoison(col, col_size);
35 col += col_stride;
36 }
37 }
38}
39
40} // namespace cpu
41} // namespace impl
42} // namespace dnnl
43
44#endif
45