• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 Google LLC. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef RUY_RUY_OPT_SET_H_
17 #define RUY_RUY_OPT_SET_H_
18 
19 // RUY_OPT_SET is a compile-time API that Ruy provides for enabling/disabling
20 // certain optimizations. It should be used by defining that macro on the
21 // compiler command line.
22 //
23 // Each bit in RUY_OPT_SET controls a particular optimization done in Ruy.
24 #define RUY_OPT_BIT_INTRINSICS 0x1
25 #define RUY_OPT_BIT_ASM 0x2
26 #define RUY_OPT_BIT_TUNING 0x4
27 #define RUY_OPT_BIT_FAT_KERNEL 0x8
28 // 0x10 used to be RUY_OPT_BIT_NATIVE_ROUNDING
29 #define RUY_OPT_BIT_AVOID_ALIASING 0x20
30 #define RUY_OPT_BIT_MAX_STREAMING 0x40
31 #define RUY_OPT_BIT_PACK_AHEAD 0x80
32 #define RUY_OPT_BIT_PREFETCH_LOAD 0x100
33 #define RUY_OPT_BIT_PREFETCH_STORE 0x200
34 #define RUY_OPT_BIT_FRACTAL_Z 0x400
35 #define RUY_OPT_BIT_FRACTAL_U 0x800
36 #define RUY_OPT_BIT_FRACTAL_HILBERT 0x1000
37 
38 #if !defined(RUY_OPT_SET)
39 #ifdef RUY_OPTIMIZE_FOR_MATMUL_BENCHMARK
40 // Load prefetching is detrimental in matrix multiplication benchmarks.
41 // Store prefetching is not.
42 #define RUY_OPT_SET (~RUY_OPT_BIT_PREFETCH_LOAD)
43 #else
44 // Default to all optimizations.
45 #define RUY_OPT_SET (~0)
46 #endif
47 #endif
48 
49 #define RUY_OPT(X) ((RUY_OPT_SET & RUY_OPT_BIT_##X) != 0)
50 
51 #endif  // RUY_RUY_OPT_SET_H_
52