Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mpi-mandelbrot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Kempe
mpi-mandelbrot
Commits
653cc12a
Commit
653cc12a
authored
Oct 1, 2015
by
Andreas Kempe
Browse files
Options
Downloads
Patches
Plain Diff
Modified the mandelbrot colouring.
parent
fa94b49b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.cpp
+11
-11
11 additions, 11 deletions
main.cpp
with
11 additions
and
11 deletions
main.cpp
+
11
−
11
View file @
653cc12a
...
@@ -20,7 +20,7 @@ using namespace Magick;
...
@@ -20,7 +20,7 @@ using namespace Magick;
struct
MandelResult
struct
MandelResult
{
{
unsigned
long
end_iterations
;
float
end_iterations
;
bool
belongs
;
bool
belongs
;
MandelResult
(
unsigned
long
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
...
@@ -48,7 +48,7 @@ MandelResult IsMandelbrotPoint(unsigned long x, unsigned long y, unsigned int it
for
(
unsigned
long
i
=
0
;
i
<
iterations
;
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
iterations
;
++
i
)
{
{
if
(
real
(
series_value
)
*
real
(
series_value
)
+
imag
(
series_value
)
*
imag
(
series_value
)
>=
4
)
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
;
series_value
=
pow
(
series_value
,
2
)
+
point
;
}
}
...
@@ -60,8 +60,8 @@ int main(int argc, char** argv)
...
@@ -60,8 +60,8 @@ int main(int argc, char** argv)
{
{
int
id
;
int
id
;
int
procs
;
int
procs
;
unsigned
long
*
calculated_values
;
float
*
calculated_values
;
unsigned
long
*
receive_buffer
=
nullptr
;
float
*
receive_buffer
=
nullptr
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Init
(
&
argc
,
&
argv
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
procs
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
procs
);
...
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
...
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
// Calculate this threads working area.
// Calculate this threads working area.
effective_height
/=
procs
;
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
)
for
(
unsigned
long
y
=
effective_height
*
id
;
y
<
effective_height
*
(
id
+
1
);
++
y
)
{
{
...
@@ -86,17 +86,17 @@ int main(int argc, char** argv)
...
@@ -86,17 +86,17 @@ int main(int argc, char** argv)
}
}
if
(
id
==
0
)
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
;
cout
<<
"Process: "
<<
id
<<
", Gathering!"
<<
endl
;
MPI_Gather
(
calculated_values
,
IMG_WIDTH
*
effective_height
,
MPI_
UNSIGNED_LONG
,
receive_buffer
,
MPI_Gather
(
calculated_values
,
IMG_WIDTH
*
effective_height
,
MPI_
FLOAT
,
receive_buffer
,
IMG_WIDTH
*
effective_height
,
MPI_
UNSIGNED_LONG
,
0
,
MPI_COMM_WORLD
);
IMG_WIDTH
*
effective_height
,
MPI_
FLOAT
,
0
,
MPI_COMM_WORLD
);
cout
<<
"Process: "
<<
id
<<
", done gathering!"
<<
endl
;
cout
<<
"Process: "
<<
id
<<
", done gathering!"
<<
endl
;
if
(
id
==
0
)
if
(
id
==
0
)
{
{
Image
my_image
(
Geometry
(
IMG_WIDTH
,
IMG_
WIDTH
),
"white"
);
Image
my_image
(
Geometry
(
IMG_WIDTH
,
IMG_
HEIGHT
),
"white"
);
my_image
.
modifyImage
();
my_image
.
modifyImage
();
Pixels
pixel_cache
(
my_image
);
Pixels
pixel_cache
(
my_image
);
...
@@ -121,9 +121,9 @@ int main(int argc, char** argv)
...
@@ -121,9 +121,9 @@ int main(int argc, char** argv)
{
{
int
iter_res
=
receive_buffer
[
y
*
IMG_WIDTH
+
x
];
int
iter_res
=
receive_buffer
[
y
*
IMG_WIDTH
+
x
];
if
(
iter_res
==
ITERATIONS
)
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
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
();
pixel_cache
.
sync
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment