c - What should be the value of message in MPI send-receive program? -


I have developed a given simple MPI program, as the process 1 sends the message to process the message and the process p Receives the message from -1 The following is the code: given me in the skeleton,

  four * message; Message = (four *) maul (msg_size);  

To confuse me, to check the accuracy of the program, I am trying to see the value of the message that was sent or received. So should it be hexadecimal?

 
int main (int argc, char ** argv) {double startwtime, endwtime; Floating time, bandwidth; Int my_id, next_id; / * Process ID-s * / int p; / * Number of processes * / four * messages; / * Storage for message * / int i, k, max_msgs, msg_size, v; MPI_Status status; / * Return status to get * / MPI_Init (& amp; argc, & argv); MPI_Comm_rank (MPI_COMM_WORLD, and my_id); MPI_Comm_size (MPI_COMM_WORLD, & amp; nbsp;); If (argc & lt; 3) {fprintf (stderr, "msg calculation and msg size should be in the form of parameters) \ n"); Goto exit; } If (sscanf (argv [1], "% d", and max_msgs) <1) || (sscanf (argv [2], "% d", and msg_size) <1)) {fprintf (Stadder, "msg count and msg size requirements as parameters \ n"); Goto exit; } ** Message = (four *) malloc (msg_size); ** If (RGC & gt; 3) v = 1; Else v = 0; / * We are in verbose mode * / / * Do not start the timer until all is OK * / MPI_Barrier (MPI_COMM_WORLD); Int t = 0; If (my_id == 0) {startwtime = MPI_Wtime (); // do max_msgs Time: // Size Process to message message size 1 Get 1 // Get msg_size message size message process is P-1 whereas (T & lt; max_msgs) {MPI_Send (* four *) Message, msg_size, MPI_CHAR, 1, 0, MPI_ COMM_WORLD); MPI_Recv ((* Four *) message, msg_size, MPI_CHAR, P-1, 0, MPImml_wind, and status); T ++; } MPI_Barrier (MPI_COMM_WORLD); Endvime = MPI_WIT (); Elapsed_time = endwtime-startwtime; Bandwidth = 2.0 * max_ms gs * msg_size / (elapsed_time); Printf ("Number, size of messages:% 3d,% 3d \ n", max_msgs, msg_size); Fflush (stdout); Printf ("Volclock Time =% F Seconds \ n", elapsed_time); Fflush (stdout); Printf ("bandwidth =% f byte per second \ n", bandwidth); Fflush (stdout); } Else if (my_id == p-1) {// do max_msgs times: // Send message msg_size from left to left // msg_size to process message message correctly (sends 0 to p-1) while (T & LT; Max_MS gs) {MPI Side ((* Four *) message, msg_size, MPI_CHAR, 0, 0, MPI_ COMM_WORLD); MPI_Recv ((Four *) Message, msg_size, MPI_CHAR, my_id-1, 0, MPI_COMM_WORLD, and Status); T ++; }} And {while (T & LT; Max_MS gs) {MPI side ((* four *) message, msg_size, MPI_CHAR, my_id + 1, 0, MPI_ COMM_WORLD); MPI_Recv ((Four *) Message, msg_size, MPI_CHAR, my_id-1, 0, MPI_COMM_WORLD, and Status); T ++; }} MPI_Barrier (MPI_COMM_WORLD); Remove: MPI_Finalize (); Return 0; }

I'm not completely sure what this means, but I try Will do

What I think, you want to know what the message is being sent. OK, for the code you provide, memory message is assigned, but a real "readable" message is specified. In this line.

  Message = (four *) malloc (msg_size);  

malloc keeps the memory safe for messages, so anyone can write it, however, it provides an initial value does not do. Occasionally, there is already other information stored in memory and free of charge, then the message is being sent that "trash" which is earlier. It is possible that you ask hexadecimal (I hope I think this is right).

In this case the value is four (the MPI_Send and MPI_Recv function defined as MPI_CHAR) You can find more data types for MPI

I get this message to my_id and I would suggest specifying a value with next_id. So you know who is sending it.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -