Sponsored Content
Top Forums Programming (MPI) Segmentation fault with dynamic allocated 2D array Post 302150770 by porter on Wednesday 12th of December 2007 03:17:03 PM
Old 12-12-2007
Quote:
Originally Posted by lancer6238
Please advise. Thank you.
Firstly, make a backup.

Then remove all the code that refers to arrays of ints and just prove that you can pass a buffer of characters around, effectively an MPI Hello World. Confirm that this cleanly exits.

Then be careful with your type casting whereever there is a void *, for instance the first argument to MPI_Send.

If you want to send 'ints' then change that to a

Code:
int *mySendData=&(cell[i][0]);
MPI_Send(mySendData,.....

and similarly on the read, this lets the compiler do type checking for you.

Also, run the thing under a debugger or use the core dump to find out where the thing is failing. Have you not closed the library down correctly? Is this a build issue? Is it compiler options or selection of libraries?
 

10 More Discussions You Might Find Interesting

1. Programming

segmentation fault

hi all i'm trying to execute a c program under linux RH and it gives me segmentation fault, this program was running under unix at&t anybody kow what the problem could be? thanx in advance regards (2 Replies)
Discussion started by: omran
2 Replies

2. UNIX for Dummies Questions & Answers

Segmentation Fault

hello all, I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element. ... (3 Replies)
Discussion started by: compbug
3 Replies

3. Programming

Hi! segmentation fault

I have written a program which takes a directory as command line arguments and displays all the dir and files in it. I don't know why I have a problem with the /etc directory.It displays all the directories and files untill it reaches a sub directory called peers which is in /etc/ppp/peers.the... (4 Replies)
Discussion started by: vijlak
4 Replies

4. Programming

segmentation fault

If I do this. Assume struct life { char *nolife; } struct life **life; // malloc initialization & everything if(life->nolife == 0) Would I get error at life->nolife if it is equal to 0. wrong accession? (3 Replies)
Discussion started by: joey
3 Replies

5. Programming

segmentation fault

What is segmentation fault(core dumped) (1 Reply)
Discussion started by: gokult
1 Replies

6. Programming

Segmentation fault.

I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek: #include </usr/include/mysql++/mysql++.h> #include <stdio.h> #include <iostream> #include <sstream> #include <string.h> using namespace std; int outputToImport(const char*... (1 Reply)
Discussion started by: sepoto
1 Replies

7. Programming

segmentation fault.

This code is causing a segmentation fault and I can't figure out why. I'm new to UNIX and I need to learn how to avoid this segmentation fault thing. Thank you so much. Thanks also for the great answers to my last post.:):b: int main() { mysqlpp::Connection conn(false); if... (3 Replies)
Discussion started by: sepoto
3 Replies

8. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

9. Programming

Segmentation fault

I keep getting this fault on a lot of the codes I write, I'm not exactly sure why so I'd really appreciate it if someone could explain the idea to me. For example this code #include <stdio.h> main() { unsigned long a=0; unsigned long b=0; int z; { printf("Enter two... (2 Replies)
Discussion started by: sizzler786
2 Replies

10. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
MPI_Scatter(3OpenMPI)													     MPI_Scatter(3OpenMPI)

NAME
MPI_Scatter - Sends data from one task to all tasks in a group. SYNTAX
C Syntax #include <mpi.h> int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) Fortran Syntax INCLUDE 'mpif.h' MPI_SCATTER(SENDBUF, SENDCOUNT, SENDTYPE, RECVBUF, RECVCOUNT, RECVTYPE, ROOT, COMM, IERROR) <type> SENDBUF(*), RECVBUF(*) INTEGER SENDCOUNT, SENDTYPE, RECVCOUNT, RECVTYPE, ROOT INTEGER COMM, IERROR C++ Syntax #include <mpi.h> void MPI::Comm::Scatter(const void* sendbuf, int sendcount, const MPI::Datatype& sendtype, void* recvbuf, int recvcount, const MPI::Datatype& recvtype, int root) const INPUT PARAMETERS
sendbuf Address of send buffer (choice, significant only at root). sendcount Number of elements sent to each process (integer, significant only at root). sendtype Datatype of send buffer elements (handle, significant only at root). recvcount Number of elements in receive buffer (integer). recvtype Datatype of receive buffer elements (handle). root Rank of sending process (integer). comm Communicator (handle). OUTPUT PARAMETERS
recvbuf Address of receive buffer (choice). IERROR Fortran only: Error status (integer). DESCRIPTION
MPI_Scatter is the inverse operation to MPI_Gather. The outcome is as if the root executed n send operations, MPI_Send(sendbuf + i * sendcount * extent(sendtype), sendcount, sendtype, i, ...) and each process executed a receive, MPI_Recv(recvbuf, recvcount, recvtype, i, ...). An alternative description is that the root sends a message with MPI_Send(sendbuf, sendcount * n, sendtype, ...). This message is split into n equal segments, the ith segment is sent to the ith process in the group, and each process receives this message as above. The send buffer is ignored for all nonroot processes. The type signature associated with sendcount, sendtype at the root must be equal to the type signature associated with recvcount, recvtype at all processes (however, the type maps may be different). This implies that the amount of data sent must be equal to the amount of data received, pairwise between each process and the root. Distinct type maps between sender and receiver are still allowed. All arguments to the function are significant on process root, while on other processes, only arguments recvbuf, recvcount, recvtype, root, comm are significant. The arguments root and comm must have identical values on all processes. The specification of counts and types should not cause any location on the root to be read more than once. Rationale: Though not needed, the last restriction is imposed so as to achieve symmetry with MPI_Gather, where the corresponding restric- tion (a multiple-write restriction) is necessary. Example: The reverse of Example 1 in the MPI_Gather manpage. Scatter sets of 100 ints from the root to each process in the group. MPI_Comm comm; int gsize,*sendbuf; int root, rbuf[100]; ... MPI_Comm_size(comm, &gsize); sendbuf = (int *)malloc(gsize*100*sizeof(int)); ... MPI_Scatter(sendbuf, 100, MPI_INT, rbuf, 100, MPI_INT, root, comm); USE OF IN-PLACE OPTION When the communicator is an intracommunicator, you can perform a gather operation in-place (the output buffer is used as the input buffer). Use the variable MPI_IN_PLACE as the value of the root process recvbuf. In this case, recvcount and recvtype are ignored, and the root process sends no data to itself. Note that MPI_IN_PLACE is a special kind of value; it has the same restrictions on its use as MPI_BOTTOM. Because the in-place option converts the receive buffer into a send-and-receive buffer, a Fortran binding that includes INTENT must mark these as INOUT, not OUT. WHEN COMMUNICATOR IS AN INTER-COMMUNICATOR When the communicator is an inter-communicator, the root process in the first group sends data to all processes in the second group. The first group defines the root process. That process uses MPI_ROOT as the value of its root argument. The remaining processes use MPI_PROC_NULL as the value of their root argument. All processes in the second group use the rank of that root process in the first group as the value of their root argument. The receive buffer argument of the root process in the first group must be consistent with the receive buffer argument of the processes in the second group. ERRORS
Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. C++ func- tions do not return errors. If the default error handler is set to MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism will be used to throw an MPI:Exception object. Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. SEE ALSO
MPI_Scatterv MPI_Gather MPI_Gatherv Open MPI 1.2 September 2006 MPI_Scatter(3OpenMPI)
All times are GMT -4. The time now is 10:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy