[問題] MPI on Windows

看板C_and_CPP作者時間15年前 (2010/05/24 11:01), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
小弟是MPI使用的新手 對於下一段程式碼在MPI_Allgather上有疑問 如下 #include <stdio.h> #include <stdlib.h> #include <mpi.h> int main( int argc, char *argv[] ) { int n[5]={0}; int total[5]={0}; int myId, nProc; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &nProc ); MPI_Comm_size( MPI_COMM_WORLD, &myId ); n[myId]=myId; MPI_Allgather(( void * )( &n+myId ), 1, MPI_INT, ( void * )( &total+myId ), 1,MPI_INT, MPI_COMM_WORLD ); if( myId==0 ) printf("The contents:%d, %d, %d, %d, %d", total[0], total[1], total[2], total[3], total[4] ); MPI_Finalize(); return 0; } 在command mode執行結果會是錯的且會跳出stack 'n' was corrupted 若將n宣告為整數變數 並且改為 n=myId; MPI_Allgather(( void * )&n, 1, MPI_INT, ( void * )( &total+myId ), 1, MPI_INT, MPI_COMM_WORLD ); 結果是對了, 但仍會跳出錯誤訊息 想請問是錯在MPI_Allgather中的哪邊 我是使用mpich2 執行參數為 mpich2 -n 5 <binary file> 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) Windows VS VC++ 2008 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.136.144.13

05/24 20:38, , 2F
還是不行...囧
05/24 20:38, 2F

05/24 21:05, , 3F
解決了, 接收之資料之陣列不用特地指出要放到陣列哪個位址
05/24 21:05, 3F
文章代碼(AID): #1B-boOiC (C_and_CPP)