mirror of
https://gitlab.com/Trygve/contour-creator.git
synced 2024-12-04 21:10:17 +00:00
Compare commits
4 Commits
e287323332
...
e457adf244
Author | SHA1 | Date | |
---|---|---|---|
e457adf244 | |||
6469a26cf1 | |||
|
c94a59616a | ||
|
781b96215a |
2
Doxyfile
2
Doxyfile
@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8
|
||||
# title of most generated pages and in a few other places.
|
||||
# The default value is: My Project.
|
||||
|
||||
PROJECT_NAME = "Marching Squares"
|
||||
PROJECT_NAME = "Contour Creator"
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
|
20
README.md
20
README.md
@ -6,8 +6,19 @@ This is our project for the INF205: Resource-efficient programming course
|
||||
- [x] Run the marching squares algorithm and produce a "cellmap"
|
||||
- [ ] Use a lookuptable to produce a vector file from the "cellmap"
|
||||
## Dependencies
|
||||
- GDAL
|
||||
- GDAL >= 3.5
|
||||
- OpenMP
|
||||
- CMake
|
||||
|
||||
If you want to clone the repo with the example files you need [git-lfs](https://git-lfs.com/) installed and activated with ´git lfs install´
|
||||
To install the packages on Fedora run
|
||||
```
|
||||
dnf install g++ git-lfs cmake gdal-devel
|
||||
```
|
||||
on Debian:
|
||||
```
|
||||
apt install g++ git-lfs cmake libgdal-dev
|
||||
```
|
||||
## How to build:
|
||||
```
|
||||
mkdir build
|
||||
@ -15,4 +26,9 @@ cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
cmake --build . --parallel
|
||||
```
|
||||
Then you can run `./contour-creator PATH/TO/HEIGTHMAP.TIF`
|
||||
Then you can run `./contour-creator PATH/TO/HEIGTHMAP.TIF`
|
||||
Run an example file: `./contour-creator "../example_files/Follo 2014-dtm.tif"`
|
||||
Currently the program outputs to ´out.shp´ in the current directory.
|
||||
|
||||
## Docs
|
||||
[Doxygen output](https://trygve.gitlab.io/contour-creator/)
|
@ -113,7 +113,7 @@
|
||||
</Property>
|
||||
<Class id="4a8d98db-e76f-11ee-9ded-8bb162b1502a">
|
||||
<name>
|
||||
<val>Cells</val>
|
||||
<val>Cell</val>
|
||||
</name>
|
||||
<ownedAttribute>
|
||||
<reflist>
|
||||
|
@ -35,9 +35,6 @@
|
||||
<g id="glyph-0-10">
|
||||
<path d="M 1.171875 -10.640625 L 3.625 -10.640625 L 3.625 0 L 1.171875 0 Z M 1.171875 -10.640625 "/>
|
||||
</g>
|
||||
<g id="glyph-0-11">
|
||||
<path d="M 7.15625 -7.421875 L 7.15625 -5.5625 C 6.632812 -5.78125 6.128906 -5.941406 5.640625 -6.046875 C 5.148438 -6.160156 4.691406 -6.21875 4.265625 -6.21875 C 3.796875 -6.21875 3.445312 -6.15625 3.21875 -6.03125 C 3 -5.914062 2.890625 -5.738281 2.890625 -5.5 C 2.890625 -5.300781 2.972656 -5.148438 3.140625 -5.046875 C 3.304688 -4.941406 3.613281 -4.863281 4.0625 -4.8125 L 4.484375 -4.765625 C 5.742188 -4.597656 6.585938 -4.332031 7.015625 -3.96875 C 7.453125 -3.601562 7.671875 -3.03125 7.671875 -2.25 C 7.671875 -1.4375 7.367188 -0.820312 6.765625 -0.40625 C 6.160156 0 5.265625 0.203125 4.078125 0.203125 C 3.566406 0.203125 3.039062 0.160156 2.5 0.078125 C 1.96875 -0.00390625 1.414062 -0.125 0.84375 -0.28125 L 0.84375 -2.140625 C 1.332031 -1.898438 1.832031 -1.71875 2.34375 -1.59375 C 2.851562 -1.476562 3.375 -1.421875 3.90625 -1.421875 C 4.382812 -1.421875 4.742188 -1.488281 4.984375 -1.625 C 5.222656 -1.757812 5.34375 -1.957031 5.34375 -2.21875 C 5.34375 -2.4375 5.257812 -2.597656 5.09375 -2.703125 C 4.925781 -2.804688 4.597656 -2.890625 4.109375 -2.953125 L 3.671875 -3.015625 C 2.578125 -3.148438 1.8125 -3.398438 1.375 -3.765625 C 0.9375 -4.140625 0.71875 -4.703125 0.71875 -5.453125 C 0.71875 -6.265625 0.992188 -6.863281 1.546875 -7.25 C 2.109375 -7.644531 2.960938 -7.84375 4.109375 -7.84375 C 4.566406 -7.84375 5.039062 -7.804688 5.53125 -7.734375 C 6.03125 -7.671875 6.570312 -7.566406 7.15625 -7.421875 Z M 7.15625 -7.421875 "/>
|
||||
</g>
|
||||
<g id="glyph-1-0">
|
||||
<path d="M 6.4375 -8.78125 L 6.4375 -4.96875 L 10.25 -4.96875 L 10.25 -3.8125 L 6.4375 -3.8125 L 6.4375 0 L 5.296875 0 L 5.296875 -3.8125 L 1.484375 -3.8125 L 1.484375 -4.96875 L 5.296875 -4.96875 L 5.296875 -8.78125 Z M 6.4375 -8.78125 "/>
|
||||
</g>
|
||||
@ -251,11 +248,10 @@
|
||||
</g>
|
||||
<path fill="none" stroke-width="2" stroke-linecap="butt" stroke-linejoin="round" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 0.00103399 0 L 311.001034 0 L 311.001034 117 L 0.00103399 117 Z M 0.00103399 0 Z M 0.00103399 0 " transform="matrix(1, 0, 0, 1, 363.924747, 26.042969)"/>
|
||||
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
|
||||
<use xlink:href="#glyph-0-9" x="500.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-1" x="510.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-10" x="519.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-10" x="524.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-11" x="529.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-9" x="504.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-1" x="514.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-10" x="523.925781" y="57.042969"/>
|
||||
<use xlink:href="#glyph-0-10" x="528.925781" y="57.042969"/>
|
||||
</g>
|
||||
<path fill="none" stroke-width="2" stroke-linecap="butt" stroke-linejoin="round" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 0.00103399 41 L 311.001034 41 " transform="matrix(1, 0, 0, 1, 363.924747, 26.042969)"/>
|
||||
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
|
||||
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 41 KiB |
@ -1,18 +1,59 @@
|
||||
# 29. Glossary:
|
||||
% INF205 Lab 5
|
||||
% Esther and Trygve
|
||||
% April 23 2024
|
||||
|
||||
# 29. Glossary contributions:
|
||||
## dynamic library
|
||||
Dynamic libraries are libraries are pre compiled and often provided by the operating system, as opposed to compiling it as part of your project. This saves space as each program dont need its own "copy".
|
||||
Dynamic libraries are libraries that are pre compiled and often provided by the operating system, as opposed to compiling them as part of your project. This saves space as each program dont need its own "copy".
|
||||
|
||||
## command-line arguments
|
||||
Command-line arguments are extra commands that we enter after the program's executable name so that the functionality of the program changes.
|
||||
|
||||
|
||||
# 30. Draft slides:
|
||||
See slides.pdf
|
||||
|
||||
# 31. Basic functionality and validation per
|
||||
...
|
||||
|
||||
We ran a simple benchmark against gdal_contour as the reference implementation using `time` in the shell. My laptop has a 6 core AMD Ryzen 5 PRO 5675U running linux 6.8. The average of three tests was:
|
||||
```
|
||||
Ours: 33,53 s
|
||||
Reference: 4,46 s
|
||||
```
|
||||
This is despite the reference gdal implementation beinge single threaded and our being paritally paralell. We think we will gaing a significant speedup from optimizing the part of he program drawing the contours into a file. Right now its a placeholder that just creates points, not lines.
|
||||
This innital gap in performance leaves us a lot of room to improve and it will be interesting to see what the final performance will be.
|
||||
The plan is to create a more sophisticated benchmark program in c++, but for now we just use the time command
|
||||
|
||||
Memory usage is also very big because of our datastructure for CellMap. It is storing essentially a line in a 2d array, so most of the items are 0. We will try to fix this by making a cell type that stores its coordinates or by getting rid of the cellmap entirely.
|
||||
|
||||
The source code is available at [https://gitlab.com/Trygve/contour-creator](https://gitlab.com/Trygve/contour-creator) with instructions in the readme for building and running.
|
||||
If you want to view the .shp file you can use this simple webapp: [https://mapshaper.org/](https://mapshaper.org/)
|
||||
|
||||
# 32 Special interest functionality and responsibilities
|
||||
Per now we dont have time to add any extra functionality.
|
||||
It does not seem like we will have time to add any extra functionality.
|
||||
|
||||
33. Programming project: Progress on data structure implementation
|
||||
# 33. Programming project: Progress on data structure implementation
|
||||
|
||||
...
|
||||
![ER diagram](ER_diagram.svg)
|
||||
|
||||
34. Parallelization
|
||||
We need to create destructors to call free on data in HeightMap and cells in Cells as those are arrays allocated with malloc. The default copy behaviur is fine for our program.
|
||||
|
||||
\newpage
|
||||
|
||||
# 34. Parallelization
|
||||
We are using openMP because we want multiple threads using the same data and the files are small enough to fit into memory (~500mb). To scale it to multiple machines we would use mpi to distrubute seperate iamge tiles to each node.
|
||||
We haven't had time to test the performance and we have only parallelized half of what is possible. But we can see that it is using all the cores.
|
||||
The following code was used for parallelization using openMP, each thread produces one "layer" of the cellmap:
|
||||
```cpp
|
||||
#pragma omp parallel
|
||||
{
|
||||
std::vector<CellMap> vec_private;
|
||||
#pragma omp for
|
||||
for (int i = 1; i <= num_contours; i++)
|
||||
{
|
||||
vec_private.push_back(produce_cellmap(heightmap, heightmap->min + interval*i));
|
||||
}
|
||||
#pragma omp critical
|
||||
vector_contours.insert(vector_contours.end(), vec_private.begin(), vec_private.end());
|
||||
}
|
||||
```
|
20
documentation/slides.md
Normal file
20
documentation/slides.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
title:
|
||||
- "INF205: creating contours using the marching squares algorithm"
|
||||
author:
|
||||
- Trygve og Esther
|
||||
|
||||
---
|
||||
# What are contours
|
||||
|
||||
# Output of our program
|
||||
pretty pictures
|
||||
|
||||
# The logical flow of our program
|
||||
flowchart
|
||||
|
||||
# GDAL
|
||||
What is it?
|
||||
|
||||
# Performance
|
||||
show the benchmarks
|
@ -42,7 +42,6 @@ std::vector<CellMap> vector_cellmap(HeightMap* heightmap, int interval)
|
||||
for (int i = 1; i <= num_contours; i++)
|
||||
{
|
||||
vec_private.push_back(produce_cellmap(heightmap, heightmap->min + interval*i));
|
||||
std::cout << "Execute thread " << omp_get_num_threads() << " ";
|
||||
}
|
||||
#pragma omp critical
|
||||
vector_contours.insert(vector_contours.end(), vec_private.begin(), vec_private.end());
|
||||
|
Loading…
Reference in New Issue
Block a user