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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:25:14+00:00 2026-06-02T22:25:14+00:00

void iso_diffusion_denoising(image *u, image *u_bar, float kappa, int iters) { int my_rank,num_procs; float *temp;

  • 0
void iso_diffusion_denoising(image *u, image *u_bar, float kappa, int iters) { 

  int my_rank,num_procs;
  float *temp;
  int i,j,k=0;
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
  int m=u->m;
  int n=u->n;
  //temp= malloc(n*sizeof(float));//1*n array ?

  float *ptr;

  for(k=0;k<iters;k++) {

for(i=1; i<m-1; i++) { 

  for(j=1; j<n-1; j++) {

    /*  temp[m-1]=u->image_data[m-1][0];
    temp[m-1]=u->image_data[m-1][n-1];
    temp[i]=u->image_data[m-1][j];*/


    u_bar->image_data[i][j]= u->image_data[i][j] + kappa*(u->image_data[i-1][j] + u->image_data[i][j-1] - 4*u->image_data[i][j] + u->image_data[i][j+1] + u->image_data[i+1][j]);
    u->image_data[i][j]=u_bar->image_data[i][j];
  } 
}

//temp[m-1][n-1]
if(my_rank==0) {
  ptr = u->image_data[m-1];
  MPI_Send(&ptr[0],n,MPI_FLOAT,1,1,MPI_COMM_WORLD);
  MPI_Recv(&temp,n,MPI_FLOAT,1,2,MPI_COMM_WORLD,&status);
  printf("my rank is :  %d ", my_rank);
  fflush(stdout);
} else if(my_rank==1) { //if(my_rank!=num_procs) {
  ptr = u->image_data[0];
  MPI_Send(&ptr[0],n,MPI_FLOAT,0,2,MPI_COMM_WORLD);
  MPI_Recv(&temp,n,MPI_FLOAT,1,1,MPI_COMM_WORLD,&status);
  printf("my rank is :  %d ", my_rank);
  fflush(stdout);
}

  }

}

mpirun -np 2 Oblig 0.1 20 noisy denoised

my rank is : 1114636288 [safir:22140] *** Process received signal ***
--------------------------------------------------------------------------
mpirun noticed that process rank 0 with PID 22140 on node safir.ifi.uio.no exited on signal 11 (Segmentation fault).

why is my_rank printed out with a very large value? Also I get a segmentation fault.

  • 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-02T22:25:16+00:00Added an answer on June 2, 2026 at 10:25 pm

    The problem appears to be with your first argument to MPI_Recv. Here you are sending a pointer to temp which is itself a pointer. MPI_Recv is trying to copy n floats starting at the memory location reserved for the temp pointer. You need to allocate memory for temp (uncomment the call to malloc) and change the MPI_Recv calls to:

    MPI_Recv(temp, ...
    

    This is most likely where my_rank is getting it’s garbage value. MPI_Recv is trying to write n * sizeof(float) bytes of data where temp is stored and is overwriting into memory reserved for other variables, i.e. my_rank.

    And don’t forget to free up any memory you allocate for temp when you are done with it!

    A couple other things, I’ve done very little MPI programming but I think your MPI_Recv call in the my_rank == 1 block should have a source of 0. I also thought MPI_Send and MPI_Recv were blocking calls – in other words they don’t return until the transfer either completes or fails. Since both of your ranks are calling MPI_Send first I would expect them to both block and deadlock your program. Maybe they are failing – you should check the return value of MPI_Send for success.

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

Sidebar

Related Questions

void FileManager::CloseFile(File * const file) { for (int i = 0; i < MAX_OPEN_FILES;
so I had this code: #include <list> void j(){ list<int> first; } but then
- (void)viewDidUnload { self.GPSArray = nil; self.accelerometerArray = nil; self.headingArray = nil; self.managedObjectContext =
- (void)applicationDidFinishLaunching:(UIApplication *)application { // Create the navigation and view controllers RootViewController *rootViewController =
-(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *theXML = [[NSString alloc] initWithBytes: [myWebData mutableBytes] length:[myWebData length] encoding:NSUTF8StringEncoding];
void BinaryTree::InitializeFromFile(string Filename){ ifstream inFile; treenode* Freq[256]; inFile.open(Filename.c_str(), fstream::binary); if(inFile.fail()){ cout<<Error in opening file
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { touchStartTime = [event timestamp]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
void main(void) { vec4 clipCoord = glModelViewProjectionmatrix * gl_Vertex; gl_Position = clipCoord; gl_FrontColor =
void GasPump::dispense() { bool cont = true; char stop; do{ cout << Press any
-(void) readProductsFromDatabase { // Setup the database object sqlite3 *database; // Init the animals

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.