The unified diff between revisions [c79c1246..] and [8ad2cbb1..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "aca319/Makefile"
#  from [df0e69d3b7c14e61e416e26bc62711cb498e0efc]
#    to [99193ecd2c6a8ad4f32b3c3ba45ddb43cc6c8f99]
#
# patch "aca319/gen-rand.py"
#  from [2f32df8f6a4bb6be7598bf6960dc7e3a78ebbcc1]
#    to [4a6fa6adb0ea87655042628f983f49775800cab5]
#
# patch "aca319/lab7q1.c"
#  from [4ecac7fccb527e95ed1c01774541ff4e80eafbe0]
#    to [faa415d2e67b7d4e55638298bec634720765dc44]
#
============================================================
--- aca319/Makefile	df0e69d3b7c14e61e416e26bc62711cb498e0efc
+++ aca319/Makefile	99193ecd2c6a8ad4f32b3c3ba45ddb43cc6c8f99
@@ -54,6 +54,9 @@ run_lab6q2:
 run_lab6q2:
 	mpirun -machinefile machines -np 5 lab6q2

+run_lab7q1:
+	mpirun -machinefile machines -np 5 lab7q1
+
 clean:
-	rm -f *.o lab1q1 lab1q2 lab2q1 lab2q2 lab3q1 lab3q2 lab3q3 lab4q1 lab4q1_up lab5q1 lab5q2 lab6q1 lab6q2
+	rm -f *.o lab1q1 lab1q2 lab2q1 lab2q2 lab3q1 lab3q2 lab3q3 lab4q1 lab4q1_up lab5q1 lab5q2 lab6q1 lab6q2 lab7q1

============================================================
--- aca319/gen-rand.py	2f32df8f6a4bb6be7598bf6960dc7e3a78ebbcc1
+++ aca319/gen-rand.py	4a6fa6adb0ea87655042628f983f49775800cab5
@@ -3,5 +3,5 @@ if __name__ == '__main__':
 import random

 if __name__ == '__main__':
-	for i in range(100):
+	for i in range(500):
 		print "%d" % (random.randint(0,500))
============================================================
--- aca319/lab7q1.c	4ecac7fccb527e95ed1c01774541ff4e80eafbe0
+++ aca319/lab7q1.c	faa415d2e67b7d4e55638298bec634720765dc44
@@ -1,26 +1,97 @@

+#include <stdio.h>
+#include <stdlib.h>

+#include "mpi.h"
+#include "mpe.h"
+
+#define	FALSE			0
+#define TRUE			!(FALSE)
+#define INPUT_VECTOR_SIZE	100
+
+int ev_start_compute, ev_end_compute;
+
 /* read N integers from an input file
  * integers are >= 0
  * values < 0 are not permitted
  */
-int *
-read_from_file(const char *filename, int *min, int *max, int *length)
+int
+read_from_file(const char *filename, int *dataset, int *min, int *max)
 {
-	FILE *f = fopen(filename);
+	FILE *f = fopen(filename, "r");
+	int val;
+	int i=0;
+
 	if (!f) {
 		fprintf(stderr, "Unable to open input file.\n");
-		return NULL;
+		return FALSE;
 	}
-	while (fscanf(f, "%d\n", val)) {
-		printf("read value: %d\n", val);
+	while ((i < INPUT_VECTOR_SIZE) && (fscanf(f, "%d\n", &val) != EOF)) {
+		dataset[i] = val;
+		if (val > *max) *max = val;
+		if (val < *min) *min = val;
+		i++;
 	}
+	if (i < INPUT_VECTOR_SIZE) {
+		fprintf(stderr, "Read too few lines!\n");
+		return FALSE;
+	}
+	return TRUE;
 }

+void
+master(int rank, int size)
+{
+	int input_min, input_max;
+	int dataset[INPUT_VECTOR_SIZE];
+
+	/* first of all, read our input file */
+	if (!read_from_file("lab7in.txt", dataset, &input_min, &input_max)) {
+		fprintf(stderr, "Unable to read input file!\n");
+		return;
+	}
+	fprintf(stderr, "[%d] dataset has min of %d and max of %d\n", rank, input_min, input_max);
+
+	/* check that the dataset splits evenly over size */
+	if (INPUT_VECTOR_SIZE % size != 0) {
+		fprintf(stderr, "Input vector does not split evenly over this number of processors. Abort.\n");
+	}
+}
+
+
+void
+slave(int rank, int size)
+{
+
+
+
+}
+
 int
 main(int argc, char *argv[])
 {
-	read_from_file("lab7in.txt");
+	int rank, size;
+
+	MPI_Init(&argc, &argv);
+
+	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+	MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+	MPE_Init_log();
+
+	ev_start_compute = MPE_Log_get_event_number();
+	ev_end_compute = MPE_Log_get_event_number();
+
+	if (rank == 0) {
+		master(rank, size);
+	} else {
+		slave(rank, size);
+	}
+
+	MPE_Finish_log("lab7q1");
+	MPI_Finalize();
+
+	return 0;
 }