Skip to content

Commit

Permalink
added round-robin scheduling of reading slices in case of sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
alheinecke committed Aug 19, 2021
1 parent 697305e commit 823300a
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions level0/readbw_multilevel/readbw_multilevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,21 @@ int main(int argc, char* argv[]) {
char* my_buffer = l_n_buffers[j];
size_t my_size = l_n_bytes / l_n_parts;
size_t my_offset = (size_t)tid / ( l_n_workers / l_n_parts );

read_buffer( my_buffer + (my_offset * my_size), my_size );
size_t my_start = my_offset * my_size;
#if 1
size_t my_shr_deg = l_n_workers / l_n_parts;
size_t my_kern_size = my_size / my_shr_deg;
size_t my_tid = tid % my_shr_deg;
size_t l;
for ( l = 0; l < my_shr_deg; ++l ) {
#if 0
if (tid == 6) printf("tid: %lld, my_tid: %lld, my_shr_deg: %lld, my_size %lld, my_kern_size: %lld, my_start: %lld, inner_offset: %lld\n", tid, my_tid, my_shr_deg, my_size, my_kern_size, my_start, ( ( (l+my_tid) % my_shr_deg ) * my_kern_size) );
#endif
read_buffer( my_buffer + my_start + ( ( (l+my_tid) % my_shr_deg ) * my_kern_size), my_kern_size );
}
#else
read_buffer( my_buffer + my_start, my_size );
#endif
}
}
}
Expand Down Expand Up @@ -326,8 +339,21 @@ int main(int argc, char* argv[]) {
char* my_buffer = l_n_buffers[j];
size_t my_size = l_n_bytes / l_n_parts;
size_t my_offset = (size_t)tid / ( l_n_workers / l_n_parts );

read_buffer( my_buffer + (my_offset * my_size), my_size );
size_t my_start = my_offset * my_size;
#if 1
size_t my_shr_deg = l_n_workers / l_n_parts;
size_t my_kern_size = my_size / my_shr_deg;
size_t my_tid = tid % my_shr_deg;
size_t l;
for ( l = 0; l < my_shr_deg; ++l ) {
#if 0
if (tid == 6) printf("tid: %lld, my_tid: %lld, my_shr_deg: %lld, my_size %lld, my_kern_size: %lld, my_start: %lld, inner_offset: %lld\n", tid, my_tid, my_shr_deg, my_size, my_kern_size, my_start, ( ( (l+my_tid) % my_shr_deg ) * my_kern_size) );
#endif
read_buffer( my_buffer + my_start + ( ( (l+my_tid) % my_shr_deg ) * my_kern_size), my_kern_size );
}
#else
read_buffer( my_buffer + my_start, my_size );
#endif
}
}
}
Expand Down

0 comments on commit 823300a

Please sign in to comment.