



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Hints and instructions for debugging mpi applications in cosc 6374 – parallel computation course by edgar gabriel. It covers two methods for allocating 2d matrices in c, their memory locations, and the relevance of these methods when sending matrices to other processes using mpi. Additionally, it discusses debugging techniques for sequential and parallel applications, including printf statements, assertions, and using a debugger.
Typology: Assignments
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Edgar Gabriel
Debugging MPI applications
COSC 6374 – Parallel ComputationEdgar Gabriel
/* Method 1 to allocate a 2D matrix */ A = ( double *) malloc ( NROWS * sizeof ( double )); for ( i=0; i<NROWS; i++ ) { A[i] = (double) malloc (NCOLUMNSsizeof(double )); }
/* How to free a 2D matrix allocated with Method 1 */ for ( i=0; i<NROWS; i++ ) { free ( A[i] ); } free (A);
COSC 6374 – Parallel ComputationEdgar Gabriel
/* Method 2 to allocate a 2D matrix / A = ( double ) malloc ( NROWS * sizeof ( double )); A[0] = (double) malloc (NROWSNCOLUMNSsizeof(double)); for ( i=1; i<NROWS; i++ ) { A[i] = &(A[0]+iNCOLUMNS); }
/* How to free a 2D matrix allocated with Method 2 */ free (A[0]); free (A);
COSC 6374 – Parallel ComputationEdgar Gabriel
Method 1 A= 0x602010 A[0]= 0x &(A[0][0]) = 0x &(A[1][0]) = 0x &(A[2][0]) = 0x602a &(A[3][0]) = 0x602f Matrix A has been freed Method 2 A = 0x602010 A[0] = 0x &(A[0][0]) = 0x &(A[1][0]) = 0x &(A[2][0]) = 0x602a &(A[3][0]) = 0x602f Matrix A has freed Static matrix B = 0x7fff8ade7b00 B[0] = 0x7fff8ade7b &(B[0][0]) = 0x7fff8ade7b &(B[1][0]) = 0x7fff8ade &(B[2][0]) = 0x7fff8ade &(B[3][0]) = 0x7fff8ade8a
COSC 6374 – Parallel ComputationEdgar Gabriel
COSC 6374 – Parallel ComputationEdgar Gabriel
Start
Load application into the debugger
Debugger points to the problem
Show the value of a variable when the problem occurred
Show source code of app.
COSC 6374 – Parallel ComputationEdgar Gabriel
(gdb) next (skips subroutines/functions) (gdb) step (enters subroutines/functions)
(gdb) cont
COSC 6374 – Parallel ComputationEdgar Gabriel
COSC 6374 – Parallel ComputationEdgar Gabriel
COSC 6374 – Parallel ComputationEdgar Gabriel
mpirun –np 2 ddd ./colltest