Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support simpleomp on Windows with MSVC #5683

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
17 changes: 17 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ jobs:
Copy-Item -Path "$env:GITHUB_WORKSPACE\swiftshader-install\vulkan-1.dll" -Destination 'build-x64\tests'
cd build-x64; ctest -C Release --output-on-failure -j 4

- name: x64-simpleomp
run: |
mkdir build-x64-simpleomp; cd build-x64-simpleomp
cmake -T ${{ matrix.toolset-version }},host=x64 -A x64 -Dprotobuf_DIR="$env:GITHUB_WORKSPACE\protobuf-install\cmake" -DNCNN_SHARED_LIB=OFF -DNCNN_VULKAN=ON -DNCNN_SIMPLEOMP=ON -DNCNN_BUILD_TESTS=ON ..
cmake --build . --config Release -j 4
- name: x64-simpleomp-test
if: matrix.vs-version != 'vs2015' && matrix.vs-version != 'vs2017'
run: |
echo "[Processor]`nThreadCount=1`n" > build-x64-simpleomp/tests/Release/SwiftShader.ini
Copy-Item -Path "$env:GITHUB_WORKSPACE\swiftshader-install\vulkan-1.dll" -Destination 'build-x64-simpleomp\tests'
cd build-x64-simpleomp; ctest -C Release --output-on-failure -j 4
# Copy-Item -Path "build-x64-simpleomp\src\Release\ncnn.dll" -Destination 'build-x64-simpleomp\tests'

- name: x64-sse2
run: |
mkdir build-x64-sse2; cd build-x64-sse2
Expand All @@ -144,3 +157,7 @@ jobs:
run: |
Copy-Item -Path "build-x86\src\Release\ncnn.dll" -Destination 'build-x86\tests'
cd build-x86; ctest -C Release --output-on-failure -j 4




2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ if(NCNN_VULKAN)
endif()
endif()

if (TARGET glslang AND TARGET SPIRV)
if(TARGET glslang AND TARGET SPIRV)
get_property(glslang_location TARGET glslang PROPERTY LOCATION)
get_property(SPIRV_location TARGET SPIRV PROPERTY LOCATION)
message(STATUS "Found glslang: ${glslang_location} (found version \"${glslang_VERSION}\")")
Expand Down
22 changes: 14 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function(ncnn_src_group ncnn_src_string folder)
string(REGEX REPLACE "/" "\\\\" _target_folder "${folder}")

foreach(_file IN LISTS ${_ncnn_src_list})
source_group ("${_target_folder}" FILES "${_file}")
endforeach ()
source_group("${_target_folder}" FILES "${_file}")
endforeach()
endfunction()

set(ncnn_SRCS
Expand Down Expand Up @@ -215,11 +215,11 @@ endif()

target_include_directories(ncnn
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/ncnn>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/ncnn>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/layer>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/layer>)

if(NCNN_OPENMP)
if(NOT NCNN_SIMPLEOMP)
Expand All @@ -237,6 +237,8 @@ if(NCNN_OPENMP)
if(NCNN_SIMPLEOMP)
if(IOS OR APPLE)
target_compile_options(ncnn PRIVATE -Xpreprocessor -fopenmp)
elseif(MSVC OR WIN32)
target_compile_options(ncnn PRIVATE /openmp)
else()
target_compile_options(ncnn PRIVATE -fopenmp)
endif()
Expand All @@ -262,7 +264,11 @@ if(NCNN_THREADS)
target_link_libraries(ncnn PUBLIC Threads::Threads)
endif()
if(NCNN_SIMPLEOMP OR NCNN_SIMPLESTL)
target_link_libraries(ncnn PUBLIC pthread)
if(MSVC OR WIN32)
message(STATUS "Using Native WIN32 THREAD MODEL")
else()
target_link_libraries(ncnn PUBLIC pthread)
endif()
endif()
endif()

Expand Down Expand Up @@ -398,7 +404,7 @@ if(NCNN_TARGET_ARCH STREQUAL "x86")
else()
if(NOT CMAKE_SYSTEM_NAME MATCHES "WASI")
target_compile_options(ncnn PRIVATE -msse2 -msse)
endif ()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten|WASI")
target_compile_options(ncnn PRIVATE -msimd128)
endif()
Expand Down
Loading
Loading