Skip to content

Commit

Permalink
Update style and CI and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Kormanyos committed Mar 29, 2024
1 parent 37f43d7 commit 078630b
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 68 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/mandelbrot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022 - 2023.
# Copyright Christopher Kormanyos 2022 - 2024.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -22,10 +22,10 @@ jobs:
- compiler: clang++
clang_tidy: "clang-tidy"
container: johnmcfarlane/cnl_ci:clang-13-libcpp
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
container: ${{matrix.container}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install Boost
run: |
apt-get update --quiet
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
compiler: [ g++, clang++ ]
standard: [ c++14, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
compiler: [ g++ ]
standard: [ c++14, c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
compiler: [ g++ ]
standard: [ c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
compiler: [ g++ ]
standard: [ c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -327,7 +327,7 @@ jobs:
compiler: [ g++ ]
standard: [ c++20 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -386,7 +386,7 @@ jobs:
msvc-release-x64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -422,7 +422,7 @@ jobs:
git submodule update --init libs/variant2
./bootstrap.bat
./b2 headers
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.2
Expand All @@ -441,7 +441,7 @@ jobs:
msvc-release-x64-vs2022:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
Expand Down Expand Up @@ -477,7 +477,7 @@ jobs:
git submodule update --init libs/variant2
./bootstrap.bat
./b2 headers
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.3
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/mandelbrot_codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022.
# Copyright Christopher Kormanyos 2022 - 2024.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -14,7 +14,7 @@ on:
types: [opened, synchronize, reopened]
jobs:
gcc-gcov-native:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
defaults:
run:
shell: bash
Expand All @@ -24,7 +24,7 @@ jobs:
standard: [ c++14 ]
compiler: [ g++ ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
Expand All @@ -51,9 +51,10 @@ jobs:
lcov --remove coverage_unfiltered.info '/usr/*' '*boost/*' '*concurrency/*' '*/cfg/*' '*test_mandelbrot.cpp' '*mandelbrot_color.h' --output-file coverage.info
genhtml coverage.info --demangle-cpp --output-directory report
- name: upload-codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
files: ./coverage.info
plugin: gcov
file: ${{ runner.workspace }}/wide-integer/.gcov/make/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
functionalities: fix
verbose: false
10 changes: 5 additions & 5 deletions .github/workflows/mandelbrot_sonar.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022 - 2023.
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022 - 2024.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -21,9 +21,9 @@ jobs:
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
fetch-depth: 0
- name: clone-submods-bootstrap-headers-boost-develop
run: |
git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
cd ..
mkdir -p images/tmp
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
Expand Down
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@ $$z_{n+1} = z_{n}^2 + c$$

where $z_{0}=0$ and $z{\in}{\mathbb{C}}$ remains bounded.

ckormanyos/mandelbrot (this repository)
implements a header-only C++ template library for
extended precision Mandelbrot fractal iterations.
`ckormanyos/mandelbrot` implements a header-only C++ template library
for extended-precision Mandelbrot fractal iterations.

It is intended to be used for _deep_ _dives_ in the world of fractal iterations.
It is intended for _deep_ _dives_ in the world of fractal iterations.

Fractal iterations are carried out with high-precision
floating-point types such as those found in
[Boost.Multiprecison](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html).
[`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html).
Also fixed-point types having sufficient precision (although these have not yet been used or tested
extensively in this project) should work well.

## Design

This project uses [Boost.Multiprecison](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html)
This project uses [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html)
to implement
a high-precision Mandelbrot iteration and visualization.
Graphic file creation uses
[Boost.Gil](https://www.boost.org/doc/libs/1_83_0/libs/gil/doc/html/index.html) to wrap the JPEG-6b library (see [below](#Adaptions-of-and-Notes-on-jpeg-6b)).
[`Boost.Gil`](https://www.boost.org/doc/libs/1_83_0/libs/gil/doc/html/index.html) to wrap the JPEG-6b library (see [below](#Adaptions-of-and-Notes-on-jpeg-6b)).
Color-strething in combination with the histogram method
is used for creating vivid images. The default color
scheme uses stretched, amplified and modulated black
Expand All @@ -53,11 +52,11 @@ The multithreading dispatcher uses $(n-1)$
of the available CPU cores that can be found using hardware concurrency.

The following design goals have been incorporated.
- ckormanyos/mandelbrot is written in header-only C++14, and compatible through C++14, 17, 20, 23 and beyond.
- The inner loop performing the work of fractal iteration uses multiple, parallel CPU cores.
- `ckormanyos/mandelbrot` is written in header-only C++14, and compatible through C++14, 17, 20, 23 and beyond.
- The inner loop that performs the work of fractal iteration uses multiple, parallel CPU cores.
- C++ template design allows for flexible interchange of any appropriate kind of big-number type in the classes that implement fractal iteration.
- Visualization of the result uses color-stretching techniques combined with the histogram method.
- Graphical representation uses [Boost.Gil](https://www.boost.org/doc/libs/1_83_0/libs/gil/doc/html/index.html) in combination with the JPEG-6b library (see [below](#Adaptions-of-and-Notes-on-jpeg-6b)).
- Graphical representation uses [`Boost.Gil`](https://www.boost.org/doc/libs/1_83_0/libs/gil/doc/html/index.html) in combination with the JPEG-6b library (see [below](#Adaptions-of-and-Notes-on-jpeg-6b)).
- Color schemes can be easily adapted via straightforward creation (or modification) of a skinny derived class.

## Building the Project
Expand Down Expand Up @@ -114,7 +113,7 @@ mkdir -p images/tmp
```

In `*nix`, it is also possible to optionally make use of GMP
via Boost.Multiprecision's `gmp_float` backend
via `Boost.Multiprecision`'s `gmp_float` backend
(instead of the default `cpp_dec_float` backend).
When doing so, define `-DMANDELBROT_USE_GMP_FLOAT`
on the command line in the compile `test_mandelbrot.cpp` stage.
Expand All @@ -130,11 +129,11 @@ Improvements on the TODO list include (among others) the following.
## Sample Images

Several images are highlighted in the paragraphs below.
Please see the [gallery](./images/gallery) of ckormanyos/mandelbrot
Please see the [gallery](./images/gallery) of `ckormanyos/mandelbrot`
for a more comprehensive collection of images.

In these particular images presented from the [gallery](./images/gallery)
of ckormanyos/mandelbrot,
of `ckormanyos/mandelbrot`,
we have concentrated on various beautiful iteration results
represented in pure black-and-white/gray-scale tones.

Expand All @@ -149,7 +148,7 @@ This image has the following features and parameters.
- The square image has $2048 {\times} 2048$ pixels.
- Centered at the point $(-0.75,0.0)$.
- Uses a half-width of $1.25$.
- Computed with $2,000$ iteratons using the `cpp_dec_float` type from [Boost.Multiprecison](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $37$ decimal digits of precision.
- Computed with $2,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $37$ decimal digits of precision.

### Swirly Seahorses and Mini Mandelbrot

Expand All @@ -163,7 +162,7 @@ This image has the following features and parameters.
- The square image has $2048 {\times} 2048$ pixels.
- Centered at the point $(-0.7453983606667815,0.1125046349959942)$.
- Uses a half-width of $1.76{\times}10^{-12}$.
- Computed with $2,000$ iteratons using the `cpp_dec_float` type from [Boost.Multiprecison](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $37$ decimal digits of precision.
- Computed with $2,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $37$ decimal digits of precision.

### A Deep Dive

Expand All @@ -179,7 +178,7 @@ This image has the the following features and parameters.
- Centered at the point $(-1.2951890821477774570170641771856819267{\ldots},0.44093698267832013888090367835626261211{\ldots})$.
- See the configuration code [mandelbrot_cfg_MANDELBROT_09_DEEP_DIVE_02.h](./mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_09_DEEP_DIVE_02.h) for the full precision of the center point.
- Uses a half-width of $2.55{\times}10^{-55}$.
- Computed with $15,000$ iteratons using the `cpp_dec_float` type from [Boost.Multiprecison](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $95$ decimal digits of precision.
- Computed with $15,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $95$ decimal digits of precision.

### A Really Deep Dive

Expand All @@ -195,15 +194,15 @@ This image has the the following features and parameters.

- The square image has $1536 {\times} 1536$ pixels.
- Centered at the point $(0.3602404434376143632361252444495453084{\ldots},-0.6413130610648031748603750151793020665{\ldots})$.
- See the configuration code [mandelbrot_cfg_MANDELBROT_20_ZOOM_VERY_DEEP_00.h](./mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_20_ZOOM_VERY_DEEP_00.h) for the full precision of the center point provided with slightly more than $1,000$ decimal places.
- See the configuration code [`mandelbrot_cfg_MANDELBROT_20_ZOOM_VERY_DEEP_00.h`](./mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_20_ZOOM_VERY_DEEP_00.h) for the full precision of the center point provided with slightly more than $1,000$ decimal places.
- Uses a half-width of $4.4 {\times} 10^{-311}$.
- Computed with $60,000$ iteratons using the `gmp_float` type from [Boost.Multiprecison](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $365$ decimal digits of precision.
- Computed with $60,000$ iteratons using the `gmp_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_83_0/libs/multiprecision/doc/html/index.html) instantiated with $365$ decimal digits of precision.

## Using ckormanyos/mandelbrot
## Using `ckormanyos/mandelbrot`

ckormanyos/mandelbrot uses configuration files to specify the point,
`ckormanyos/mandelbrot` uses configuration files to specify the point,
size and depth of the iterative fractal calculation.
The configuration files are stored in the [mandelbrot/cfg](./mandelbrot/cfg)
The configuration files are stored in the [`mandelbrot/cfg`](./mandelbrot/cfg)
directory.

The code responsible for controlling the iterative calculation,
Expand All @@ -213,10 +212,10 @@ is written in a generic and configurable way.
To characterize a new Mandelbrot fractal iteration, simply write
a header-configuration-file with content similar to that shown below.
Include the configuration file in
[test_mandelbrot.cpp](./test/test_mandelbrot.cpp) and run the calculation.
[`test_mandelbrot.cpp`](./test/test_mandelbrot.cpp) and run the calculation.

Consider as a sample, for instance, the relevant content of the configuration file
[mandelbrot_cfg_MANDELBROT_01_FULL.h](./mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_01_FULL.h).
[`mandelbrot_cfg_MANDELBROT_01_FULL.h`](./mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_01_FULL.h).

```cpp
// This is the classic full immage.
Expand Down
63 changes: 63 additions & 0 deletions concurrency/stopwatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2013 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef STOPWATCH_2024_03_28_H
#define STOPWATCH_2024_03_28_H

#include <chrono>

template <class clock_type>
struct stopwatch
{
public:
using duration_type = typename clock_type::duration;

stopwatch() : m_start(clock_type::now()) { }

stopwatch(const stopwatch& other) : m_start(other.m_start) { }
stopwatch(stopwatch&& other) noexcept : m_start(other.m_start) { }

auto operator=(const stopwatch& other) -> stopwatch&
{
if(this != &other)
{
m_start = other.m_start;
}

return *this;
}

auto operator=(stopwatch&& other) noexcept -> stopwatch&
{
m_start = other.m_start;

return *this;
}

~stopwatch() { }

auto reset() -> void
{
m_start = clock_type::now();
}

template<typename RepresentationRequestedType>
static auto elapsed_time(const stopwatch& my_stopwatch) noexcept -> RepresentationRequestedType
{
return std::chrono::duration_cast<std::chrono::duration<float>>(my_stopwatch.elapsed()).count();
}

private:
typename clock_type::time_point m_start;

auto elapsed() const -> duration_type
{
return (clock_type::now() - m_start);
}
};

#endif // STOPWATCH_2024_03_28_H
5 changes: 3 additions & 2 deletions mandelbrot.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)jpeg\jpeg-6b-2022;$(SolutionDir);C:\boost\boost_1_83_0;$(SolutionDir)mpir\x64;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)jpeg\jpeg-6b-2022;$(SolutionDir);C:\boost\boost_1_84_0;$(SolutionDir)mpir\x64;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)jpeg\jpeg-6b-2022;$(SolutionDir);C:\boost\boost_1_83_0;$(SolutionDir)mpir\x64;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)jpeg\jpeg-6b-2022;$(SolutionDir);C:\boost\boost_1_84_0;$(SolutionDir)mpir\x64;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand Down Expand Up @@ -100,6 +100,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="concurrency\parallel_for.h" />
<ClInclude Include="concurrency\stopwatch.h" />
<ClInclude Include="mandelbrot\cfg\mandelbrot_cfg.h" />
<ClInclude Include="mandelbrot\cfg\mandelbrot_cfg_MANDELBROT_01_FULL.h" />
<ClInclude Include="mandelbrot\cfg\mandelbrot_cfg_MANDELBROT_03_TOP.h" />
Expand Down
3 changes: 3 additions & 0 deletions mandelbrot.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<ClInclude Include="mandelbrot\cfg\mandelbrot_cfg_MANDELBROT_14_ZOOM_WIKI_04.h">
<Filter>Source Files\mandelbrot\cfg</Filter>
</ClInclude>
<ClInclude Include="concurrency\stopwatch.h">
<Filter>Source Files\concurrency</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include=".clang-tidy" />
Expand Down
Loading

0 comments on commit 078630b

Please sign in to comment.