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
79e0d716
Commit
79e0d716
authored
Oct 04, 2015
by
Andreas Kempe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected an error where the root process was rendering too much.
parent
2cbf0688
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
server/mandel_render_srv.cpp
server/mandel_render_srv.cpp
+14
-6
No files found.
server/mandel_render_srv.cpp
View file @
79e0d716
...
...
@@ -11,7 +11,7 @@ using namespace Magick;
mandel_render_srv
::
mandel_render_srv
(
std
::
string
host
,
unsigned
int
port
,
int
id
,
int
procs
,
QObject
*
parent
)
:
QObject
(
parent
),
settings
(
settings
),
id
(
id
),
procs
(
procs
)
QObject
(
parent
),
id
(
id
),
procs
(
procs
)
{
// We only let the root process connect to the client.
if
(
id
==
0
)
...
...
@@ -57,17 +57,17 @@ void mandel_render_srv::start_drawing()
void
mandel_render_srv
::
root_process_handling
(
unsigned
long
*
receive_buffer
)
{
Image
my_image
(
Geometry
(
settings
.
img_width
,
settings
.
img_height
),
"white"
);
Image
my_image
(
Geometry
(
settings
.
img_width
,
settings
.
img_height
*
procs
),
"white"
);
my_image
.
modifyImage
();
Pixels
pixel_cache
(
my_image
);
PixelPacket
*
pixels
=
pixel_cache
.
get
(
0
,
0
,
settings
.
img_width
,
settings
.
img_height
);
PixelPacket
*
pixels
=
pixel_cache
.
get
(
0
,
0
,
settings
.
img_width
,
settings
.
img_height
*
procs
);
cout
<<
"Assembling image!"
<<
endl
;
for
(
unsigned
long
y
=
0
;
y
<
settings
.
img_height
;
++
y
)
for
(
unsigned
long
y
=
0
;
y
<
settings
.
img_height
*
procs
;
++
y
)
{
cout
<<
"Progress: "
<<
setprecision
(
3
)
<<
static_cast
<
float
>
(
y
*
100
)
/
(
settings
.
img_height
)
<<
" %
\r
"
<<
flush
;
static_cast
<
float
>
(
y
*
100
)
/
(
settings
.
img_height
*
procs
)
<<
" %
\r
"
<<
flush
;
for
(
unsigned
long
x
=
0
;
x
<
settings
.
img_width
;
++
x
)
{
...
...
@@ -155,6 +155,8 @@ void mandel_render_srv::handle_recv_data()
settings
=
recv_settings
;
settings
.
img_height
/=
procs
;
double
mpi_data
[
8
];
mpi_data
[
0
]
=
static_cast
<
double
>
(
mpi_opcodes
::
RENDER
);
...
...
@@ -163,7 +165,7 @@ void mandel_render_srv::handle_recv_data()
mpi_data
[
3
]
=
settings
.
im_max
;
mpi_data
[
4
]
=
settings
.
im_min
;
mpi_data
[
5
]
=
settings
.
img_width
;
mpi_data
[
6
]
=
settings
.
img_height
/
procs
;
mpi_data
[
6
]
=
settings
.
img_height
;
mpi_data
[
7
]
=
settings
.
iterations
;
// Send current render settings to other processes.
...
...
@@ -173,6 +175,12 @@ void mandel_render_srv::handle_recv_data()
MPI_Send
(
mpi_data
,
8
,
MPI_DOUBLE
,
i
,
0
,
MPI_COMM_WORLD
);
}
// Update the settings for the root process.
double
im_max
=
settings
.
im_max
;
double
im_min
=
settings
.
im_min
;
settings
.
im_max
=
get_max_im
(
im_max
,
im_min
,
0
,
procs
);
settings
.
im_min
=
get_min_im
(
im_max
,
im_min
,
0
,
procs
);
start_drawing
();
break
;
}
...
...
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