Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6764069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:33:03+00:00 2026-05-26T14:33:03+00:00

EDIT #1: so SOLUTION IS : line MPI_Gatherv(buffer, rank, MPI_INT, buffer, receive_counts, receive_displacements, MPI_INT,

  • 0

EDIT #1:

so SOLUTION IS:

line

MPI_Gatherv(buffer, rank, MPI_INT, buffer, receive_counts, receive_displacements, MPI_INT, 0, MPI_COMM_WORLD);

has to be changed to

MPI_Gatherv(buffer, receive_counts[rank], MPI_INT, buffer, receive_counts, receive_displacements, MPI_INT, 0, MPI_COMM_WORLD);

thank you again for help


ORIGINAL POST:

my code is from DeinoMPI

when I run mpiexec -localonly 4 skusamGatherv.exe, everithing is ok.

if I change line

int receive_counts[4] = { 0, 1, 2, 3 };

to

int receive_counts[4] = { 0, 1, 2, 1 };

compiling is still ok, but when i run mpiexec -localonly 4 skusamGatherv.exe I’ll get error

I thing it suppose to work

Thanks for help


I’ll get error:

Fatal error in MPI_Gatherv: Message truncated, error stack:
MPI_Gatherv(363)........................: MPI_Gatherv failed(sbuf=0012FF4C, scou
nt=0, MPI_INT, rbuf=0012FF2C, rcnts=0012FEF0, displs=0012FED8, MPI_INT, root=0,
MPI_COMM_WORLD) failed
MPIDI_CH3_PktHandler_EagerShortSend(351): Message from rank 3 and tag 4 truncate
d; 12 bytes received but buffer size is 4
unable to read the cmd header on the pmi context, Error = -1
.
0. [0][0][0][0][0][0] , [0][0][0][0][0][0]
Error posting readv, An existing connection was forcibly closed by the remote ho
st.(10054)
unable to read the cmd header on the pmi context, Error = -1
.
Error posting readv, An existing connection was forcibly closed by the remote ho
st.(10054)
1. [1][1][1][1][1][1] , [0][0][0][0][0][0]
unable to read the cmd header on the pmi context, Error = -1
.
Error posting readv, An existing connection was forcibly closed by the remote ho
st.(10054)
2. [2][2][2][2][2][2] , [0][0][0][0][0][0]
unable to read the cmd header on the pmi context, Error = -1
.
Error posting readv, An existing connection was forcibly closed by the remote ho
st.(10054)
3. [3][3][3][3][3][3] , [0][0][0][0][0][0]

job aborted:
rank: node: exit code[: error message]
0: jan-pc-nb: 1: Fatal error in MPI_Gatherv: Message truncated, error stack:
MPI_Gatherv(363)........................: MPI_Gatherv failed(sbuf=0012FF4C, scou
nt=0, MPI_INT, rbuf=0012FF2C, rcnts=0012FEF0, displs=0012FED8, MPI_INT, root=0,
MPI_COMM_WORLD) failed
MPIDI_CH3_PktHandler_EagerShortSend(351): Message from rank 3 and tag 4 truncate
d; 12 bytes received but buffer size is 4
1: jan-pc-nb: 1
2: jan-pc-nb: 1
3: jan-pc-nb: 1
Press any key to continue . . .

My code:

#include "mpi.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
    int buffer[6];
    int rank, size, i;
    int receive_counts[4] = { 0, 1, 2, 3 };
    int receive_displacements[4] = { 0, 0, 1, 3 };

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    if (size != 4)
    {
        if (rank == 0)
        {
            printf("Please run with 4 processes\n");fflush(stdout);
        }
        MPI_Finalize();
        return 0;
    }
    for (i=0; i<rank; i++)
    {
        buffer[i] = rank;
    }
    MPI_Gatherv(buffer, rank, MPI_INT, buffer, receive_counts, receive_displacements, MPI_INT, 0, MPI_COMM_WORLD);
    if (rank == 0)
    {
        for (i=0; i<6; i++)
        {
            printf("[%d]", buffer[i]);
        }
        printf("\n");
        fflush(stdout);
    }
    MPI_Finalize();
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:33:03+00:00Added an answer on May 26, 2026 at 2:33 pm

    Step back and consider what MPI_Gatherv is doing: it’s an MPI_Gather (in this case to rank 0) where each processor can send different amounts of data.

    In your example, rank 0 sends 0 ints, rank 1 sends 1 int, rank 2 sends 2 ints, and rank 3 sends 3 ints.

    MPIDI_CH3_PktHandler_EagerShortSend(351): Message from rank 3 and tag 4 truncated; 12 bytes received but buffer size is 4
    

    it’s buried in a lot of other information, but it’s saying that rank 3 sent 3 ints (12 bytes) but rank 0 only had room for 1 int.

    Look at the first three arguments to gatherv: ‘buffer, rank, MPI_INT’. No matter what you set receive to, rank 3 will always send 3 ints.

    note that you can under-fill a buffer (you could have made the last item in receive_counts 100, say), but you told the MPI library with the smaller receive_counts[3] to only expect 1 int, even though you sent 3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit (Solution Discovered) Thanks everyone for your help on this. The problem was an
EDIT - FOUND A EASY 5-10 LINE SOLUTION!!! See MY OWN ANSWER BELOW!!! YAY!!!!!!!!!
Intro: EDIT: See solution at the bottom of this question (c++) I have a
[edit] Found the solution. Reinstall EVERYTHING - xcode, mono, monodevelop and monotouch. Now it
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
My current solution will suck sometimes EDIT For those who don't understand,see this example:
Please note the Edit below for a lot more information, and a possible solution
Edit: From another question I provided an answer that has links to a lot
Edit: solution added. Hi, I currently have some working albeit slow code. It merges
[Edit: The solution to this problem is in the routes.rb file. I have resource

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.