का उपयोग कर गतिशील आकार के साथ गतिशील सरणी भेजें ओपनएमपीआई: मैं रूट नोड पर एक फ़ाइल पढ़ना चाहता हूं और उस फ़ाइल की सामग्री को अन्य सभी नोड्स पर भेजना चाहता हूं। मैं पाया है MPI_Bcast करता है कि कि:MPI_Bcast
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
int root, MPI_Comm comm)
सभी उदाहरण है कि मैं पाया है count
मूल्य पहले से ही ज्ञात है, लेकिन मेरे मामले में, गिनती मूल्य मुख्य रूप से जड़ पर जाना जाता है। अन्य examples कहते हैं कि MPI_Bcast का एक ही कॉल अन्य नोड्स पर डेटा पुनर्प्राप्त करता है।
मैं इस जोड़ दिया है:
typedef short Descriptor[128];
MPI_Datatype descriptorType;
MPI_Type_contiguous(sizeof(Descriptor), MPI_SHORT, &descriptorType);
MPI_Type_commit(&descriptorType);
if(world_rank == 0) {
struct stat finfo;
if(stat(argv[1], &finfo) == 0) {
querySize = finfo.st_size/sizeof(Descriptor);
}
{
//read binary query
queryDescriptors = new Descriptor[querySize];
fstream qFile(argv[1], ios::in | ios::binary);
qFile.read((char*)queryDescriptors, querySize*sizeof(Descriptor));
qFile.close();
}
}
MPI_Bcast((void*)&querySize, 1, MPI_INT, 0, MPI_COMM_WORLD);
if (world_rank != 0)
{
queryDescriptors = new Descriptor[querySize];
}
MPI_Bcast((void*)queryDescriptors, querySize, descriptorType, 0, MPI_COMM_WORLD);
जब मैं इसे इस तरह कहते हैं: mpirun -np 2 ./mpi_hello_world
यह ठीक काम करता है, लेकिन जब मैं एक से अधिक से कॉल करने, मैं इस मिल:
mpi_hello_world: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
mpi_hello_world: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
तो दो प्रसारण, गिनती के साथ पहले, बफर सामग्री के साथ दूसरा मुद्दा: यह
MPI_Type_contiguous(sizeof(Descriptor), MPI_CHAR, &descriptorType);
यहाँ तुम्हारा के आधार पर कोड का एक टुकड़ा है कि चाल करना चाहिए है होना चाहिए। –आप सही हैं, यह एक समाधान है। मैं सोच रहा था कि ऐसी परिस्थितियों के लिए एमपीआई में एक तंत्र है या नहीं। – AlexandruC
ऐसा नहीं है कि मुझे पता है, लेकिन मेरे एमपीआई थोड़ा जंगली हो रहा है। –