我正在使用 MPJ Express 进行项目。我在这里读到: http ://www.researchgate.net/profile/Bryan_Carpenter/publication/221302919_Multicore-enabling_the_MPJ_express_messaging_library/links/02bfe510be4ddbd5d0000000
对于这样的代码:
import mpi.MPI;
public class NumberOfProcesses {
static int sharedVar = 0;
public static void main(String[] args) throws Exception{
MPI.Init(args);
int rank = MPI.COMM_WORLD.Rank();
sharedVar++;
System.out.println("Proc <"+rank+">: sharedVar = <"+sharedVar+">");
MPI.Finalize();
}
}
If we execute the code in the cluster configuration, we observe
the following output:
Proc <0>: sharedVar = <1>
Proc <1>: sharedVar = <1>
This is the correct and desired output. Here the HelloBug class
is executed by two MPJ processes in a SPMD fashion. Both of these
processes execute in a separate JVM and thus do not share the static
variable sharedVar—for this reason both processes increment the
variable first and print 1. This execution model is also depicted in
the Figure 10a.
On the other hand, when the code is executed in the multicore
configuration, the following output is observed:
Proc <0>: sharedVar = <1>
Proc <1>: sharedVar = <2>
我找不到在多核配置中运行程序的任何方法。尽管它似乎在多核配置中运行,但它总是在输出中给我这样的结果:
MPJ Express (0.43) is started in the multicore configuration
Proc <2>: sharedVar = <1>
Proc <1>: sharedVar = <1>
Proc <3>: sharedVar = <1>
Proc <0>: sharedVar = <1>
如何使这段代码像这样在输出上给出:MPJ Express (0.43) is started in the multicore configuration
Proc <2>: sharedVar = <1>
Proc <1>: sharedVar = <2>
Proc <3>: sharedVar = <3>
Proc <0>: sharedVar = <4>
?