fml  0.1-0
Fused Matrix Library
cpu_utils.hh
1 // This file is part of fml which is released under the Boost Software
2 // License, Version 1.0. See accompanying file LICENSE or copy at
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #ifndef FML_CPU_INTERNALS_CPU_UTILS_H
6 #define FML_CPU_INTERNALS_CPU_UTILS_H
7 #pragma once
8 
9 
10 namespace fml
11 {
12  namespace cpu_utils
13  {
14  // zero specified triangle
15  template <typename REAL>
16  void tri2zero(const char uplo, const bool diag, const len_t m, const len_t n,
17  REAL *A, const len_t lda)
18  {
19  if (uplo == 'U')
20  {
21  const len_t offset = diag ? 1 : 0;
22 
23  for (len_t j=0; j<n; j++)
24  {
25  const len_t top = std::min(j+offset, m);
26 
27  #pragma omp for simd
28  for (len_t i=0; i<top; i++)
29  A[i + lda*j] = (REAL)0;
30  }
31  }
32  else // if (uplo == 'L')
33  {
34  const len_t offset = diag ? 0 : 1;
35 
36  for (len_t j=0; j<n; j++)
37  {
38  #pragma omp for simd
39  for (len_t i=j+offset; i<m; i++)
40  A[i + lda*j] = (REAL)0;
41  }
42  }
43  }
44  }
45 }
46 
47 
48 #endif
fml
Core namespace.
Definition: dimops.hh:10