Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
64539e65
Commit
64539e65
authored
Nov 12, 2012
by
Davis King
Browse files
fixed grammar
parent
0ee27438
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
examples/bsp_ex.cpp
examples/bsp_ex.cpp
+6
-5
No files found.
examples/bsp_ex.cpp
View file @
64539e65
...
@@ -88,7 +88,8 @@ int main(int argc, char** argv)
...
@@ -88,7 +88,8 @@ int main(int argc, char** argv)
{
{
// Get the argument to -l
// Get the argument to -l
const
unsigned
short
listening_port
=
get_option
(
parser
,
"l"
,
0
);
const
unsigned
short
listening_port
=
get_option
(
parser
,
"l"
,
0
);
cout
<<
"Listening in port "
<<
listening_port
<<
endl
;
cout
<<
"Listening on port "
<<
listening_port
<<
endl
;
const
long
grid_resolution
=
100
;
const
long
grid_resolution
=
100
;
// bsp_listen() starts a listening BSP job. This means that it will wait until
// bsp_listen() starts a listening BSP job. This means that it will wait until
...
@@ -130,7 +131,7 @@ int main(int argc, char** argv)
...
@@ -130,7 +131,7 @@ int main(int argc, char** argv)
// and we will see the results here in main() after bsp_connect() terminates.
// and we will see the results here in main() after bsp_connect() terminates.
bsp_connect
(
hosts
,
bsp_job_node_0
,
dlib
::
ref
(
min_value
),
dlib
::
ref
(
optimal_x
));
bsp_connect
(
hosts
,
bsp_job_node_0
,
dlib
::
ref
(
min_value
),
dlib
::
ref
(
optimal_x
));
// bsp_connect() and bsp_listen() block until all the BSP nodes have terminate.
// bsp_connect() and bsp_listen() block until all the BSP nodes have terminate
d
.
// Therefore, we won't get to this part of the code until the BSP processing
// Therefore, we won't get to this part of the code until the BSP processing
// has finished. But once we do we can print the results like so:
// has finished. But once we do we can print the results like so:
cout
<<
"optimal_x: "
<<
optimal_x
<<
endl
;
cout
<<
"optimal_x: "
<<
optimal_x
<<
endl
;
...
@@ -163,7 +164,7 @@ void bsp_job_node_0 (bsp_context& bsp, double& min_value, double& optimal_x)
...
@@ -163,7 +164,7 @@ void bsp_job_node_0 (bsp_context& bsp, double& min_value, double& optimal_x)
// you want. However, in this example we use this node as a kind of controller for the
// you want. However, in this example we use this node as a kind of controller for the
// other nodes. In particular, since we are doing a nested grid search, this node's
// other nodes. In particular, since we are doing a nested grid search, this node's
// job will be to collect results from other nodes and then decide which part of the
// job will be to collect results from other nodes and then decide which part of the
// number line subsequen
ce
iterations should focus on.
// number line subsequen
t
iterations should focus on.
//
//
// Also, each BSP node has a node ID number. You can determine it by calling
// Also, each BSP node has a node ID number. You can determine it by calling
// bsp.node_id(). However, the node spawned by a call to bsp_connect() always has a
// bsp.node_id(). However, the node spawned by a call to bsp_connect() always has a
...
@@ -175,7 +176,7 @@ void bsp_job_node_0 (bsp_context& bsp, double& min_value, double& optimal_x)
...
@@ -175,7 +176,7 @@ void bsp_job_node_0 (bsp_context& bsp, double& min_value, double& optimal_x)
// Now lets get down to work. Recall that we are trying to find the x value that
// Now lets get down to work. Recall that we are trying to find the x value that
// minimizes the f(x) defined above. The grid search will start out by considering the
// minimizes the f(x) defined above. The grid search will start out by considering the
// range [-1e100, 1e100] on the number line. It will progressively narrow this window
// range [-1e100, 1e100] on the number line. It will progressively narrow this window
// until it has located the minimizer of f(x) to within 1e-15 of it
'
s true value.
// until it has located the minimizer of f(x) to within 1e-15 of its true value.
double
left
=
-
1e100
;
double
left
=
-
1e100
;
double
right
=
1e100
;
double
right
=
1e100
;
...
@@ -236,7 +237,7 @@ void bsp_job_other_nodes (bsp_context& bsp, long grid_resolution)
...
@@ -236,7 +237,7 @@ void bsp_job_other_nodes (bsp_context& bsp, long grid_resolution)
// only returns false if waiting for a message would result in all the BSP nodes
// only returns false if waiting for a message would result in all the BSP nodes
// waiting forever.
// waiting forever.
//
//
// Therefore, try_receive()
function
s both as a message receiving tool as well as an
// Therefore, try_receive()
serve
s both as a message receiving tool as well as an
// implicit form of barrier synchronization. In this case, we use it to know when to
// implicit form of barrier synchronization. In this case, we use it to know when to
// terminate. That is, we know it is the time to terminate if all the messages between
// terminate. That is, we know it is the time to terminate if all the messages between
// nodes have been received and all nodes are inactive due to either termination or
// nodes have been received and all nodes are inactive due to either termination or
...
...
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