File tree Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ include(simd)
29
29
30
30
################################ Configurations #######################################
31
31
option (WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND} )
32
- option (WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND} )
32
+ option (WITH_AVX "Compile PaddlePaddle with AVX intrinsics" OFF )
33
33
option (WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON )
34
34
option (WITH_TESTING "Compile PaddlePaddle with unit testing" ON )
35
35
option (WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ limitations under the License. */
14
14
15
15
#pragma once
16
16
17
+ #include " Error.h"
17
18
#include " Excepts.h"
18
19
19
20
/* *
Original file line number Diff line number Diff line change @@ -97,4 +97,37 @@ class SIMDFlags final {
97
97
#define HAS_AVX512 HAS_SIMD (SIMD_AVX512)
98
98
// clang-format on
99
99
100
+ /* *
101
+ * Invoke checkCPUFeature() before Paddle initialization to
102
+ * check target machine whether support compiled instructions.
103
+ * If not, simply throw out an error.
104
+ */
105
+ inline Error __must_check checkCPUFeature() {
106
+ Error err;
107
+ #ifndef __AVX__
108
+ if (HAS_AVX) {
109
+ LOG (WARNING) << " PaddlePaddle wasn't compiled to use avx instructions, "
110
+ << " but these are available on your machine and could "
111
+ << " speed up CPU computations via CMAKE .. -DWITH_AVX=ON" ;
112
+ }
113
+ #else
114
+ if (!HAS_AVX) {
115
+ err = Errors (
116
+ " PaddlePaddle was compiled to use avx instructions, "
117
+ " but these aren't available on your machine, please "
118
+ " disable it via CMAKE .. -DWITH_AVX=OFF" );
119
+ }
120
+ #endif // __AVX__
121
+ #ifdef __SSE3__
122
+ if (!HAS_SSE3) {
123
+ err = Error (
124
+ " PaddlePaddle was compiled to use sse3 instructions, "
125
+ " which is the minimum requirement of PaddlePaddle. "
126
+ " But these aren't available on your current machine." );
127
+ }
128
+ #endif // __SSE3__
129
+
130
+ return err;
131
+ }
132
+
100
133
} // namespace paddle
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ limitations under the License. */
26
26
27
27
#include < gflags/gflags.h>
28
28
29
+ #include " CpuId.h"
29
30
#include " CustomStackTrace.h"
30
31
#include " Logging.h"
31
32
#include " StringUtil.h"
@@ -185,6 +186,7 @@ void initMain(int argc, char** argv) {
185
186
}
186
187
187
188
version::printVersion ();
189
+ checkCPUFeature ().check ();
188
190
runInitFunctions ();
189
191
}
190
192
You can’t perform that action at this time.
0 commit comments