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
06b9b553
Commit
06b9b553
authored
Oct 01, 2015
by
Andreas Kempe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the root processing to its own function.
parent
3e512777
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
32 deletions
+35
-32
server/main.cpp
server/main.cpp
+35
-32
No files found.
server/main.cpp
View file @
06b9b553
...
...
@@ -19,6 +19,39 @@
using
namespace
std
;
using
namespace
Magick
;
void
root_process_handling
(
unsigned
long
*
receive_buffer
)
{
Image
my_image
(
Geometry
(
IMG_WIDTH
,
IMG_HEIGHT
),
"white"
);
my_image
.
modifyImage
();
Pixels
pixel_cache
(
my_image
);
PixelPacket
*
pixels
=
pixel_cache
.
get
(
0
,
0
,
IMG_WIDTH
,
IMG_HEIGHT
);
cout
<<
"Assembling image!"
<<
endl
;
for
(
unsigned
long
y
=
0
;
y
<
IMG_HEIGHT
;
++
y
)
{
cout
<<
"Progress: "
<<
setprecision
(
3
)
<<
static_cast
<
float
>
(
y
*
100
)
/
IMG_HEIGHT
<<
" %
\r
"
<<
flush
;
for
(
unsigned
long
x
=
0
;
x
<
IMG_WIDTH
;
++
x
)
{
const
unsigned
long
&
iter_res
=
receive_buffer
[
y
*
IMG_WIDTH
+
x
];
if
(
iter_res
==
ITERATIONS
)
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
MaxRGB
*
0.55
,
MaxRGB
*
0.35
,
MaxRGB
*
0.6
);
else
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
MaxRGB
*
cosf
(
exp
(
iter_res
)),
0
,
MaxRGB
*
sinf
(
exp
(
iter_res
)));
}
}
pixel_cache
.
sync
();
cout
<<
"Progress: 100 % "
<<
endl
;
stringstream
ss
;
ss
<<
"output.png"
;
cout
<<
"Saving image!"
<<
endl
;
my_image
.
write
(
ss
.
str
());
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -48,44 +81,14 @@ int main(int argc, char** argv)
if
(
id
==
0
)
receive_buffer
=
new
unsigned
long
[
IMG_WIDTH
*
IMG_HEIGHT
];
cout
<<
"Process: "
<<
id
<<
",
G
athering!"
<<
endl
;
cout
<<
"Process: "
<<
id
<<
",
g
athering!"
<<
endl
;
MPI_Gather
(
mandel
.
get_point_array
(),
IMG_WIDTH
*
effective_height
,
MPI_UNSIGNED_LONG
,
receive_buffer
,
IMG_WIDTH
*
effective_height
,
MPI_UNSIGNED_LONG
,
0
,
MPI_COMM_WORLD
);
cout
<<
"Process: "
<<
id
<<
", done gathering!"
<<
endl
;
if
(
id
==
0
)
{
Image
my_image
(
Geometry
(
IMG_WIDTH
,
IMG_HEIGHT
),
"white"
);
my_image
.
modifyImage
();
Pixels
pixel_cache
(
my_image
);
PixelPacket
*
pixels
=
pixel_cache
.
get
(
0
,
0
,
IMG_WIDTH
,
IMG_HEIGHT
);
cout
<<
"Assembling image!"
<<
endl
;
for
(
unsigned
long
y
=
0
;
y
<
IMG_HEIGHT
;
++
y
)
{
cout
<<
"Progress: "
<<
setprecision
(
3
)
<<
static_cast
<
float
>
(
y
*
100
)
/
IMG_HEIGHT
<<
" %
\r
"
<<
flush
;
for
(
unsigned
long
x
=
0
;
x
<
IMG_WIDTH
;
++
x
)
{
const
unsigned
long
&
iter_res
=
receive_buffer
[
y
*
IMG_WIDTH
+
x
];
if
(
iter_res
==
ITERATIONS
)
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
MaxRGB
*
0.55
,
MaxRGB
*
0.35
,
MaxRGB
*
0.6
);
else
pixels
[
y
*
IMG_WIDTH
+
x
]
=
Color
(
MaxRGB
*
cosf
(
exp
(
iter_res
)),
0
,
MaxRGB
*
sinf
(
exp
(
iter_res
)));
}
}
pixel_cache
.
sync
();
cout
<<
"Progress: 100 % "
<<
endl
;
stringstream
ss
;
ss
<<
"output.png"
;
cout
<<
"Saving image!"
<<
endl
;
my_image
.
write
(
ss
.
str
());
}
root_process_handling
(
receive_buffer
);
delete
[]
calculated_values
;
delete
[]
receive_buffer
;
...
...
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