c++ - How can I pass long and/or unsigned integers to MPI arguments? -


Let's say I have a very large array that I want to send or receive with MPI (v1). To index this array, I use an unsigned long integer. Now, all MPI function calls I have seen use of the int type for my "count" arguments, such as in this example:

  MPI_Recv (void * buf, int count, MPI_Datatpe datatype, int source, int tag, MPI_Comm comm, MPI_Status * status)   

However, in my implementation, I would send / receive an array more than the maximum number of arrays Can the capacity be needed? The compiler, naturally, gives me the "invalid conversion" error, when I try to feed an unsigned integer for the "count" argument. I thought of an artist, but then I worry that it will reduce my variable, so I am in some kind of loss.

An artist does not have a solution to do because it will only reduce the long count to match here There are two obstacles - easy and hard one.

The easy hurdle count type is the int for argument. You can easily find it by making a small size smaller size and then send the data as multiples of the new datatype. An example code is as follows:

  // Data to send data to data [1000]; // Make an approximate datatype of the 100 MPs of MPI Datatype DT100; MPI_Type_contiguous (100, MPINDT, & amp; dt100); MPI_Type_commit (& amp; dt100); // Send data as 10 elements of new type MPI_Send (data, 10, DT100, ...);   

Since the MPI_Type_contiguous is int counting logic, with this technique you (2 31 -1) 2 = (2 62 - 2 32 + 1) element If this is not enough, then you dt100 datatype You can create a new closest datatype, for example: <100p> 100 dt100 (one effectively 100x100 elements) MPI_Datatype dt10000; MPI Type_Cguigate (100, DT100, and DT10000); MPI_Type_commit (& amp; dt10000);

If your original data size is not a repository of the size of the new datatype, you can create a structure datatype whose first element is int (data_size / cont_type_length) Elements of the nearest datatype and whose second element is an array of elements of primitive datatype datasize% cont_type_length . The example is as follows:

  // Data to send data [260]; // Create a composition type MPI_Datatype dt260; Int blacklanes [2]; MPI_Datatype Old Type [2]; MPI_Int offset [2]; Blacklines [0] = 2; // This int (260/100) offset [0] = 0; Old Style [0] = DT100; Blacklines [1] = 60; // This is 260% 100 offset [1] = Blacklines [0] * 100 L * size (int); // offsets are in BYTES! Old style [1] = MPIENT; MPI_Type_create_struct (2, blacklines, offset, old type, and dt260); MPI_Type_commit (& amp; dt260); // Send data to MPI_Send (data, 1, dt260, ...);   

MPI_Aint is a large enough integer that can keep the offset larger than the int LP64 systems can be shown. Note that the receiver should create the same datatype and similarly in the MPI_Recv call. Getting an arbitrary non-integer amount of contiguous datatype is a little problematic.

This easy handicap is not so easy when your MPI implementation internal counts internally. In that case the MPI usually occurs in the accident or may be just part of the data or something weird. Even as the total message size of INT_MAX type MPI_INT (2 31 - 1) without the implementation of such MPI to create a special datatype ) * 4 = 2 33 - 4. If this is the case, your only escape manually divides the message and it is sending / receiving it in the loop.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -