Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cea0cbd
[ci] debug on appveyor
simogasp Apr 28, 2020
5d09d4a
[ci] testing shared and static
simogasp Apr 29, 2020
b8f0cc5
[ci] testing %DBUILD_SHARED_LIBS%
simogasp Apr 29, 2020
318ae82
[ci] testing manually replacing \MD for static build
simogasp Apr 29, 2020
bdc4e72
[cmake]-std=c++11 not hardcoded for MSVC because it is propagated to …
simogasp May 9, 2020
d7a779a
[cmake];-fPIC not hardcoded for MSVC because it is propagated to nvcc…
simogasp May 9, 2020
2db2ae2
[cmake] use correct flags for static build for MSVC
simogasp May 9, 2020
a67f9cf
[cmake] force /MT and /MD into nvcc for windows
simogasp May 9, 2020
73e5e08
[cmake] remove BOOST_ALL_DYN_LINK BOOST_ALL_NO_LIB
simogasp May 9, 2020
bff7c92
[popsift] use nullptr
simogasp May 11, 2020
0010d87
[popsift] unneeded ;
simogasp May 11, 2020
c5583da
[cmake] fix typo
simogasp May 11, 2020
8e4aef7
[cmake] set CMAKE_BUILD_TYPE values
simogasp May 11, 2020
9e23dd0
[cmake] linker flags
simogasp May 11, 2020
8d2b8b0
[cmake] simplify PopSift_MVSC_LINKER
simogasp May 11, 2020
1640d9a
[cmake] doc
simogasp May 11, 2020
d8769ca
[cmake] boost not used anymore
simogasp May 11, 2020
1f6a337
[cmake] fix message for pic
simogasp May 11, 2020
15004ce
[cmake] no pic for MSVC
simogasp May 11, 2020
50bf0f9
[cmake] lowercase
simogasp May 11, 2020
ca544d4
[apps] use EXIT_SUCCESS
simogasp May 11, 2020
066f07f
[cmake] add -fPIE for exe
simogasp May 11, 2020
a62e684
[cmake] cleaning
simogasp May 15, 2020
30d5818
[ci] win only shared
simogasp May 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,43 @@ option(PopSift_USE_NVTX_PROFILING "Use CUDA NVTX for profiling." OFF)
option(PopSift_ERRCHK_AFTER_KERNEL "Synchronize and check CUDA error after every kernel." OFF)
option(PopSift_USE_POSITION_INDEPENDENT_CODE "Generate position independent code." ON)
option(PopSift_USE_GRID_FILTER "Switch off grid filtering to massively reduce compile time while debugging other things." ON)
option(PopSift_USE_NORMF "The __normf function computes Euclidian distance on large arrays. Fast but stability is uncertain." OFF)
option(PopSift_USE_NORMF "The __normf function computes Euclidean distance on large arrays. Fast but stability is uncertain." OFF)
option(PopSift_USE_TEST_CMD "Add testing step for functional verification" OFF)
option(PopSift_NVCC_WARNINGS "Switch on several additional warning for CUDA nvcc" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)


if(PopSift_USE_POSITION_INDEPENDENT_CODE)
if(PopSift_USE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

# set(CMAKE_BUILD_TYPE Debug)
if(NOT CMAKE_BUILD_TYPE)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Build type not set, building in Release configuration")
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
else()
message(STATUS "Building in ${CMAKE_BUILD_TYPE} configuration")
endif()

# ensure the proper linker flags when building the static version on MSVC
if(MSVC AND NOT BUILD_SHARED_LIBS)
foreach(config "DEBUG" "RELEASE" "MINSIZEREL" "RELWITHDEBINFO")
string(REPLACE /MD /MT CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}")
string(REPLACE /MD /MT CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}")
message(STATUS "CMAKE_C_FLAGS_${config} ${CMAKE_C_FLAGS_${config}}")
message(STATUS "CMAKE_CXX_FLAGS_${config} ${CMAKE_CXX_FLAGS_${config}}")
endforeach()
endif()

# for some reason this line is necessary to propagate the standard to nvcc
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# On MSVC this is not necessary / nvcc does not recognize the flag for MSVC
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 11)
Expand Down Expand Up @@ -117,10 +132,24 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
list(APPEND CUDA_NVCC_FLAGS_RELEASE "-O3")

if(PopSift_USE_POSITION_INDEPENDENT_CODE)
if(PopSift_USE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler;-fPIC")
endif()

# this is to ensure that on MSVC the flags for the linker are properly propagate even to the intermediate
# linking step. This seems not the case e.g. on vcpkg using ninja build.
if(MSVC)
if(BUILD_SHARED_LIBS)
set(PopSift_MVSC_LINKER "/MD")
else()
set(PopSift_MVSC_LINKER "/MT")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PopSift_MVSC_LINKER "${PopSift_MVSC_LINKER}d")
endif()
list(APPEND CUDA_NVCC_FLAGS -Xcompiler ${PopSift_MVSC_LINKER})
endif()

# default stream per-thread implies that each host thread has one non-synchronizing 0-stream
# currently, the code requires legacy mode
list(APPEND CUDA_NVCC_FLAGS "--default-stream;legacy")
Expand Down Expand Up @@ -190,12 +219,11 @@ message(STATUS "PopSift version: " ${PROJECT_VERSION})
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
message(STATUS "Build Shared libs: " ${BUILD_SHARED_LIBS})
message(STATUS "Build examples: " ${PopSift_BUILD_EXAMPLES})
message(STATUS "Generate position independent code: " ${PopSift_USE_POSITION_INDEPENDENT_CODE})
message(STATUS "Generate position independent code: " ${CMAKE_POSITION_INDEPENDENT_CODE})
message(STATUS "Use CUDA NVTX for profiling: " ${PopSift_USE_NVTX_PROFILING})
message(STATUS "Synchronize and check CUDA error after every kernel: " ${PopSift_ERRCHK_AFTER_KERNEL})
message(STATUS "Grid filtering: " ${PopSift_USE_GRID_FILTER})
message(STATUS "Testing step: " ${PopSift_USE_TEST_CMD})
message(STATUS "Link with static Boost libraries: " ${PopSift_BOOST_USE_STATIC_LIBS})
message(STATUS "Additional warning for CUDA nvcc: " ${PopSift_NVCC_WARNINGS})
message(STATUS "Compiling for CUDA CCs: ${PopSift_CUDA_CC_LIST}")
message(STATUS "Install path: " ${CMAKE_INSTALL_PREFIX})
Expand Down
10 changes: 8 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ platform:

configuration:
- Release
- Debug

#environment:
# matrix:
# - DBUILD_SHARED_LIBS: 0
# - DBUILD_SHARED_LIBS: 1

install:
- cmd: >-
Expand All @@ -20,7 +26,7 @@ install:
before_build:
- md build
- cd build
- cmake -G "Visual Studio 14 2015" -A x64 -T v140,host=x64 -DPopSift_BUILD_EXAMPLES:BOOL=ON -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- cmake -G "Visual Studio 14 2015" -A x64 -T v140,host=x64 -DBUILD_SHARED_LIBS=%DBUILD_SHARED_LIBS% -DPopSift_USE_POSITION_INDEPENDENT_CODE:BOOL=%DBUILD_SHARED_LIBS% -DPopSift_BUILD_EXAMPLES:BOOL=ON -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- ls -l

build:
Expand All @@ -29,4 +35,4 @@ build:
parallel: true

cache:
c:\tools\vcpkg\installed\
- c:\tools\vcpkg\installed\
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ set_target_properties(popsift PROPERTIES DEBUG_POSTFIX "d")
target_link_libraries(popsift ${CUDA_CUDADEVRT_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} Threads::Threads)



# EXPORTING THE LIBRARY
#
# place to put the cmake-related files
Expand Down
23 changes: 20 additions & 3 deletions src/application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
cmake_minimum_required(VERSION 3.12)
project(PopsiftDemo LANGUAGES CXX)

OPTION(PopSift_BOOST_USE_STATIC_LIBS "Link examples with static Boost libraries" OFF)
option(PopSift_BOOST_USE_STATIC_LIBS "Link examples with static Boost libraries" OFF)

# if this is used as a stand-alone project we need to tell whether to use PIC
if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS})
endif()

# enable -fPIE for executables when -fpic
# https://cmake.org/cmake/help/v3.17/policy/CMP0083.html
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
cmake_policy(SET CMP0083 NEW)
include(CheckPIESupported)
check_pie_supported()
elseif(CMAKE_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# manually add the link flag for gcc
list(APPEND CMAKE_EXE_LINKER_FLAGS "-pie")
endif()

if(TARGET popsift)
# when compiled in the repository the target is already defined
Expand Down Expand Up @@ -52,7 +69,7 @@ set_property(TARGET popsift-demo PROPERTY CXX_STANDARD 11)

target_compile_options(popsift-demo PRIVATE ${PD_COMPILE_OPTIONS} )
target_include_directories(popsift-demo PUBLIC ${PD_INCLUDE_DIRS})
target_compile_definitions(popsift-demo PRIVATE ${Boost_DEFINITIONS} BOOST_ALL_DYN_LINK BOOST_ALL_NO_LIB)
target_compile_definitions(popsift-demo PRIVATE ${Boost_DEFINITIONS})
target_link_libraries(popsift-demo PUBLIC PopSift::popsift ${PD_LINK_LIBS})

set_target_properties(popsift-demo PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
Expand All @@ -67,7 +84,7 @@ set_property(TARGET popsift-match PROPERTY CXX_STANDARD 11)

target_compile_options(popsift-match PRIVATE ${PD_COMPILE_OPTIONS} )
target_include_directories(popsift-match PUBLIC ${PD_INCLUDE_DIRS})
target_compile_definitions(popsift-match PRIVATE ${Boost_DEFINITIONS} BOOST_ALL_DYN_LINK BOOST_ALL_NO_LIB)
target_compile_definitions(popsift-match PRIVATE ${Boost_DEFINITIONS})
target_link_libraries(popsift-match PUBLIC PopSift::popsift ${PD_LINK_LIBS})

set_target_properties(popsift-match PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
Expand Down
2 changes: 1 addition & 1 deletion src/application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void parseargs(int argc, char** argv, popsift::Config& config, string& in

if (vm.count("help")) {
std::cout << all << '\n';
exit(1);
exit(EXIT_SUCCESS);
}

notify(vm); // Notify does processing (e.g., raise exceptions if required args are missing)
Expand Down
4 changes: 2 additions & 2 deletions src/popsift/common/assist.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void* memalign(size_t alignment, size_t size)
int err = posix_memalign( &ret, alignment, size );
if( err != 0 ) {
errno = err;
ret = 0;
ret = nullptr;
}
return ret;
#endif
Expand All @@ -148,4 +148,4 @@ static void memalign_free( void* ptr )
#endif
}

}; // namespace popsift
} // namespace popsift