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

  • SEARCH
  • Home
  • 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 7609751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:14:58+00:00 2026-05-31T01:14:58+00:00

I doing an application using C and MPI that makes a vector by Matrix

  • 0

I doing an application using C and MPI that makes a vector by Matrix multiplication, but I keep having errors like Error posting readv , and An existing connection was forcibly closed by the remote host (10054)
Here is the code:

#include "stdio.h"
#include "mpi.h"

#define W 5
#define H 5

void make_matrix(int[]);
void make_vector(int []);

void main(int argc, char* argv[])
{

  int myrank,size,k;
  int matrix[H*W];
  int vec[W];
  int res[W];
  static int col_count = 0;

  MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
  MPI_Comm_rank(MPI_COMM_WORLD,&size);

  MPI_Bcast(vec,W,MPI_INT,0,MPI_COMM_WORLD);

  if(myrank != 0)
  {
    for(k=0; k<W; k++)
    {
      vec[k]+= matrix[k*W+col_count];
    }
    col_count++;
    printf("%d ",vec[col_count]);
  }

  MPI_Finalize();
}

void make_matrix(int a[])
{
  int i;
  for(i=0; i<H*W; i+=1)
  {
    a[i] = i;
  }
};

void make_vector(int v[])
{
  int i;
  for(i=0; i<H; i++)
    v[i] = i*2;
};
  • 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-31T01:14:59+00:00Added an answer on May 31, 2026 at 1:14 am

    MPI_Bcast() is a collective function, which means that every process in the communicator must call it. In other words, don’t call MPI_Recv(). So get rid of your if(myrank == 0) conditional and have all processes call:

    MPI_Bcast(vec,W,MPI_INT,0,MPI_COMM_WORLD);
    

    Note that I have vec above, not &vec; since vec is already an array, it is the pointer that MPI needs. Also, your result will appear in vec on the non-root processes; there is no need for the separate arr array.

    I recommend that you read some examples of MPI and try to make your code look more like them.

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

Sidebar

Related Questions

I am using jaxb for my application configurations I feel like I am doing
I'm using rails, but doing all my Javascript unobtrusively using jQuery in application.js .
I wrote an application using wxWidgets that uses wxList . I am having some
I am doing Multimedia application using client server interaction, for that i uploaded some
I'm doing this application in C# using the free Krypton Toolkit but the Krypton
We need to represent huge numbers in our application. We're doing this using integer
People always advised me that if I am doing some application that should use
I am doing one application using proximity sensor in android. when any object(finger) comes
I am doing my application using RoR, which make me very annoying is the
Good morning everyone! I'm doing a distributed application using .NET 4.0, C# and Remoting

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.