Skip to content

Commit

Permalink
Adding support for multiple kernels per file, closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsighter committed Jun 17, 2015
1 parent d7efbc0 commit fec6693
Show file tree
Hide file tree
Showing 8 changed files with 650 additions and 470 deletions.
39 changes: 25 additions & 14 deletions src/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void BarrierInstance::compute_transitivity(Weft *weft, bool forward)
// Then do the transitive update
if (forward)
{
latest_before.resize(graph->weft->thread_count(), -1);
latest_before.resize(graph->program->thread_count(), -1);
for (std::vector<WeftBarrier*>::const_iterator it =
participants.begin(); it != participants.end(); it++)
{
Expand All @@ -299,7 +299,7 @@ void BarrierInstance::compute_transitivity(Weft *weft, bool forward)
}
else
{
earliest_after.resize(graph->weft->thread_count(), -1);
earliest_after.resize(graph->program->thread_count(), -1);
for (std::vector<WeftBarrier*>::const_iterator it =
participants.begin(); it != participants.end(); it++)
{
Expand Down Expand Up @@ -438,16 +438,16 @@ void BarrierDependenceGraph::PreceedingBarriers::add_instance(
next->update_waiting_threads(arrival_threads);
}

BarrierDependenceGraph::BarrierDependenceGraph(Weft *w)
: weft(w), max_num_barriers(w->barrier_upper_bound())
BarrierDependenceGraph::BarrierDependenceGraph(Weft *w, Program *p)
: weft(w), program(p), max_num_barriers(p->barrier_upper_bound())
{
barrier_instances.resize(max_num_barriers);
PTHREAD_SAFE_CALL( pthread_mutex_init(&validation_mutex, NULL) );
}

BarrierDependenceGraph::BarrierDependenceGraph(
const BarrierDependenceGraph &rhs)
: weft(NULL), max_num_barriers(0)
: weft(NULL), program(NULL), max_num_barriers(0)
{
assert(false);
}
Expand Down Expand Up @@ -496,19 +496,28 @@ void BarrierDependenceGraph::construct_graph(
{
if (weft->print_detail())
{
char buffer[1024];
snprintf(buffer, 1023, "DEADLOCK DETECTED IN KERNEL %s! "
"(thread and barrier state reported above)",
program->get_name());
report_state(program_counters, threads, pending_arrives);
weft->report_error(WEFT_ERROR_DEADLOCK, "DEADLOCK DETECTED! "
"(thread and barrier state reported above)");
weft->report_error(WEFT_ERROR_DEADLOCK, buffer);
}
else
weft->report_error(WEFT_ERROR_DEADLOCK, "DEADLOCK DETECTED! "
"(run in detailed mode with '-d' to see thread and barrier state)");
{
char buffer[1024];
snprintf(buffer, 1023, "DEADLOCK DETECTED IN KERNEL %s! "
"(run in detailed mode with '-d' to see thread and barrier state)",
program->get_name());
weft->report_error(WEFT_ERROR_DEADLOCK, buffer);
}
}
else
fprintf(stdout,"WEFT INFO: No deadlocks detected!\n");
fprintf(stdout,"WEFT INFO: No deadlocks detected in kernel %s!\n",
program->get_name());
if (weft->print_verbose())
fprintf(stdout,"WEFT INFO: Total barrier instances: %ld\n",
all_barriers.size());
fprintf(stdout,"WEFT INFO: Total barrier instances in kernel %s: %ld\n",
program->get_name(), all_barriers.size());
}

int BarrierDependenceGraph::count_validation_tasks(void)
Expand Down Expand Up @@ -547,7 +556,8 @@ void BarrierDependenceGraph::check_for_validation_errors(void)
// threadpool when we invokee this method
if (!failed_validations.empty())
{
fprintf(stderr, "WEFT INFO: BARRIERS NOT PROPERLY RECYCLED!\n");
fprintf(stderr, "WEFT INFO: BARRIERS NOT PROPERLY RECYCLED "
"IN KERNEL %s!\n", program->get_name());
for (std::vector<std::pair<int,int> >::const_iterator it =
failed_validations.begin(); it != failed_validations.end(); it++)
{
Expand All @@ -562,7 +572,8 @@ void BarrierDependenceGraph::check_for_validation_errors(void)
weft->report_error(WEFT_ERROR_GRAPH_VALIDATION, buffer);
}
else
fprintf(stdout,"WEFT INFO: Barriers properly recycled!\n");
fprintf(stdout,"WEFT INFO: Barriers properly recycled in kernel %s!\n",
program->get_name());
}

void BarrierDependenceGraph::validate_barrier(int name, int generation)
Expand Down
3 changes: 2 additions & 1 deletion src/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class BarrierDependenceGraph {
std::deque<BarrierInstance*> previous;
};
public:
BarrierDependenceGraph(Weft *weft);
BarrierDependenceGraph(Weft *weft, Program *p);
BarrierDependenceGraph(const BarrierDependenceGraph &rhs);
~BarrierDependenceGraph(void);
public:
Expand Down Expand Up @@ -150,6 +150,7 @@ class BarrierDependenceGraph {
void initialize_pending_counts(void);
public:
Weft *const weft;
Program *const program;
const int max_num_barriers;
protected:
std::vector<std::deque<BarrierInstance*> > barrier_instances;
Expand Down
Loading

0 comments on commit fec6693

Please sign in to comment.