2014-12-08 12 views
0

저는 MPJ Express를 사용하여 프로젝트 작업을하고 있습니다. 은 여기 읽기 : http://www.researchgate.net/profile/Bryan_Carpenter/publication/221302919_Multicore-enabling_the_MPJ_express_messaging_library/links/02bfe510be4ddbd5d0000000MPJ Java 멀티 코어 구성 또는 공유 메모리?

코드의 같은 부분에 대한 것을 :

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> 

내가 멀티 코어 구성에서 프로그램을 실행할 수있는 방법을 찾을 수 없습니다. 같은 출력 STH에서 제공하는 코드의 조각을 만드는 방법

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 익스프레스 (0.43) 인 것이 비록 는 항상 출력에 이러한 결과를 나에게주는 멀티 코어 구성에서 실행 것으로 보인다 멀티 코어 구성에서 시작되었습니다.

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

?

답변

1

클러스터 모드와 멀티 코어 모드 모두에서 제공 한 결과가 정확합니다. MPJ Express는 통신 프로세스가 동일한 물리적 시스템에 있더라도 메시지 전달을 사용하여 통신을 시행하는 mpiJava 표준을 따릅니다. 따라서 MPJ Express 멀티 코어 환경에서는 프로세스가 공유 메모리 메커니즘을 사용하여 메시지를 전달하고 프로세스 간에는 아무 것도 공유 할 수 없습니다. x 번호 (np = x)가 인 Java 프로세스이 동일한 노드에서 실행되고 이 프로세스가 서로 다른 변수 (정적 또는 비 정적)을 공유 할 수 없다고 상상해보십시오. 에 이러한 java 프로세스에서 일부 변수 또는 데이터를 공유하려는 경우에만 옵션이을 전달하는 메시지를 사용하여 통신합니다.

멀티 코어 구성과 공유 메모리는 서로 동의어입니다. 실제로 멀티 코어 구성에서는 더 나은 대역폭을 위해 네트워크 인터페이스 카드 (NIC) 대신 공유 메모리를 통해 통신이 이루어집니다.

+0

그래서,이 문서를 참조 : http://www.researchgate.net/profile/Bryan_Carpenter/publication/221302919_Multicore-enabling_the_MPJ_express_messaging_library/links/02bfe510be4ddbd5d0000000 이 가능하다는 출력을 얻는 방법은? PROC <2> : sharedVar = <1> PROC <1> : sharedVar = <2> PROC <3> : sharedVar = <3> PROC <0> : sharedVar = <4> –