Skip to content

Commit

Permalink
Avoid massive stack-allocs (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 authored Nov 17, 2024
1 parent d05b8ff commit 41d7868
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
if: github.event_name == 'push'

- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v4
with:
name: libmrcal-jar-${{ matrix.arch-name }}
path: |
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
env:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
name: Upload jar
with:
name: libmrcal-jar-pi
Expand Down Expand Up @@ -160,18 +160,18 @@ jobs:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
if: github.event_name == 'push'

- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v4
with:
name: libmrcal-jar-windowsx64
path: ${{ github.workspace }}/build/libs/*.jar

release:
needs: [build-host, build-raspi]
needs: [build-host, build-raspi, build-windows]
runs-on: ubuntu-22.04
steps:
# Download literally every single artifact. This also downloads client and docs,
# but the filtering below won't pick these up (I hope)
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4

- run: find

Expand All @@ -186,7 +186,7 @@ jobs:
if: github.event_name == 'push'

# Push to actual release, if tagged
- uses: softprops/action-gh-release@v1
- uses: softprops/action-gh-release@v2
with:
files: |
**/*
Expand Down
32 changes: 29 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/home/matt/github/mrcal-java/cmake_build/lib/libmrcal_jni.so",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "Python debug calibrate cameras",
"type": "debugpy",
Expand All @@ -12,8 +27,19 @@
"console": "integratedTerminal",
"cwd": "/home/matt/mrcal_debug_tmp/output_will/images-trimmed",
"args": [
"--corners-cache","corners.vnl","--lensmodel","LENSMODEL_OPENCV8","--focal","1200",
"--object-spacing","0.03","--object-width-n","18","--object-height-n","13","*.png"
"--corners-cache",
"corners.vnl",
"--lensmodel",
"LENSMODEL_OPENCV8",
"--focal",
"1200",
"--object-spacing",
"0.03",
"--object-width-n",
"18",
"--object-height-n",
"13",
"*.png"
],
"justMyCode": false
},
Expand Down Expand Up @@ -63,4 +89,4 @@
]
}
]
}
}
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ if (WITH_ASAN)
add_compile_options(-fsanitize=address -g -Wall -fsanitize=undefined)
endif ()


find_package(JNI)
if (JNI_FOUND)
# Fixes odd AWT dependency
Expand Down
12 changes: 8 additions & 4 deletions src/mrcal_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) Photon Vision.
*
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
Expand Down Expand Up @@ -115,7 +115,8 @@ static std::unique_ptr<mrcal_result> mrcal_calibrate(

// Copy from board/point pool above, using some code borrowed from
// mrcal-pywrap
mrcal_observation_board_t c_observations_board[Nobservations_board];
std::vector<mrcal_observation_board_t> observations_board_data(Nobservations_board);
auto c_observations_board = observations_board_data.data();
// Try to make sure we don't accidentally make a zero-length array or
// something stupid
mrcal_observation_point_t
Expand Down Expand Up @@ -176,8 +177,11 @@ static std::unique_ptr<mrcal_result> mrcal_calibrate(
// call optimize

// Residuals
double c_b_packed_final[Nstate];
double c_x_final[Nmeasurements];
std::vector<double> b_packed_final(Nstate);
auto c_b_packed_final = b_packed_final.data();

std::vector<double> x_final(Nmeasurements);
auto c_x_final = x_final.data();

// Seeds
double *c_intrinsics = intrinsics.data();
Expand Down

0 comments on commit 41d7868

Please sign in to comment.