In the previous two part, we set up the parallel development environment separately, and tried sledgehammer to practice the simple parallel development.
Win7 Building Java Parallel development environment MPJ Express (PART1) http://blog.csdn.net/baimafujinji/article/details/45195159
Win7 Building Java Parallel development environment MPJ Express (PART2)
http://blog.csdn.net/baimafujinji/article/details/45195285
Of course, in this process, it is unavoidable to have such or such problems, and this part we will discuss some of the problems that may come up.
Question 1: When we set up the development environment, we need to try out the Mpjdaemon batch processing command, at this time we may encounter a problem is: Port is not available, as shown in.
The problem is that the port is not available. We follow the prompts to locate the folder where the configuration file mpjexpress.conf is located, and then open it with Notepad, as shown below. Visible, port.1=10000,port.2=10001 by default.
At this point, we only need to adjust the port, for example, modified to the following results (of course, it should be guaranteed that 8888 and 8889 are not occupied)
The problem is solved by saving the file after the modification is complete.
Question 2: Notice that we save the extracted MPJ Express file under the path "D:\mpj-v0_43" and assign the environment variable mpj_home to D:\mpj-v0_43 accordingly. What happens if we save the file in the path "D:\Program files\mpj-v0_43" and modify the environment variable assignment accordingly?
This may seem like a completely non-problem problem, but once we do this, when we use the Mpjdaemon batch command again, we encounter the following scenario.
The results show an error!
Error:unable to access Jarfile D:\Program
The system has no way to access the corresponding jar file. But why? This is because the name of the Program Files folder is not valid. The name of this folder is of course not a problem in Windows, and this will not be a problem for most of our daily application development. However, in MPJ Express, there is no "space" in the middle of the folder name. As we all know, when you enter an instruction in the console, spaces are usually used to interval operators and operands, or you can think of spaces as meaningful, so batch commands in MPJ Express can cause confusion when parsing a path name with a space. This is where the problem lies. So as long as we have the MPJ Express file storage path slightly adjusted to eliminate such problems.
In addition, an easy way to view the current environment variable settings on the command line is to use the ECHO directive, such as
Issue 3: The previous problem will occur in eclipse, in addition to the console operator interface. Recall that we wrote this when we set the VM arguments parameter in PART2
-jar D:/mpj-v0_43/lib/starter.jar
-NP 4
We've used an absolute path! And more often we are accustomed to writing relative paths, when the user needs to select "Window" in the menu bar and then select "Preferences" in the drop-down menu, as shown below.
Then select "String Substitution" from the list on the left and create a new "variable substitution" as shown below.
After completing the above steps, we can use a relative path that is shaped like this.
-jar ${mpj_home}/lib/starter.jar
Here we need to note that the value of mpj_home is still not equal to a path with a space, otherwise the following error will appear, the principle of the same as the problem 2, here no longer repeat.
Question 4: Finally, let's discuss how to compile a parallel program under commands.
first edit the following code and save it in a file named Helloworld.java.
Import mpi.*;
public class helloworld{
public static void Main (string[] args) throws Exception
{
Mpi. Init (args);
int me = MPI.COMM_WORLD.Rank ();
int size = MPI.COMM_WORLD.Size ();
System.out.println ("Hi from" + Me + "of" + size + "\ n");
Mpi. Finalize ();
}
}
Examples of compiling directives: JAVAC-CP.; %mpj_home%/lib/mpj.jar Helloworld.java
Example of execution instruction: MPJRUN.BAT-NP 4 HelloWorld A//Where a is an arbitrarily specified parameter
Execute the results as shown below.
The above scenario is the first scenario for parallel computing, which is to execute the MPJ Express program in a multi-core configuration.
We specify the number of cores by the number behind the MPJRUN.BAT-NP.
Another scenario is the implementation of the MPJ Express program in a cluster (Cluster) configuration.
Cluster configuration: If developers expect parallel Java programs to be executed on distributed memory platforms, including clusters and computer networks, they will sample this configuration scenario.
For this cluster configuration, there are four options, as follows:
1) Niodev-using Java NIO Sockets
2) Mxdev-use Myrinet eXpress (MX) library for Myrinet Networks
3) Hybdev-Cluster for multicore processing
4) Native-use a native MPI library (curretly only tested under Ms-mpi for Windows)
Write a file named "Machines" when you use it, specifying all the host names or IP addresses that are used for concurrent execution.
Execution method
For Niodev, Hybdev and Mxdev
1) Open guard: Mpjdaemon.bat-boot
-You will need to execute the command manually on each of the open-guard machines.
2) Example of execution instruction: MPJRUN.BAT-NP 4-dev Niodev HelloWorld
---dev <device> inside the device can be Niodev, Hybdev or Mxdev
3) Termination daemon: Mpjdaemon.bat-halt
For native
1) Compile the JNI wrapper library (see the Help documentation for MPJ Express for specific compilation methods)
2) Example of execution instruction: MPJRUN.BAT-NP 4-dev native HelloWorld
complete the full text.
WIN7 Building Java Parallel development environment MPJ Express (PART3)