diff --git a/cs677/pa2/Makefile b/cs677/pa2/Makefile index b40f6cf..e792a6d 100644 --- a/cs677/pa2/Makefile +++ b/cs677/pa2/Makefile @@ -6,5 +6,12 @@ all: $(PROGS) %: %.cc $(CXX) -o $@ -pthread -O3 $< +.PHONY: test +test: all + ./sequential e1.* + ./threaded e1.* + ./sequential e2.* + ./sequential e2.* + clean: -rm -f $(PROGS) *~ *.o diff --git a/cs677/pa2/e1.seq b/cs677/pa2/e1.seq new file mode 100644 index 0000000..031844a --- /dev/null +++ b/cs677/pa2/e1.seq @@ -0,0 +1 @@ +GATATGCA diff --git a/cs677/pa2/e1.unk b/cs677/pa2/e1.unk new file mode 100644 index 0000000..73a6eb4 --- /dev/null +++ b/cs677/pa2/e1.unk @@ -0,0 +1 @@ +ATAGCT diff --git a/cs677/pa2/e2.seq b/cs677/pa2/e2.seq new file mode 100644 index 0000000..c944a8d --- /dev/null +++ b/cs677/pa2/e2.seq @@ -0,0 +1 @@ +AATCGGATTC diff --git a/cs677/pa2/e2.unk b/cs677/pa2/e2.unk new file mode 100644 index 0000000..e307130 --- /dev/null +++ b/cs677/pa2/e2.unk @@ -0,0 +1 @@ +GACGGTTCGT diff --git a/cs677/pa2/threaded.cc b/cs677/pa2/threaded.cc index 0506721..3f47e51 100644 --- a/cs677/pa2/threaded.cc +++ b/cs677/pa2/threaded.cc @@ -142,6 +142,7 @@ void * calcSimMatrixThread(void * arg) int id = *realarg; int s_size = s->size(); int t_size = t->size(); + int last_step = s_size + t_size; int (*F)[s_size][t_size] = (int (*) [s_size][t_size]) matrix; int max_x = 0, max_y = 0, max_val = 0; int first_task_id, num_tasks; @@ -152,10 +153,13 @@ void * calcSimMatrixThread(void * arg) for (int i = 0, idx = first_task_id; i < num_tasks; i++, idx++) (*F)[idx][0] = 0; /* set first column to 0's */ pthread_barrier_wait(&barrier); - for (int i = 1; i <= s_size; i++) + for (int step = 2; i <= last_step; i++) { - for (int j = 1; j <= t_size; j++) + /* TODO: figure out how many tasks there are in this step */ + /* TODO: call taskAllocate() to get mine */ + /* TODO: loop over tasks assigned by taskAllocate() */ { + /* TODO: figure out i, j from step and task */ /* Compute the value for the matrix */ (*F)[i][j] = max( @@ -187,6 +191,7 @@ void * calcSimMatrixThread(void * arg) } } } + pthread_barrier_wait(&barrier); } cout << "Maximum value is " << max_val << " at position ("