Skip to content
Snippets Groups Projects
Commit c2e769c3 authored by GRASLAND Hadrien's avatar GRASLAND Hadrien
Browse files

Various bugfixes, still broken

parent eef895ca
No related branches found
No related tags found
No related merge requests found
Pipeline #338183 passed
......@@ -174,8 +174,7 @@ void main() {
}
#endif
// Validated the tile selection, now make sure we fetch up-to-date data
// in process_tile.
// Make sure process_tile operates on up-to-date data
memoryBarrierBuffer();
// Process selected tile
......@@ -209,7 +208,7 @@ void main() {
#endif
// Terminate work-group once it finishes a tile
if (s_output_buffer_idx == LAST_BUFFER_IDX) {
if (s_input_buffer_idx == LAST_BUFFER_IDX) {
#if DEBUG
if (is_leader()) atomicAdd(g_metadata.num_normal_exit, 1);
#endif
......
......@@ -22,10 +22,12 @@ bool leader_try_acquire_tile() {
}
#endif
const uint expected_input_idx = s_input_buffer_idx;
const uint expected_steal_count = s_expected_steal_count;
do {
// Try to signal other work-groups that we're working on this tile
const uint desired_steal_count = s_expected_steal_count + 1;
const uint desired_tile_status = encode_tile_status(s_input_buffer_idx,
const uint desired_steal_count = expected_steal_count + 1;
const uint desired_tile_status = encode_tile_status(expected_input_idx,
desired_steal_count,
s_expected_await_count);
const uint status_before_cas = comp_swap_tile_status(
......@@ -58,16 +60,14 @@ bool leader_try_acquire_tile() {
// Update state variables, prepare to analyze the transition
s_expected_tile_status = status_before_cas;
const uint old_input_idx = s_input_buffer_idx;
const uint old_steal_count = s_expected_steal_count;
decode_tile_status(status_before_cas,
s_input_buffer_idx,
s_expected_steal_count,
s_expected_await_count);
// Did another work-group steal our tile?
if ((s_input_buffer_idx != old_input_idx)
|| (s_expected_steal_count != old_steal_count))
if ((s_input_buffer_idx != expected_input_idx)
|| (s_expected_steal_count != expected_steal_count))
{
#if PROFILE
s_num_stolen_early += 1;
......@@ -112,7 +112,9 @@ bool leader_try_finish_step() {
if (status_before_cas == s_expected_tile_status) {
s_expected_tile_status = desired_tile_status;
s_input_buffer_idx = s_output_buffer_idx;
s_output_buffer_idx = output_buffer_idx(prev_input_idx);
if (s_input_buffer_idx < LAST_BUFFER_IDX) {
s_output_buffer_idx = output_buffer_idx(prev_input_idx);
}
return true;
}
......@@ -129,7 +131,7 @@ bool leader_try_finish_step() {
}
#endif
// Update state variables, prepare to analyze the transition
// Update state variables
s_expected_tile_status = status_before_cas;
decode_tile_status(status_before_cas,
s_input_buffer_idx,
......
......@@ -401,12 +401,6 @@ void switch_tile() {
}
#endif
// Release ownership of the current tile
if (s_acquired_tile) {
if (is_leader()) leader_release_tile();
barrier();
}
// Start with a tile block surrounding our current tile
//
// Center it as much as possible to maximize the odds of finding a close
......@@ -423,6 +417,10 @@ void switch_tile() {
);
}
// Release ownership of the current tile
if (is_leader() && s_acquired_tile) leader_release_tile();
barrier();
// Repeatedly attempt to find a better tile
uint attempts;
for (attempts = 0; attempts < MAX_SWITCH_ATTEMPTS; ++attempts) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment