# Makefile for MPI-Spin model of Example 4.18 from
# "MPI: The Complete Reference, vol. 1", 2nd ed.

# We check the equivalence between symbolic expressions
# generated from the sequential and the parallel version.

# The associativity of addition and multiplication is 
# supported only in Real arithmetic.
# The verifier flags an error when using 
# IEEE and Herbrand equivalence

# Author:        Pujan Kafle <kafle@cis.udel.edu>
# Last modified: 19-jul-2007


PREP        = rm -f pan* *trail mpi-spin-init.c
MS          = $(PREP); ms -notest -nocancel -noprobe

# A is a vector of size M
# B is a matrix of size M x N
# A_SIZE = M
# B_SIZE = M x N

PARAMS0_real     = -np=3 -DM=7 -DN=5 -DA_SIZE=7 -DB_SIZE=35 \
                   -buf=8 -req=8 -sym=2 
PARAMS0_real_b   = -np=3 -DM=7 -DN=5 -DA_SIZE=7 -DB_SIZE=35 \
                   -block -chansize=2 -sym=2 
PARAMS0_ieee     = -np=3 -DM=7 -DN=5 -DA_SIZE=7 -DB_SIZE=35 \
                   -buf=8 -req=8 -sym=1 
PARAMS0_herbrand = -np=3 -DM=7 -DN=5 -DA_SIZE=7 -DB_SIZE=35 \
                   -buf=8 -req=8 -sym=0 
PARAMS1_real     = -np=6 -DM=8 -DN=7 -DA_SIZE=8 -DB_SIZE=56 \
                   -buf=8 -req=8 -sym=2
PARAMS1_real_b   = -np=6 -DM=8 -DN=7 -DA_SIZE=8 -DB_SIZE=56 \
                   -block -chansize=8 -sym=2
PARAMS1_ieee     = -np=6 -DM=8 -DN=7 -DA_SIZE=8 -DB_SIZE=56 \
                   -buf=8 -req=8 -sym=1
PARAMS1_herbrand = -np=6 -DM=8 -DN=7 -DA_SIZE=8 -DB_SIZE=56 \
                   -buf=8 -req=8 -sym=0

all: vector_matrix_01a vector_matrix_01b vector_matrix_01c \
     vector_matrix_01d vector_matrix_02a vector_matrix_02b \
     vector_matrix_02c vector_matrix_02d mpi_vector_matrix

vector_matrix_01a: vector_matrix.prom
	$(MS) $(PARAMS0_real) vector_matrix.prom
	mscc
	./pan -n

vector_matrix_01b: vector_matrix.prom
	$(MS) $(PARAMS0_real_b) vector_matrix.prom
	mscc
	./pan -n

vector_matrix_01c: vector_matrix.prom
	$(MS) $(PARAMS0_ieee) vector_matrix.prom
	mscc
	./pan -n

vector_matrix_01d: vector_matrix.prom
	$(MS) $(PARAMS0_herbrand) vector_matrix.prom
	mscc
	./pan -n

vector_matrix_02a: vector_matrix.prom	
	$(MS) $(PARAMS1_real) vector_matrix.prom
	mscc -DVECTORSZ=2048
	./pan -n

vector_matrix_02b: vector_matrix.prom	
	$(MS) $(PARAMS1_real_b) vector_matrix.prom
	mscc -DVECTORSZ=8192
	./pan -n

vector_matrix_02c: vector_matrix.prom	
	$(MS) $(PARAMS1_ieee) vector_matrix.prom
	mscc -DVECTORSZ=2048
	./pan -n

vector_matrix_02d: vector_matrix.prom	
	$(MS) $(PARAMS1_herbrand) vector_matrix.prom
	mscc -DVECTORSZ=2048
	./pan -n

mpi_vector_matrix: vector_matrix.c
	mpicc -DM=7 -DN=5 -o vector_matrix vector_matrix.c
	mpiexec -n 3 ./vector_matrix

clean:
	-rm -f vector_matrix pan* *.trail *.out mpi-spin-init.c *.err *~
