High Performance Computing 1
MPI Messages
•void Get_data4(int my_rank, float* a_ptr, float* b_ptr, int* n_ptr)
•{
•int root = 0; /* Argument to MPI_Bcast */
•char buffer[100]; /* Arguments to MPI_Pack/Unpack */
•int position; /* and MPI_Bcast*/
•if (my_rank == 0)
•{
•printf("Enter a, b, and n");
•scanf("%f %f %d", a_ptr, b_ptr, n_ptr);
• /* Now pack the data into buffer */
•position = 0; /* Start at beginning of buffer */
•MPI_Pack(a_ptr, 1, MPI_FLOAT, buffer, 100,&position, MPI_COMM_WORLD);
• /* Position has been incremented by */
• /* sizeof(float) bytes */
•MPI_Pack(b_ptr, 1, MPI_FLOAT, buffer, 100, &position, MPI_COMM_WORLD);
•