Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ROSMPI_H_
00038 #define ROSMPI_H_
00039
00040 #include <boost/function.hpp>
00041 #include <boost/bind.hpp>
00042 #include <boost/make_shared.hpp>
00043
00044 #include <ros/message.h>
00045 #include <ros/serialized_message.h>
00046 #include <ros/serialization.h>
00047
00048 #include <mpi.h>
00049
00050 namespace rosmpi
00051 {
00053 namespace init_options
00054 {
00055 enum InitOption
00056 {
00058 ThreadSingle = 0,
00060 ThreadFunneled = 1,
00062 ThreadSerialized = 2,
00064 ThreadMultiple = 3,
00065 };
00066 }
00067 typedef init_options::InitOption InitOption;
00068
00074 void
00075 init (int &argc, char **argv, uint32_t options = 0)
00076 {
00077
00078
00079 int required = options;
00080 int ret = MPI::Init_thread (argc, argv, required);
00081 if (ret != required)
00082 ROS_WARN ("[rosmpi::init] MPI level of thread support required: %d, provided: %d.", required, ret);
00083
00084 ros::Time::init ();
00085 }
00086
00087 namespace this_processor
00088 {
00090 const std::string getName ()
00091 {
00092 int namelen;
00093 char processor_name[MPI_MAX_PROCESSOR_NAME];
00094 MPI::Get_processor_name (processor_name, namelen);
00095 return (std::string (processor_name));
00096 }
00097 }
00098
00099 namespace communicator
00100 {
00102 int getSize ()
00103 {
00104 return (MPI::COMM_WORLD.Get_size ());
00105 }
00106
00108 int getRank ()
00109 {
00110 return (MPI::COMM_WORLD.Get_rank ());
00111 }
00112 }
00113
00114 void
00115 shutdown ()
00116 {
00117
00118 MPI::Finalize ();
00119 }
00120
00121 void
00122 spin ()
00123 {
00124 while (true)
00125 {
00126 usleep (10);
00127
00128
00129 }
00130 }
00131
00132
00133
00134
00135 }
00136
00137 #endif //#ifndef ROSMPI_H_