WIN7 Building Java Parallel development environment MPJ Express (PART3)

Source: Internet
Author: User

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://baimafujinji.blog.51cto.com/907111/1629153


WIN7 Building Java Parallel development environment MPJ Express (PART2)

http://baimafujinji.blog.51cto.com/907111/1629176


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.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/18/wKiom1Uhc22zERBkAAGviZO73RA668.jpg "style=" float: none; "title=" Je_25.png "alt=" Wkiom1uhc22zerbkaagvizo73ra668.jpg "/>


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.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/18/wKiom1Uhc1XBBEdzAASB9pM84Uo150.jpg "style=" float: none; "title=" Je_23.png "alt=" Wkiom1uhc1xbbedzaasb9pm84uo150.jpg "/>


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)



650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/13/wKioL1UhdKXBmN3fAASHrshMRbc051.jpg "style=" float: none; "title=" Je_24.png "alt=" Wkiol1uhdkxbmn3faashrshmrbc051.jpg "/>

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?


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/13/wKioL1UhhevgF78iAAB4SiU6Sk0789.jpg "title=" je_29. PNG "alt=" wkiol1uhhevgf78iaab4siu6sk0789.jpg "/>



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.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/18/wKiom1UhhIyDO_KxAAGanKPTqs8979.jpg "style=" float: none; "title=" Je_30.png "alt=" Wkiom1uhhiydo_kxaagankptqs8979.jpg "/>


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


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/18/wKiom1UhiLvRUFEpAAG8HZRBCUo297.jpg "title=" je_31. PNG "alt=" wkiom1uhilvrufepaag8hzrbcuo297.jpg "/>


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.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/18/wKiom1UhcAuSmmT7AAPV20JIapI090.jpg "title=" je_17. PNG "alt=" wkiom1uhcausmmt7aapv20jiapi090.jpg "/>


Then select "String Substitution" from the list on the left and create a new "variable substitution" as shown below.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/13/wKioL1Uhe5GgypKgAAJ51g81KvU316.jpg "title=" je_26. PNG "alt=" wkiol1uhe5ggypkgaaj51g81kvu316.jpg "/>


After completing the above steps, we can use a relative path that is shaped like this.

-jar ${mpj_home}/lib/starter.jar

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/13/wKioL1UhfqCAlt2xAANUplADFf0637.jpg "style=" float: none; "title=" Je_27.png "alt=" Wkiol1uhfqcalt2xaanupladff0637.jpg "/>


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.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/18/wKiom1UhfV7RUOtQAACNuyOePCU764.jpg "style=" float: none; "title=" Je_28.png "alt=" Wkiom1uhfv7ruotqaacnuyoepcu764.jpg "/>


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.*;p ublic 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.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/20/wKioL1UiC33TDeFfAAFNGOgi03k540.jpg "title=" je_32. PNG "alt=" wkiol1uic33tdeffaafngogi03k540.jpg "/>


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.

This article from "White Horse Negative Gold" blog, reproduced please contact the author!

WIN7 Building Java Parallel development environment MPJ Express (PART3)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.