Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Andreas Kempe
mpi-mandelbrot
Commits
653cc12a
Commit
653cc12a
authored
Oct 01, 2015
by
Andreas Kempe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified the mandelbrot colouring.
parent
fa94b49b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
main.cpp
main.cpp
+11
-11
No files found.
main.cpp
View file @
653cc12a
...
...
@@ -20,7 +20,7 @@ using namespace Magick;
struct
MandelResult
{
unsigned
long
end_iterations
;
float
end_iterations
;
bool
belongs
;
MandelResult
(
unsigned
long
end_iterations
,
bool
belongs
)
:
...
...
@@ -48,7 +48,7 @@ MandelResult IsMandelbrotPoint(unsigned long x, unsigned long y, unsigned int it
for
(
unsigned
long
i
=
0
;
i
<
iterations
;
++
i
)
{
if
(
real
(
series_value
)
*
real
(
series_value
)
+
imag
(
series_value
)
*
imag
(
series_value
)
>=
4
)
return
MandelResult
(
abs
(
series_value
),
false
);
return
MandelResult
(
i
+
1
-
log
(
log
(
abs
(
pow
(
series_value
,
2
)
+
point
)))
/
log
(
2
),
false
);
series_value
=
pow
(
series_value
,
2
)
+
point
;
}
...
...
@@ -60,8 +60,8 @@ int main(int argc, char** argv)
{
int
id
;
int
procs
;
unsigned
long
*
calculated_values
;
unsigned
long
*
receive_buffer
=
nullptr
;
float
*
calculated_values
;
float
*
receive_buffer
=
nullptr
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
procs
);
...
...
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
// Calculate this threads working area.
effective_height
/=
procs
;
calculated_values
=
new
unsigned
long
[
IMG_WIDTH
*
effective_height
];
calculated_values
=
new
float
[
IMG_WIDTH
*
effective_height
];
for
(
unsigned
long
y
=
effective_height
*
id
;
y
<
effective_height
*
(
id
+
1
);
++
y
)
{
...
...
@@ -86,17 +86,17 @@ int main(int argc, char** argv)
}
if
(
id
==
0
)
receive_buffer
=
new
unsigned
long
[
IMG_WIDTH
*
IMG_HEIGHT
];
receive_buffer
=
new
float
[
IMG_WIDTH
*
IMG_HEIGHT
];
cout
<<
"Process: "
<<
id
<<
", Gathering!"
<<
endl
;
MPI_Gather
(
calculated_values
,
IMG_WIDTH
*
effective_height
,
MPI_
UNSIGNED_LONG
,
receive_buffer
,
IMG_WIDTH
*
effective_height
,
MPI_
UNSIGNED_LONG
,
0
,
MPI_COMM_WORLD
);
MPI_Gather
(
calculated_values
,
IMG_WIDTH
*
effective_height
,
MPI_
FLOAT
,
receive_buffer
,
IMG_WIDTH
*
effective_height
,
MPI_
FLOAT
,
0
,
MPI_COMM_WORLD
);
cout
<<
"Process: "
<<
id
<<
", done gathering!"
<<
endl
;
if
(
id
==
0
)
{
Image
my_image
(
Geometry
(
IMG_WIDTH
,
IMG_
WIDTH
),
"white"
);
Image
my_image
(
Geometry
(
IMG_WIDTH
,
IMG_
HEIGHT
),
"white"
);
my_image
.
modifyImage
();
Pixels
pixel_cache
(
my_image
);
...
...
@@ -121,9 +121,9 @@ int main(int argc, char** argv)
{
int
iter_res
=
receive_buffer
[
y
*
IMG_WIDTH
+
x
];
if
(
iter_res
==
ITERATIONS
)
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
"purple"
);
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
MaxRGB
*
0.55
,
MaxRGB
*
0.35
,
MaxRGB
*
0.6
);
else
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
0
,
0
,
MaxRGB
*
static_cast
<
float
>
(
iter_res
)
/
max
);
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
MaxRGB
*
cosf
(
exp
(
iter_res
)),
0
,
MaxRGB
*
sinf
(
exp
(
iter_res
)
)
);
}
}
pixel_cache
.
sync
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment