added test cases, skeleton logic for threaded
git-svn-id: svn://anubis/gvsu@176 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
a2c1631657
commit
1c3b6ac652
@ -6,5 +6,12 @@ all: $(PROGS)
|
|||||||
%: %.cc
|
%: %.cc
|
||||||
$(CXX) -o $@ -pthread -O3 $<
|
$(CXX) -o $@ -pthread -O3 $<
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: all
|
||||||
|
./sequential e1.*
|
||||||
|
./threaded e1.*
|
||||||
|
./sequential e2.*
|
||||||
|
./sequential e2.*
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f $(PROGS) *~ *.o
|
-rm -f $(PROGS) *~ *.o
|
||||||
|
1
cs677/pa2/e1.seq
Normal file
1
cs677/pa2/e1.seq
Normal file
@ -0,0 +1 @@
|
|||||||
|
GATATGCA
|
1
cs677/pa2/e1.unk
Normal file
1
cs677/pa2/e1.unk
Normal file
@ -0,0 +1 @@
|
|||||||
|
ATAGCT
|
1
cs677/pa2/e2.seq
Normal file
1
cs677/pa2/e2.seq
Normal file
@ -0,0 +1 @@
|
|||||||
|
AATCGGATTC
|
1
cs677/pa2/e2.unk
Normal file
1
cs677/pa2/e2.unk
Normal file
@ -0,0 +1 @@
|
|||||||
|
GACGGTTCGT
|
@ -142,6 +142,7 @@ void * calcSimMatrixThread(void * arg)
|
|||||||
int id = *realarg;
|
int id = *realarg;
|
||||||
int s_size = s->size();
|
int s_size = s->size();
|
||||||
int t_size = t->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 (*F)[s_size][t_size] = (int (*) [s_size][t_size]) matrix;
|
||||||
int max_x = 0, max_y = 0, max_val = 0;
|
int max_x = 0, max_y = 0, max_val = 0;
|
||||||
int first_task_id, num_tasks;
|
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++)
|
for (int i = 0, idx = first_task_id; i < num_tasks; i++, idx++)
|
||||||
(*F)[idx][0] = 0; /* set first column to 0's */
|
(*F)[idx][0] = 0; /* set first column to 0's */
|
||||||
pthread_barrier_wait(&barrier);
|
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 */
|
/* Compute the value for the matrix */
|
||||||
(*F)[i][j] =
|
(*F)[i][j] =
|
||||||
max(
|
max(
|
||||||
@ -187,6 +191,7 @@ void * calcSimMatrixThread(void * arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pthread_barrier_wait(&barrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Maximum value is " << max_val << " at position ("
|
cout << "Maximum value is " << max_val << " at position ("
|
||||||
|
Loading…
x
Reference in New Issue
Block a user