Skip to content

Commit 25cf489

Browse files
authored
Merge pull request #203 from ckormanyos/syntax_and_docs
Update some syntax and docs
2 parents 0032a78 + ee135cb commit 25cf489

File tree

4 files changed

+37
-41
lines changed

4 files changed

+37
-41
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ It is intended for _deep_ _dives_ in the Mandelbrot fractal world.
3131

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

@@ -42,10 +42,10 @@ for deep dives.
4242

4343
## Design
4444

45-
This project uses [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_86_0/libs/multiprecision/doc/html/index.html)
45+
This project uses [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_89_0/libs/multiprecision/doc/html/index.html)
4646
to implement a high-precision Mandelbrot iteration and visualization.
4747
Graphic file creation uses
48-
[`Boost.Gil`](https://www.boost.org/doc/libs/1_86_0/libs/gil/doc/html/index.html).
48+
[`Boost.Gil`](https://www.boost.org/doc/libs/1_89_0/libs/gil/doc/html/index.html).
4949
Color-stretching in combination with the histogram method
5050
is used for creating vivid images. The default color
5151
scheme uses stretched, amplified and modulated black
@@ -61,7 +61,7 @@ The following design goals have been incorporated.
6161
- C++ template design allows for flexible interchange of any appropriate kind of big-number type in the classes that implement fractal iteration.
6262
- The iterative scheme is implemented as a flexible run-time polymorphic function. This allows for the implementation and interchange of multiple kinds of iterative methods, each one realized within its own individual generator class. These can be specifically optimized for the particular iterative case at hand.
6363
- Visualization of the result uses color-stretching techniques combined with the histogram method.
64-
- Graphical representation uses [`Boost.Gil`](https://www.boost.org/doc/libs/1_86_0/libs/gil/doc/html/index.html) in combination with the JPEG-6b library (see [below](#Adaptions-of-and-Notes-on-jpeg-6b)).
64+
- Graphical representation uses [`Boost.Gil`](https://www.boost.org/doc/libs/1_89_0/libs/gil/doc/html/index.html) in combination with the JPEG-6b library (see [below](#Adaptions-of-and-Notes-on-jpeg-6b)).
6565
- Imaging also uses specialized versions of the [libpng](http://www.libpng.org/pub/png) library and the [zlib](https://www.zlib.net) library, in particular [libpng-1.6.44](https://github.com/pnggroup/libpng) and [zlib-1.3.1.1](https://github.com/madler/zlib), with further notes on adaptions still pending.
6666
- Color schemes can be easily adapted via straightforward creation (or modification) of a skinny derived class.
6767

@@ -104,7 +104,7 @@ make the needed output image directory and run `test_mandelbrot.exe` as shown ab
104104

105105
To optionally use `gmp_float`, the [GMP](https://gmplib.org) big-number backend,
106106
instead of `cpp_dec_float`, where both backends are from
107-
[`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_86_0/libs/multiprecision/doc/html/index.html),
107+
[`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_89_0/libs/multiprecision/doc/html/index.html),
108108
simply use [`build_all_gmp.sh`](./build_all_gmp.sh)
109109

110110
```bash
@@ -143,7 +143,7 @@ This image has the following features and parameters.
143143
- The square image has $2048 {\times} 2048$ pixels.
144144
- Centered at the point $(-0.75+i~0.0)$.
145145
- Uses a half-width of $1.35$.
146-
- Computed with $2,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_86_0/libs/multiprecision/doc/html/index.html) instantiated with $37$ decimal digits of precision.
146+
- Computed with $2,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_89_0/libs/multiprecision/doc/html/index.html) instantiated with $37$ decimal digits of precision.
147147

148148
### Swirly Seahorses and Mini Mandelbrot
149149

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

162162
### A Deep Dive
163163

@@ -173,7 +173,7 @@ This image has the the following features and parameters.
173173
- Centered at the point $(-1.2951890821477774570170641771856819267{\ldots}+i~0.44093698267832013888090367835626261211{\ldots})$.
174174
- See the configuration code [mandelbrot_cfg_MANDELBROT_09_DEEP_DIVE_02.h](https://github.com/ckormanyos/mandelbrot/tree/main/mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_09_DEEP_DIVE_02.h) for the full precision of the center point.
175175
- Uses a half-width of $2.55{\times}10^{-55}$.
176-
- Computed with $15,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_86_0/libs/multiprecision/doc/html/index.html) instantiated with $95$ decimal digits of precision.
176+
- Computed with $15,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_89_0/libs/multiprecision/doc/html/index.html) instantiated with $95$ decimal digits of precision.
177177

178178
### A Deeper Dive
179179

@@ -189,7 +189,7 @@ This image has the the following features and parameters.
189189
- Centered at the point $(-1.7683830049648722692890015019043698317{\ldots}-i~0.0035564756051580419085635598914228270{\ldots})$.
190190
- See the configuration code [mandelbrot_cfg_MANDELBROT_60_SATELITE_REGION_01.h](https://github.com/ckormanyos/mandelbrot/tree/main/mandelbrot/cfg/mandelbrot_cfg_MANDELBROT_60_SATELITE_REGION_01.h) for the full precision of the center point.
191191
- Uses a half-width of $8.1{\times}10^{-95}$.
192-
- Computed with $60,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_86_0/libs/multiprecision/doc/html/index.html) instantiated with $95$ decimal digits of precision.
192+
- Computed with $60,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_89_0/libs/multiprecision/doc/html/index.html) instantiated with $95$ decimal digits of precision.
193193

194194
### A Really Deep Dive
195195

@@ -207,7 +207,7 @@ This image has the the following features and parameters.
207207
- Centered at the point $(0.3602404434376143632361252444495453084{\ldots}-i~0.6413130610648031748603750151793020665{\ldots})$.
208208
- See the configuration code [`mandelbrot_cfg_MANDELBROT_20_ZOOM_VERY_DEEP_00.h`](https://github.com/ckormanyos/mandelbrot/tree/main/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.
209209
- Uses a half-width of $4.4 {\times} 10^{-311}$.
210-
- Computed with $60,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_86_0/libs/multiprecision/doc/html/index.html) in combination with low-order perturbative iteration having $24$ decimal digits of precision. The central point of the calculation is instantiated with $365$ decimal digits of precision.
210+
- Computed with $60,000$ iteratons using the `cpp_dec_float` type from [`Boost.Multiprecision`](https://www.boost.org/doc/libs/1_89_0/libs/multiprecision/doc/html/index.html) in combination with low-order perturbative iteration having $24$ decimal digits of precision. The central point of the calculation is instantiated with $365$ decimal digits of precision.
211211

212212
## Using `ckormanyos/mandelbrot`
213213

@@ -381,7 +381,7 @@ of _the_ _Independent_ _JPEG_ _Group's_ _software_.
381381

382382
The following adaptions have been performed.
383383

384-
- Test/compile only the subset of functions empirically found to be needed for use with [Boost.Gil](https://www.boost.org/doc/libs/1_86_0/libs/gil/doc/html/index.html).
384+
- Test/compile only the subset of functions empirically found to be needed for use with [Boost.Gil](https://www.boost.org/doc/libs/1_89_0/libs/gil/doc/html/index.html).
385385
- Adapt to VS compiler and VS solution workspace (when building with MSVC).
386386
- Use GNUmake to build the JPEG library (when building on `*nix`).
387387
- Run the `*.c`/`*.h` files through the [Artistic Style](http://astyle.sourceforge.net/astyle.html) automatic code formatter, using a version of _AStyle_ from somewhere around 2015.
@@ -395,8 +395,8 @@ The following adaptions have been performed.
395395
The
396396
[`MandelbrotDiscovery`](https://github.com/ckormanyos/mandelbrot/tree/main/MandelbrotDiscovery)
397397
program aims to provide semi-automatic assistance
398-
to find interesting points for fractal deep dives.
398+
to find interesting points for deep fractal dives.
399399

400400
This project is work in progress and further enhancements are planned.
401-
__Mandelbrot_ _Discovery_ can, however, be used today for successfully
401+
Mandelbrot Discovery can, however, be used today for successfully
402402
navigating and finding interesting points for deep dives.

concurrency/parallel_for.h

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,19 @@
1717
{
1818
template<typename index_type,
1919
typename callable_function_type>
20-
auto parallel_for(index_type first,
21-
index_type last,
20+
auto parallel_for(index_type first,
21+
index_type last,
2222
callable_function_type parallel_function) -> void
2323
{
2424
// Estimate the number of threads available.
25-
const auto number_of_threads_hint =
26-
static_cast<signed>
27-
(
28-
std::thread::hardware_concurrency()
29-
);
25+
const auto number_of_threads_hint = static_cast<signed>(std::thread::hardware_concurrency());
3026

3127
const auto number_of_threads = // NOLINT(altera-id-dependent-backward-branch)
3228
static_cast<unsigned>
3329
(
3430
(std::max)
3531
(
36-
static_cast<signed>(number_of_threads_hint - signed { INT8_C(1) }),
32+
static_cast<signed>(number_of_threads_hint - INT8_C(1)),
3733
static_cast<signed>(INT8_C(1))
3834
)
3935
);
@@ -58,26 +54,25 @@
5854

5955
{
6056
// Set the size (distance) for the range functions.
61-
const auto n_distance =
62-
static_cast<index_type>
63-
(
64-
static_cast<index_type>(last - first)
65-
);
57+
const auto n_distance { index_type { last - first } };
6658

6759
using std::floor;
6860

69-
const auto slice =
70-
(std::max)
71-
(
72-
static_cast<index_type>(floor(static_cast<float>(n_distance) / static_cast<float>(number_of_threads))),
73-
static_cast<index_type>(1)
74-
);
61+
const auto
62+
slice
63+
{
64+
(std::max)
65+
(
66+
static_cast<index_type>(floor(static_cast<float>(n_distance) / static_cast<float>(number_of_threads))),
67+
static_cast<index_type>(1)
68+
)
69+
};
7570

7671
for(auto idx = static_cast<index_type>(0);
7772
idx < static_cast<index_type>(number_of_threads); // NOLINT(altera-id-dependent-backward-branch)
7873
++idx)
7974
{
80-
index_type total_lines = slice;
75+
index_type total_lines { slice };
8176

8277
if(idx < static_cast<index_type>(last % static_cast<index_type>(number_of_threads)))
8378
{
@@ -100,20 +95,21 @@
10095
}
10196
}
10297

98+
// LCOV_EXCL_START
10399
// Provide a serial version for easy comparison.
104100
template<typename index_type,
105101
typename callable_function_type>
106-
auto sequential_for(index_type first,
107-
index_type last,
102+
auto sequential_for(index_type first,
103+
index_type last,
108104
callable_function_type sequential_function) -> void
109105
{
110-
// LCOV_EXCL_START
111106
for(auto idx = first; idx < last; ++idx)
112107
{
113108
sequential_function(idx);
114109
}
115-
// LCOV_EXCL_STOP
116110
}
111+
// LCOV_EXCL_STOP
112+
117113
} // namespace my_concurrency
118114

119115
#endif // CONCURRENCY_PARALLEL_FOR_H

mandelbrot/mandelbrot_generator_perturbative.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
y_coord.size(),
167167
[&mandelbrot_iteration_lock, &unordered_parallel_row_count, &my_text_output, &x_coord, &y_coord, &zkr, &zki, this](std::size_t j_row)
168168
{
169-
while(mandelbrot_iteration_lock.test_and_set())
169+
while(mandelbrot_iteration_lock.test_and_set(std::memory_order_acquire))
170170
{
171171
// Wait to acquire the lock.
172172
}
@@ -206,7 +206,7 @@
206206
static_cast<void>(my_text_output.write(str_calc));
207207
}
208208

209-
mandelbrot_iteration_lock.clear();
209+
mandelbrot_iteration_lock.clear(std::memory_order_release);
210210

211211
for(auto i_col = static_cast<std::size_t>(UINT8_C(0));
212212
i_col < x_coord.size(); // NOLINT(altera-id-dependent-backward-branch)

mandelbrot/mandelbrot_generator_trivial.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
y_coord.size(),
9393
[&mandelbrot_iteration_lock, &unordered_parallel_row_count, &my_text_output, &x_coord, &y_coord, this](std::size_t j_row)
9494
{
95-
while(mandelbrot_iteration_lock.test_and_set())
95+
while(mandelbrot_iteration_lock.test_and_set(std::memory_order_acquire))
9696
{
9797
// Wait to acquire the lock.
9898
}
@@ -136,7 +136,7 @@
136136
static_cast<void>(my_text_output.write(str_calc));
137137
}
138138

139-
mandelbrot_iteration_lock.clear();
139+
mandelbrot_iteration_lock.clear(std::memory_order_release);
140140

141141
for(auto i_col = static_cast<std::size_t>(UINT8_C(0));
142142
i_col < x_coord.size(); // NOLINT(altera-id-dependent-backward-branch)

0 commit comments

Comments
 (0)