소스 검색

initialize thread support, warn if no thread support is available

Samuel Thibault 15 년 전
부모
커밋
2c2170c9c8
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 1
      mpi/examples/mpi_lu/plu_example.c

+ 10 - 1
mpi/examples/mpi_lu/plu_example.c

@@ -236,11 +236,20 @@ int main(int argc, char **argv)
 {
 	int rank;
 	int world_size;
+	int thread_support;
 
 	/*
 	 *	Initialization
 	 */
-	MPI_Init(&argc, &argv);
+	if (MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &thread_support) != MPI_SUCCESS) {
+		fprintf(stderr,"MPI_Init_thread failed\n");
+		exit(1);
+	}
+	if (thread_support == MPI_THREAD_FUNNELED)
+		fprintf(stderr,"Warning: MPI only has funneled thread support, not serialized, hoping this will work\n");
+	if (thread_support < MPI_THREAD_FUNNELED)
+		fprintf(stderr,"Warning: MPI does not have thread support!\n");
+	
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 	MPI_Comm_size(MPI_COMM_WORLD, &world_size);