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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:37:17+00:00 2026-05-20T15:37:17+00:00

I am solving this problem. I am implementing cycling mapping, I have 4 processors,

  • 0

I am solving this problem. I am implementing cycling mapping, I have 4 processors, so one task is mapped on processor 1 (root), and then three others are workers. I am using cyclic mapping, and I have as a input several integers, e.g. 0-40. I want from each worker to receive (in this case it would be 10 integers for each worker), do some counting and save it.

I am using MPI_Send to send integers from root, but I don’t how to multiply receive some numbers from the same process (root). Also I send int with buffer size fixed on 1, when there is number e.g. 12, it would do bad things. How to check length of an int?

Any advice would be appreciated. Thanks

  • 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-20T15:37:18+00:00Added an answer on May 20, 2026 at 3:37 pm

    I’ll assume you’re working in C++, though your question doesn’t say. Anyway, let’s look at the arguments of MPI_Send:

    MPI_SEND(buf, count, datatype, dest, tag, comm)
    

    The second argument specifies how many data items you want to send. This call basically means “buf points to a point in memory where there are count number of values, all of them of type datatype, one after the other: send them”. This lets you send the contents of an entire array, like this:

    int values[10];
    for (int i=0; i<10; i++)
        values[i] = i;
    MPI_Send(values, 10, MPI_INTEGER, 1, 0, MPI_COMM_WORLD);
    

    This will start reading memory at the start of values, and keep reading until 10 MPI_INTEGERs have been read.

    For your case of distributing numbers between processes, this is how you do it with MPI_Send:

    int values[40];
    for (int i=0; i<40; i++)
        values[i] = i;
    for (int i=1; i<4; i++)  // start at rank 1: don't send to ourselves
        MPI_Send(values+10*i, 10, MPI_INTEGER, i, 0, MPI_COMM_WORLD);
    

    However, this is such a common operation in distributed computing that MPI gives it its very own function, MPI_Scatter. Scatter does exactly what you want: it takes one array and divides it up evenly between all processes who call it. This is a collective communication call, which is a slightly advanced topic, so if you’re just learning MPI (which it sounds like you are), then feel free to skip it until you’re comfortable using MPI_Send and MPI_Recv.

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

Sidebar

Related Questions

Ok, I have been working on solving this problem all day, and I am
I have the following problem in my Data Structures and Problem Solving using Java
I am in the middle of solving a problem which requires me to do
I have heard the 'shard' technique mentioned several times with regard to solving scaling
I have been struggling with this for the entire day now, I hope somebody
Currently I have this code: var databaseTimeZoneMS = -240 * 60000; var time =
I understand this is a basic question... but I have been stuck on it
The title for this one was quite tricky. I'm trying to solve a scenario,
I've had a go at solving the Eternity puzzle (1,000,000 GBP prize) and Netflix
I was reading the following article: http://msdn.microsoft.com/en-us/magazine/cc817398.aspx Solving 11 Likely Problems In Your Multithreaded

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.