मैं सी में एमपीआई का उपयोग करके एक मैट्रिक्स को स्थानांतरित करने की कोशिश कर रहा हूं। प्रत्येक प्रक्रिया में एक स्क्वायर सबमिट्रिक्स होता है, और मैं इसे सही प्रक्रिया (ग्रिड पर 'विपरीत') पर भेजना चाहता हूं, इसे संचार के हिस्से के रूप में स्थानांतरित करना चाहता हूं ।क्या MPI_Type_create_subarray का उपयोग करते समय आप सरणी को ट्रांसफर कर सकते हैं?
मैं MPI_Type_create_subarray
का उपयोग कर रहा हूं जिसमें क्रमशः पंक्ति-प्रमुख और स्तंभ-प्रमुख के लिए MPI_ORDER_C
या MPI_ORDER_FORTRAN
आदेश के लिए तर्क है। मैंने सोचा कि अगर मैंने इनमें से एक के रूप में भेजा है, और दूसरे के रूप में प्राप्त किया है, तो संचार के हिस्से के रूप में मेरे मैट्रिक्स को स्थानांतरित किया जाएगा। हालांकि, ऐसा प्रतीत नहीं होता है - यह केवल गैर-स्थानांतरित रहता है।
कोड का महत्वपूर्ण हिस्सा नीचे है, और संपूर्ण कोड फ़ाइल this gist पर उपलब्ध है। क्या किसी के पास कोई विचार है कि यह क्यों काम नहीं कर रहा है? क्या ट्रांसपोज़र काम करने के लिए यह दृष्टिकोण होना चाहिए? मैंने सोचा होगा कि यह MPI_ORDER_C
और MPI_ORDER_FORTRAN
के विवरण पढ़ेगा, लेकिन शायद नहीं।
/* ----------- DO TRANSPOSE ----------- */
/* Find the opposite co-ordinates (as we know it's a square) */
coords2[0] = coords[1];
coords2[1] = coords[0];
/* Get the rank for this process */
MPI_Cart_rank(cart_comm, coords2, &rank2);
/* Send to these new coordinates */
tag = (coords[0] + 1) * (coords[1] + 1);
/* Create new derived type to receive as */
/* MPI_Type_vector(rows_in_core, cols_in_core, cols_in_core, MPI_DOUBLE, &vector_type); */
sizes[0] = rows_in_core;
sizes[1] = cols_in_core;
subsizes[0] = rows_in_core;
subsizes[1] = cols_in_core;
starts[0] = 0;
starts[1] = 0;
MPI_Type_create_subarray(2, sizes, subsizes, starts, MPI_ORDER_FORTRAN, MPI_DOUBLE, &send_type);
MPI_Type_commit(&send_type);
MPI_Type_create_subarray(2, sizes, subsizes, starts, MPI_ORDER_C, MPI_DOUBLE, &recv_type);
MPI_Type_commit(&recv_type);
/* We're sending in row-major form, so it's just rows_in_core * cols_in_core lots of MPI_DOUBLE */
MPI_Send(&array[0][0], 1, send_type, rank2, tag ,cart_comm);
/* Receive from these new coordinates */
MPI_Recv(&new_array[0][0], 1, recv_type, rank2, tag, cart_comm, &status);
मैं इसे पर्याप्त रूप से ऊपर नहीं उठा सकता। मैंने अभी एक सहकर्मी के साथ एक लंबा और आगे बिताया - जिसने MPI-2 (!) - MPI_ORDER_C बनाम MPI_ORDER_FORTRAN और उसके प्रभावों के बारे में डिज़ाइन करने में मदद की। –