Changesets · Branches · Tags · Compare
| Changeset | 3a0df369be07134921b24b07e8a5c2e59afb3ec32fa8e370b4c80e218571a816 |
|---|---|
| Author | quink <zhilizhao@tencent.com> · 2024-07-02 12:44 +08:00 |
| Committer | GitHub <noreply@github.com> · 2024-07-02 12:44 +08:00 |
| Parents | 749938ca298c |
4 files changed
modified CMakeLists.txt +1 −1
| @@ -559,7 +559,7 @@ | ||
| 559 | 559 | unset(CMAKE_REQUIRED_FLAGS) |
| 560 | 560 | endif() |
| 561 | 561 | |
| 562 | - if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND NCNN_COMPILER_SUPPORT_X86_AVX) | |
| 562 | + if(NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten|WASI" AND NCNN_COMPILER_SUPPORT_X86_AVX) | |
| 563 | 563 | option(NCNN_AVX "optimize x86 platform with avx extension" ON) |
| 564 | 564 | if(NCNN_COMPILER_SUPPORT_X86_FMA) |
| 565 | 565 | if(NCNN_AVX) |
modified src/CMakeLists.txt +4 −2
| @@ -395,8 +395,10 @@ | ||
| 395 | 395 | endif() |
| 396 | 396 | target_compile_options(ncnn PRIVATE /D__SSE2__) |
| 397 | 397 | else() |
| 398 | - target_compile_options(ncnn PRIVATE -msse2 -msse) | |
| 399 | - if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | |
| 398 | + if(NOT CMAKE_SYSTEM_NAME MATCHES "WASI") | |
| 399 | + target_compile_options(ncnn PRIVATE -msse2 -msse) | |
| 400 | + endif () | |
| 401 | + if(CMAKE_SYSTEM_NAME MATCHES "Emscripten|WASI") | |
| 400 | 402 | target_compile_options(ncnn PRIVATE -msimd128) |
| 401 | 403 | endif() |
| 402 | 404 | endif() |
modified src/benchmark.cpp +12 −4
| @@ -15,11 +15,20 @@ | ||
| 15 | 15 | #include "benchmark.h" |
| 16 | 16 | |
| 17 | 17 | #if (__cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)) && !defined(__riscv) && !NCNN_SIMPLESTL |
| 18 | +#define USE_CXX11_CLOCK 1 | |
| 19 | +#else | |
| 20 | +#define USE_CXX11_CLOCK 0 | |
| 21 | +#endif | |
| 22 | + | |
| 23 | +#if USE_CXX11_CLOCK | |
| 18 | 24 | #include <chrono> |
| 25 | +#if NCNN_THREADS | |
| 19 | 26 | #include <thread> |
| 27 | +#endif | |
| 20 | 28 | #include <numeric> |
| 21 | 29 | #include <algorithm> |
| 22 | -#else | |
| 30 | +#endif // USE_CXX11_CLOCK | |
| 31 | + | |
| 23 | 32 | #ifdef _WIN32 |
| 24 | 33 | #define WIN32_LEAN_AND_MEAN |
| 25 | 34 | #include <windows.h> |
| @@ -27,7 +36,6 @@ | ||
| 27 | 36 | #include <sys/time.h> //gettimeofday() |
| 28 | 37 | #include <unistd.h> // sleep() |
| 29 | 38 | #endif // _WIN32 |
| 30 | -#endif | |
| 31 | 39 | |
| 32 | 40 | #if NCNN_BENCHMARK |
| 33 | 41 | #include "layer/convolution.h" |
| @@ -46,7 +54,7 @@ | ||
| 46 | 54 | |
| 47 | 55 | double get_current_time() |
| 48 | 56 | { |
| 49 | -#if (__cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)) && !defined(__riscv) && !NCNN_SIMPLESTL | |
| 57 | +#if USE_CXX11_CLOCK | |
| 50 | 58 | auto now = std::chrono::high_resolution_clock::now(); |
| 51 | 59 | auto usec = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()); |
| 52 | 60 | return usec.count() / 1000.0; |
| @@ -69,7 +77,7 @@ | ||
| 69 | 77 | |
| 70 | 78 | void sleep(unsigned long long int milliseconds) |
| 71 | 79 | { |
| 72 | -#if (__cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)) && !defined(__riscv) && !NCNN_SIMPLESTL | |
| 80 | +#if USE_CXX11_CLOCK && NCNN_THREADS | |
| 73 | 81 | std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); |
| 74 | 82 | #else |
| 75 | 83 | #ifdef _WIN32 |
modified src/cpu.cpp +2 −0
| @@ -17,8 +17,10 @@ | ||
| 17 | 17 | #include "platform.h" |
| 18 | 18 | |
| 19 | 19 | #include <limits.h> |
| 20 | +#ifndef __wasi__ | |
| 20 | 21 | #include <setjmp.h> |
| 21 | 22 | #include <signal.h> |
| 23 | +#endif // __wasi__ | |
| 22 | 24 | #include <stdio.h> |
| 23 | 25 | #include <string.h> |
| 24 | 26 |