0

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>

このようなコードを出力 sth に与える方法: MPJ Express (0.43) はマルチコア構成で開始されます

Proc <2>: sharedVar = <1>
Proc <1>: sharedVar = <2>
Proc <3>: sharedVar = <3>
Proc <0>: sharedVar = <4>

?

4

1 に答える 1

1

クラスター モードとマルチコア モードの両方のケースで提供した出力は正しいです。MPJ Express は、通信プロセスが同じ物理マシン上にある場合でも、メッセージ パッシングを使用して通信を強制する mpiJava 標準に従います。そのため、MPJ Express マルチコア構成では、共有メモリ メカニズムを使用してメッセージ パッシングを行うプロセスがあり、プロセス間で何も共有できません。x 個 (np=x) のJava プロセスが同じノードで起動され、これらのプロセスが他の変数(静的または非静的)を共有できないとします。これらの Java プロセスで変数またはデータを共有したい場合、オプションはメッセージ パッシングを使用した通信のみです。

マルチコア構成と共有メモリは互いに同義語ですが、実際には、マルチコア構成では、帯域幅を向上させるためにネットワーク インターフェイス カード (NIC) を使用する代わりに共有メモリを介してプロセス間の通信が行われます。

于 2014-12-11T13:13:02.000 に答える