Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libeigen3-dev libpng-dev

- name: Configure
run: cd samples && mkdir build && cd build && cmake ..

- name: Build
run: cd samples/build && make -j

1 change: 1 addition & 0 deletions lib/gpc/Feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <gpc/buffer.hpp>
#include <iostream>
#include <iterator>
#include <gpc/filter.hpp>
#include <random>
#include <set>
#include <string>
Expand Down
39 changes: 25 additions & 14 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.6)

cmake_minimum_required(VERSION 3.10)
include(CheckCXXCompilerFlag)
include(CheckCXXSourceRuns)
project(openGPC CXX)
# Use C++11 features.
set (REQ_CPP11_FEATURES cxx_strong_enums cxx_auto_type)

set(CMAKE_CXX_STANDARD 11)
Expand All @@ -12,31 +12,42 @@ find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

#By default, use SSE intrinsics
option(SSE "SSE" ON)
option(SSE "Enable SSE/AVX optimizations if available" ON)

add_compile_options(-O3 -funroll-loops)
if(SSE)
add_definitions(-D_INTRINSICS_SSE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mavx2 -march=core-avx2 -lpthread -funroll-loops")
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -lpthread -funroll-loops")
message(STATUS "Checking if target CPU supports AVX2 instructions...")
check_cxx_source_runs("
#include <immintrin.h>
int main() {
__m256i x = _mm256_set1_epi32(1);
return _mm256_extract_epi32(x, 0);
}
" CPU_HAS_AVX2)

if(CPU_HAS_AVX2)
message(STATUS "AVX2: supported and enabled")
add_compile_definitions(_INTRINSICS_SSE)
add_compile_options(-mavx2 -march=core-avx2)
endif()
endif()

#find pnglib (used to load and store images for training and during evaluation)
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIRS})

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

#Add gpc header directy
include_directories("../lib")

#Three examples for GPC library
add_executable(extract extract.cpp)
target_link_libraries(extract ${PNG_LIBRARIES})
target_link_libraries(extract ${PNG_LIBRARIES} Threads::Threads)

add_executable(train train.cpp)
target_link_libraries(train ${PNG_LIBRARIES})

target_link_libraries(train ${PNG_LIBRARIES} Threads::Threads)

add_executable(sparsematch sparsematch.cpp)
target_link_libraries(sparsematch ${PNG_LIBRARIES})
target_link_libraries(sparsematch ${PNG_LIBRARIES} Threads::Threads)