1/*******************************************************************************
2* Copyright 2019-2022 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 ONEAPI_DNNL_DNNL_CONFIG_H
18#define ONEAPI_DNNL_DNNL_CONFIG_H
19
20#include "oneapi/dnnl/dnnl_types.h"
21
22/// @cond DO_NOT_DOCUMENT_THIS
23
24// All symbols shall be internal unless marked as DNNL_API
25#if defined _WIN32 || defined __CYGWIN__
26#define DNNL_HELPER_DLL_IMPORT __declspec(dllimport)
27#define DNNL_HELPER_DLL_EXPORT __declspec(dllexport)
28#else
29#if __GNUC__ >= 4
30#define DNNL_HELPER_DLL_IMPORT __attribute__((visibility("default")))
31#define DNNL_HELPER_DLL_EXPORT __attribute__((visibility("default")))
32#else
33#define DNNL_HELPER_DLL_IMPORT
34#define DNNL_HELPER_DLL_EXPORT
35#endif
36#endif
37
38#ifdef DNNL_DLL
39#ifdef DNNL_DLL_EXPORTS
40#define DNNL_API DNNL_HELPER_DLL_EXPORT
41#else
42#define DNNL_API DNNL_HELPER_DLL_IMPORT
43#endif
44#else
45#define DNNL_API
46#endif
47
48#if defined(__GNUC__)
49#define DNNL_DEPRECATED __attribute__((deprecated))
50#elif defined(_MSC_VER)
51#define DNNL_DEPRECATED __declspec(deprecated)
52#else
53#define DNNL_DEPRECATED
54#endif
55
56/// @endcond
57
58// clang-format off
59
60// oneDNN CPU threading runtime
61#define DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_OMP
62
63// oneDNN CPU engine runtime
64#define DNNL_CPU_RUNTIME DNNL_RUNTIME_OMP
65
66// oneDNN GPU engine runtime
67#define DNNL_GPU_RUNTIME DNNL_RUNTIME_OCL
68
69// clang-format on
70
71#if defined(DNNL_CPU_RUNTIME) && defined(DNNL_GPU_RUNTIME)
72#if (DNNL_CPU_RUNTIME == DNNL_RUNTIME_OCL)
73#error "Unexpected DNNL_CPU_RUNTIME"
74#endif
75#if (DNNL_GPU_RUNTIME != DNNL_RUNTIME_NONE) \
76 && (DNNL_GPU_RUNTIME != DNNL_RUNTIME_OCL) \
77 && (DNNL_GPU_RUNTIME != DNNL_RUNTIME_SYCL)
78#error "Unexpected DNNL_GPU_RUNTIME"
79#endif
80#if (DNNL_CPU_RUNTIME == DNNL_RUNTIME_NONE \
81 && DNNL_GPU_RUNTIME == DNNL_RUNTIME_NONE)
82#error "At least one runtime must be specified"
83#endif
84#else
85#error "BOTH DNNL_CPU_RUNTIME and DNNL_GPU_RUNTIME must be defined"
86#endif
87
88// For SYCL CPU, a primitive may be created and executed in different threads
89// hence the global scratchpad does not work. This enables concurrent execution
90// when CPU runtime is SYCL to avoid the issue.
91#if DNNL_CPU_RUNTIME == DNNL_RUNTIME_SYCL
92#ifndef DNNL_ENABLE_CONCURRENT_EXEC
93#define DNNL_ENABLE_CONCURRENT_EXEC
94#endif
95#endif
96
97// When defined, primitive cache stores runtime objects.
98/* #undef DNNL_USE_RT_OBJECTS_IN_PRIMITIVE_CACHE */
99
100// When defined, DPCPP is supported.
101/* #undef DNNL_WITH_SYCL */
102
103// When defined, Level Zero is supported.
104/* #undef DNNL_WITH_LEVEL_ZERO */
105
106// When defined, SYCL CUDA backend is used.
107/* #undef DNNL_SYCL_CUDA */
108
109// When defined, SYCL HIP backend is used.
110/* #undef DNNL_SYCL_HIP */
111
112// When defined, stack checker is enabled.
113/* #undef DNNL_ENABLE_STACK_CHECKER */
114
115// When defined, experimental features are enabled.
116/* #undef DNNL_EXPERIMENTAL */
117
118// List of configurating build controls
119// Workload controls
120#define BUILD_TRAINING 1
121#define BUILD_INFERENCE 0
122// Primitive controls
123#define BUILD_PRIMITIVE_ALL 1
124#define BUILD_BATCH_NORMALIZATION 0
125#define BUILD_BINARY 0
126#define BUILD_CONCAT 0
127#define BUILD_CONVOLUTION 0
128#define BUILD_DECONVOLUTION 0
129#define BUILD_ELTWISE 0
130#define BUILD_INNER_PRODUCT 0
131#define BUILD_LAYER_NORMALIZATION 0
132#define BUILD_LRN 0
133#define BUILD_MATMUL 0
134#define BUILD_POOLING 0
135#define BUILD_PRELU 0
136#define BUILD_REDUCTION 0
137#define BUILD_REORDER 0
138#define BUILD_RESAMPLING 0
139#define BUILD_RNN 0
140#define BUILD_SHUFFLE 0
141#define BUILD_SOFTMAX 0
142#define BUILD_SUM 0
143// Primitives CPU ISA controls
144#define BUILD_PRIMITIVE_CPU_ISA_ALL 1
145#define BUILD_SSE41 0
146#define BUILD_AVX2 0
147#define BUILD_AVX512 0
148#define BUILD_AMX 0
149// Primitives GPU ISA controls
150#define BUILD_PRIMITIVE_GPU_ISA_ALL 1
151#define BUILD_GEN9 0
152#define BUILD_GEN11 0
153#define BUILD_XELP 0
154#define BUILD_XEHP 0
155#define BUILD_XEHPG 0
156#define BUILD_XEHPC 0
157#endif
158