Added assertion to segfaulting function.

parent 186e1e12
CC=mpicc
CFLAGS=-Wall -Wextra -pedantic -std=c99 -O0 -D_GNU_SOURCE
CFLAGS=-Wall -Wextra -pedantic -std=c99 -O0 -D_GNU_SOURCE -g
LDFLAGS=-lm
all: seq par
......
......@@ -3,6 +3,7 @@
#include <string.h>
#include <math.h>
#include <mpi.h>
#include <assert.h>
double **y = NULL, dx;
int steps, time, start, rank, tasks;
......@@ -21,6 +22,7 @@ static inline int last_node() {
*/
void connect(int state) {
double send[2], recv[2];
assert(tasks);
int source = (rank - 1 + tasks) % tasks, target = (rank + 1) % tasks;
MPI_Status status;
......@@ -144,6 +146,13 @@ int main(int argc, char **argv) {
void (*init_method)(double, double);
double l, tau, constant;
// Parse arguments
if( argc < 7 ) {
printf("Usage: %s INIT_METHOD CALCULATION_STEPS LENGTH DX TAU N|XP\n",
argv[0]);
return EXIT_FAILURE;
}
// Initialize and setup MPI
if( (error = MPI_Init(&argc, &argv)) != MPI_SUCCESS ) {
printf("MPI_init failed (error %d)\n", error);
......@@ -154,13 +163,6 @@ int main(int argc, char **argv) {
MPI_Comm_size(MPI_COMM_WORLD, &tasks);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// Parse arguments
if( argc < 7 ) {
printf("Usage: %s INIT_METHOD CALCULATION_STEPS LENGTH DX TAU N|XP\n",
argv[0]);
return EXIT_FAILURE;
}
if( !strcmp(argv[1], "sinus") ) {
init_method = init_sinus;
} else if( !strcmp(argv[1], "plucked") ) {
......
#!/bin/sh
#!/bin/bash
NUM_PROCESSES=${1-4} # Default: 4 processes
#RSH_AGENT=rsh
#MPI_HOSTFILE=~/.mpirun.machines
PROGRAM_EXEC=par
ARGS=sinus 1001 1 .01 1 1
ARGS="sinus 1001 1 .01 1 1"
mpirun -np $NUM_PROCESSES $PROGRAM_EXEC $@
mpirun -np $NUM_PROCESSES $PROGRAM_EXEC $ARGS
#mpirun -np $NUM_PROCESSES --mca pls_rsh_agent $RSH_AGENT \
# --hostfile $MPI_HOSTFILE $PROGRAM_EXEC
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment