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 8897899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:28:13+00:00 2026-06-15T00:28:13+00:00

I have something like: int numprocs, id, arr[10], winner = -1; bool stop =

  • 0

I have something like:

int numprocs, id, arr[10], winner = -1;
bool stop = false;
MPI_Request reqs[10], winnerNotification;

MPI_Init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &id);

srand(time(NULL) + id);

if (id == 10) {
    int completed = 0;
    int* completedIndexes;
    for (int i = 0; i < 10; i++) {
        MPI_Irecv(&arr[i], 1, MPI_INT, i, 0, MPI_COMM_WORLD, &reqs[i]);
    }
    MPI_Waitsome(10, reqs, &completed, completedIndexes, MPI_STATUSES_IGNORE);
    cout << completed << " seems to have completed" << endl;
    for (int i = 0; i < completed; i++) {
        cout << completedIndexes[i] << " have completed!";
    }
}

while (id < 10 && winner == -1) {
    if (((rand() % 100) + 1) < 5) { // players have 5% chance of completing
        MPI_Send(&id, 1, MPI_INT, 10, 0, MPI_COMM_WORLD);
        cout << id << " completed" << endl;
        MPI_Wait(&winnerNotification, MPI_STATUS_IGNORE);
    }
}

MPI_Finalize();

Which is giving segmentation fault, I think its something to do with Waitsome? But what? The error looks like:

1 completed
[JM:01317] *** Process received signal ***
[JM:01317] Signal: Segmentation fault (11)
[JM:01317] Signal code: Address not mapped (1)
[JM:01317] Failing at address: 0x646574
4 completed
5 completed
[JM:01320] *** Process received signal ***
[JM:01320] Signal: Segmentation fault (11)
[JM:01320] Signal code: Address not mapped (1)
[JM:01320] Failing at address: 0x646574
3 completed
[JM:01319] *** Process received signal ***
[JM:01319] Signal: Segmentation fault (11)
[JM:01319] Signal code: Address not mapped (1)
[JM:01319] Failing at address: 0x646574
...
  • 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-06-15T00:28:14+00:00Added an answer on June 15, 2026 at 12:28 am

    MPI_Waitsome expects an array of integers where it stores the indices of the completed requests, but what you give to it is an uninitialised int pointer. Given the fact that you have hardcoded 10 as the number of requests, the following code should work:

    if (id == 10) {
        int completed = 0;
        int completedIndexes[10];
        for (int i = 0; i < 10; i++) {
            MPI_Irecv(&arr[i], 1, MPI_INT, i, 0, MPI_COMM_WORLD, &reqs[i]);
        }
        MPI_Waitsome(10, reqs, &completed, completedIndexes, MPI_STATUSES_IGNORE);
        cout << completed << " seems to have completed" << endl;
        for (int i = 0; i < completed; i++) {
            cout << completedIndexes[i] << " have completed!";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: __global__ void globFunction(int *arr, int N) { int idx
I have something like this: int* a = NULL; int* b = *a; b
I have something like the code below: for(int i=0;i<10;i++){ button=new JButton(buttons[i]); button.addActionListener(new ActionListener(){ public
I have something like this: create table account ( id int identity(1,1) primary key,
If I have something like class Base { static int staticVar; } class DerivedA
Suppose I have something like this: class A { public B mem; public int
Okay, I have something like this in C++: class MyClass{ private: int someVariable; int
I have a code that looks something like: struct Data { int value; };
I have a constexpr function that looks something like this: constexpr int foo(int bar)
I have two tables which looks something like this Table Queue int ID; string

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.