Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ oxford
# Temporary files
.DS_Store

# Downloaded archives for tests.
*.tgz
13 changes: 1 addition & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ OPTION(PopSift_USE_POSITION_INDEPENDENT_CODE "Generate position independent code
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_TEST_CMD "Add testing step for functional verification" OFF)
OPTION(PopSift_BOOST_USE_STATIC_LIBS "Link with static Boost libraries" OFF)
OPTION(PopSift_BOOST_USE_STATIC_LIBS "Link examples with static Boost libraries" OFF)
Comment thread
simogasp marked this conversation as resolved.
Outdated
OPTION(PopSift_NVCC_WARNINGS "Switch on several additional warning for CUDA nvcc" OFF)

if(PopSift_BOOST_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif()

if(PopSift_USE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
Expand All @@ -40,13 +36,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -G")
# set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -G")

find_package(Boost 1.53.0 REQUIRED COMPONENTS system thread)
if(WIN32)
add_definitions("-DBOOST_ALL_NO_LIB")
link_directories(Boost_LIBRARRY_DIR_DEBUG)
link_directories(Boost_LIBRARRY_DIR_RELEASE)
endif(WIN32)

if(BUILD_SHARED_LIBS)
message(STATUS "BUILD_SHARED_LIBS ON")
# Need to declare CUDA_USE_STATIC_CUDA_RUNTIME as an option to ensure that it is not overwritten in FindCUDA.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ Dependencies

Most of the dependencies can be installed from the common repositories (apt, yum etc):

Boost >= 1.55 ([atomic, chrono, date-time, system, thread]-dev)
Boost >= 1.55 ([atomic, chrono, date-time, system, thread]-dev) (only required for the application)
CUDA >= 7.0
DevIL (libdevil-dev) (only required for the application)

Build
-----

PopSift has been developed and tested on Linux machines, mostly a variant of Ubuntu, but compiles on MacOSX as well. It comes as a CMake project and requires at least CUDA 7.0 and Boost >= 1.55. It is known to compile and work with NVidia cards of compute capability 3.0 (including the GT 650M), but the code is developed with the compute capability 5.2 card GTX 980 Ti in mind.
PopSift has been developed and tested on Linux machines, mostly a variant of Ubuntu, but compiles on MacOSX as well. It comes as a CMake project and requires at least CUDA 7.0. The example application carries an additional dependency on Boost >= 1.55. It is known to compile and work with NVidia cards of compute capability 3.0 (including the GT 650M), but the code is developed with the compute capability 5.2 card GTX 980 Ti in mind.

If you want to avoid building the application you can run cmake with the option `-DPopSift_BUILD_EXAMPLES:BOOL=OFF`.
If you want to avoid building the example application you can run cmake with the option `-DPopSift_BUILD_EXAMPLES:BOOL=OFF`.
If you want to build PopSift as a shared library: `-DBUILD_SHARED_LIBS=ON`.

In order to build the library you can run:
Expand Down
10 changes: 7 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})

CUDA_INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/popsift)
CUDA_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/popsift)

CUDA_ADD_LIBRARY(popsift
popsift/popsift.cpp popsift/popsift.h
Expand Down Expand Up @@ -49,7 +49,7 @@ configure_file(popsift/sift_config.h.in
# BUILD_INTERFACE allows to include the directory with source only when target is
# built in the building tree (ie, not from an install location)
target_include_directories(popsift
PUBLIC ${Boost_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS}
PUBLIC ${CUDA_INCLUDE_DIRS}
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>")


Expand All @@ -58,7 +58,11 @@ set_target_properties(popsift PROPERTIES DEBUG_POSTFIX "d")

# cannot use PRIVATE here as there is a bug in FindCUDA and CUDA_ADD_LIBRARY
# https://gitlab.kitware.com/cmake/cmake/issues/16097
target_link_libraries(popsift ${Boost_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY} ${CUDA_CUBLAS_LIBRARIES})
target_link_libraries(popsift ${CUDA_CUDADEVRT_LIBRARY} ${CUDA_CUBLAS_LIBRARIES})

# Link to threads because we're using C++11 std::thread.
find_package(Threads REQUIRED)
target_link_libraries(popsift ${CMAKE_THREAD_LIBS_INIT})
Comment thread
simogasp marked this conversation as resolved.
Outdated


# EXPORTING THE LIBRARY
Expand Down
12 changes: 9 additions & 3 deletions src/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ endif()

find_package(DevIL COMPONENTS IL ILU) # yields IL_FOUND, IL_LIBRARIES, IL_INCLUDE_DIR

set(Boost_INCLUDE_DIRS "")
set(Boost_LIBRARIES "")
find_package(Boost 1.53.0 REQUIRED COMPONENTS filesystem program_options)
if(PopSift_BOOST_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif()
find_package(Boost 1.53.0 REQUIRED COMPONENTS filesystem program_options system)
if(WIN32)
add_definitions("-DBOOST_ALL_NO_LIB")
link_directories(Boost_LIBRARRY_DIR_DEBUG)
link_directories(Boost_LIBRARRY_DIR_RELEASE)
Comment thread
andrew-hardin marked this conversation as resolved.
Outdated
endif(WIN32)

set(PD_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
set(PD_LINK_LIBS ${Boost_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY})
Expand Down
49 changes: 49 additions & 0 deletions src/popsift/common/sync_queue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once

#include <condition_variable>
#include <mutex>
#include <queue>

namespace popsift {

/*************************************************************
* SyncQueue
* This is a basic alternative to the Boost sync_queue class.
* It lets threads push and pull items off a queue in a thread
* safe manner.
*************************************************************/
template<typename T>
class SyncQueue {
public:
SyncQueue() = default;

/* Push an item onto the queue and signal it's available. */
Comment thread
simogasp marked this conversation as resolved.
Outdated
void push(const T& value) {
std::unique_lock<std::mutex> lock(mtx_);
items_.push(value);
lock.unlock();
signal_.notify_one();
}

/* Check if the queue is empty - thread safety via mutex. */
bool empty() {
std::unique_lock<std::mutex> lock(mtx_);
return items_.empty();
}

/* BLOCKING. Pull an item off the queue, or, wait until one arrives. */
T pull() {
std::unique_lock<std::mutex> lock(mtx_);
signal_.wait(lock, [this] { return !items_.empty(); });
auto ans = items_.front();
items_.pop();
return ans;
}

private:
std::mutex mtx_;
std::queue<T> items_;
std::condition_variable signal_;
};

} // namespace popsift
12 changes: 7 additions & 5 deletions src/popsift/popsift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <cmath>
#include <cstring>
#include <fstream>

#include "popsift.h"
Expand All @@ -29,11 +31,11 @@ PopSift::PopSift( const popsift::Config& config, popsift::Config::ProcessingMode

configure( config, true );

_pipe._thread_stage1.reset( new boost::thread( &PopSift::uploadImages, this ));
_pipe._thread_stage1.reset( new std::thread( &PopSift::uploadImages, this ));
if( mode == popsift::Config::ExtractingMode )
_pipe._thread_stage2.reset( new boost::thread( &PopSift::extractDownloadLoop, this ));
_pipe._thread_stage2.reset( new std::thread( &PopSift::extractDownloadLoop, this ));
else
_pipe._thread_stage2.reset( new boost::thread( &PopSift::matchPrepareLoop, this ));
_pipe._thread_stage2.reset( new std::thread( &PopSift::matchPrepareLoop, this ));
}

PopSift::PopSift( ImageMode imode )
Expand All @@ -50,8 +52,8 @@ PopSift::PopSift( ImageMode imode )
_pipe._unused.push( new popsift::ImageFloat );
}

_pipe._thread_stage1.reset( new boost::thread( &PopSift::uploadImages, this ));
_pipe._thread_stage2.reset( new boost::thread( &PopSift::extractDownloadLoop, this ));
_pipe._thread_stage1.reset( new std::thread( &PopSift::uploadImages, this ));
_pipe._thread_stage2.reset( new std::thread( &PopSift::extractDownloadLoop, this ));
}

PopSift::~PopSift()
Expand Down
14 changes: 7 additions & 7 deletions src/popsift/popsift.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <stack>
#include <queue>
#include <future>
#include <boost/thread/thread.hpp>
#include <boost/thread/sync_queue.hpp>
#include <thread>

#include "common/sync_queue.h"
#include "sift_conf.h"
#include "sift_extremum.h"

Expand Down Expand Up @@ -74,11 +74,11 @@ class PopSift
{
struct Pipe
{
std::unique_ptr<boost::thread> _thread_stage1;
std::unique_ptr<boost::thread> _thread_stage2;
boost::sync_queue<SiftJob*> _queue_stage1;
boost::sync_queue<SiftJob*> _queue_stage2;
boost::sync_queue<popsift::ImageBase*> _unused;
std::unique_ptr<std::thread> _thread_stage1;
std::unique_ptr<std::thread> _thread_stage2;
popsift::SyncQueue<SiftJob*> _queue_stage1;
popsift::SyncQueue<SiftJob*> _queue_stage2;
popsift::SyncQueue<popsift::ImageBase*> _unused;

popsift::Pyramid* _pyramid{nullptr};

Expand Down