* build on windos

* WIN32 to MSVC

* CI

* fix CI

* verbose pytest

* cast to 64bit int

---------

Co-authored-by: tenteroring <tenteroring@tenteroring.org>
This commit is contained in:
koide3 2024-04-28 12:30:45 +09:00 committed by GitHub
parent 06114f860d
commit 0568057518
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 70 additions and 18 deletions

36
.github/workflows/build-windows.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Build(Windows)
on:
push:
branches: [ master ]
paths-ignore: '**.md'
pull_request:
branches: [ master ]
paths-ignore: '**.md'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- uses: crazy-max/ghaction-chocolatey@v3
with:
args: install cmake eigen
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- run: pip install numpy scipy pytest
- run: pip install .
- run: python -m pytest src/test/python_test.py -v

View File

@ -82,6 +82,11 @@ if(BUILD_WITH_MARCH_NATIVE)
add_compile_options(-march=native)
endif()
if(MSVC)
add_compile_definitions(_USE_MATH_DEFINES)
add_compile_options(/openmp:llvm)
endif()
##############
## Coverage ##
##############
@ -127,6 +132,9 @@ if(BUILD_PYTHON_BINDINGS)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(small_gicp_python
src/small_gicp/registration/registration.cpp
src/small_gicp/registration/registration_helper.cpp
src/python/pointcloud.cpp
src/python/kdtree.cpp
src/python/voxelmap.cpp
@ -138,8 +146,15 @@ if(BUILD_PYTHON_BINDINGS)
src/python/python.cpp
)
target_include_directories(small_gicp_python PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(small_gicp_python PUBLIC
Eigen3::Eigen
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
)
set_target_properties(small_gicp_python PROPERTIES OUTPUT_NAME small_gicp)
target_link_libraries(small_gicp_python PRIVATE small_gicp)
endif()
###############
@ -293,7 +308,7 @@ if(BUILD_PYTHON_BINDINGS)
elseif(NOT DEFINED PYTHON_INSTALL_DIR)
set(PYTHON_INSTALL_DIR lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
endif()
install(TARGETS small_gicp_python small_gicp
install(TARGETS small_gicp_python
LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}
COMPONENT python
)

View File

@ -141,7 +141,7 @@ public:
inline size_t calc_index(const size_t voxel_id, const size_t point_id) const { return (voxel_id << point_id_bits) | point_id; }
inline size_t voxel_id(const size_t i) const { return i >> point_id_bits; } ///< Extract the point ID from an index
inline size_t point_id(const size_t i) const { return i & ((1ul << point_id_bits) - 1); } ///< Extract the voxel ID from an index
inline size_t point_id(const size_t i) const { return i & ((1ull << point_id_bits) - 1); } ///< Extract the voxel ID from an index
public:
static_assert(sizeof(size_t) == 8, "size_t must be 64-bit");

View File

@ -50,7 +50,7 @@ static void write_points(const std::string& filename, const std::vector<Eigen::V
/// @param filename Filename
/// @return Points
static std::vector<Eigen::Vector4f> read_ply(const std::string& filename) {
std::ifstream ifs(filename);
std::ifstream ifs(filename, std::ios::binary);
if (!ifs) {
std::cerr << "error: failed to open " << filename << std::endl;
return {};

View File

@ -30,7 +30,7 @@ struct ParallelReductionOMP {
std::vector<double> es(num_threads, 0.0);
#pragma omp parallel for num_threads(num_threads) schedule(guided, 8)
for (size_t i = 0; i < factors.size(); i++) {
for (std::int64_t i = 0; i < factors.size(); i++) {
Eigen::Matrix<double, 6, 6> H;
Eigen::Matrix<double, 6, 1> b;
double e;
@ -59,7 +59,7 @@ struct ParallelReductionOMP {
double sum_e = 0.0;
#pragma omp parallel for num_threads(num_threads) schedule(guided, 8) reduction(+ : sum_e)
for (size_t i = 0; i < factors.size(); i++) {
for (std::int64_t i = 0; i < factors.size(); i++) {
sum_e += factors[i].error(target, source, T);
}
return sum_e;

View File

@ -40,9 +40,9 @@ std::shared_ptr<OutputPointCloud> voxelgrid_sampling(const InputPointCloud& poin
// Compute voxel coord bits (0|1bit, z|21bit, y|21bit, x|21bit)
const std::uint64_t bits = //
((coord[0] & coord_bit_mask) << (coord_bit_size * 0)) | //
((coord[1] & coord_bit_mask) << (coord_bit_size * 1)) | //
((coord[2] & coord_bit_mask) << (coord_bit_size * 2));
(static_cast<std::uint64_t>(coord[0] & coord_bit_mask) << (coord_bit_size * 0)) | //
(static_cast<std::uint64_t>(coord[1] & coord_bit_mask) << (coord_bit_size * 1)) | //
(static_cast<std::uint64_t>(coord[2] & coord_bit_mask) << (coord_bit_size * 2));
coord_pt[i] = {bits, i};
}

View File

@ -31,7 +31,7 @@ std::shared_ptr<OutputPointCloud> voxelgrid_sampling_omp(const InputPointCloud&
std::vector<std::pair<std::uint64_t, size_t>> coord_pt(traits::size(points));
#pragma omp parallel for num_threads(num_threads) schedule(guided, 32)
for (size_t i = 0; i < traits::size(points); i++) {
for (std::int64_t i = 0; i < traits::size(points); i++) {
const Eigen::Array4i coord = fast_floor(traits::point(points, i) * inv_leaf_size) + coord_offset;
if ((coord < 0).any() || (coord > coord_bit_mask).any()) {
std::cerr << "warning: voxel coord is out of range!!" << std::endl;
@ -40,9 +40,9 @@ std::shared_ptr<OutputPointCloud> voxelgrid_sampling_omp(const InputPointCloud&
}
// Compute voxel coord bits (0|1bit, z|21bit, y|21bit, x|21bit)
const std::uint64_t bits = //
((coord[0] & coord_bit_mask) << (coord_bit_size * 0)) | //
((coord[1] & coord_bit_mask) << (coord_bit_size * 1)) | //
((coord[2] & coord_bit_mask) << (coord_bit_size * 2));
(static_cast<std::uint64_t>(coord[0] & coord_bit_mask) << (coord_bit_size * 0)) | //
(static_cast<std::uint64_t>(coord[1] & coord_bit_mask) << (coord_bit_size * 1)) | //
(static_cast<std::uint64_t>(coord[2] & coord_bit_mask) << (coord_bit_size * 2));
coord_pt[i] = {bits, i};
}
@ -61,7 +61,7 @@ std::shared_ptr<OutputPointCloud> voxelgrid_sampling_omp(const InputPointCloud&
std::atomic_uint64_t num_points = 0;
#pragma omp parallel for num_threads(num_threads) schedule(guided, 4)
for (size_t block_begin = 0; block_begin < traits::size(points); block_begin += block_size) {
for (std::int64_t block_begin = 0; block_begin < traits::size(points); block_begin += block_size) {
std::vector<Eigen::Vector4d> sub_points;
sub_points.reserve(block_size);

View File

@ -41,9 +41,9 @@ std::shared_ptr<OutputPointCloud> voxelgrid_sampling_tbb(const InputPointCloud&
// Compute voxel coord bits (0|1bit, z|21bit, y|21bit, x|21bit)
const std::uint64_t bits = //
((coord[0] & coord_bit_mask) << (coord_bit_size * 0)) | //
((coord[1] & coord_bit_mask) << (coord_bit_size * 1)) | //
((coord[2] & coord_bit_mask) << (coord_bit_size * 2));
(static_cast<std::uint64_t>(coord[0] & coord_bit_mask) << (coord_bit_size * 0)) | //
(static_cast<std::uint64_t>(coord[1] & coord_bit_mask) << (coord_bit_size * 1)) | //
(static_cast<std::uint64_t>(coord[2] & coord_bit_mask) << (coord_bit_size * 2));
coord_pt[i] = {bits, i};
}
});

View File

@ -20,7 +20,7 @@ template <typename Setter, typename PointCloud, typename KdTree>
void estimate_local_features_omp(PointCloud& cloud, KdTree& kdtree, int num_neighbors, int num_threads) {
traits::resize(cloud, traits::size(cloud));
#pragma omp parallel for num_threads(num_threads)
for (size_t i = 0; i < traits::size(cloud); i++) {
for (std::int64_t i = 0; i < traits::size(cloud); i++) {
estimate_local_features<Setter>(cloud, kdtree, num_neighbors, i);
}
}

View File

@ -28,6 +28,7 @@ wheel.py-api = "cp312" # Build stable ABI wheels for CPython 3.12+
[tool.scikit-build.cmake.define]
BUILD_PYTHON_BINDINGS = true
BUILD_HELPER = false
BUILD_SHARED_LIBS = false
[tool.cibuildwheel]