From 823300a36385c7d0b594e74c838e30bbbd31e430 Mon Sep 17 00:00:00 2001 From: Alexander Heinecke Date: Thu, 19 Aug 2021 15:28:30 -0700 Subject: [PATCH] added round-robin scheduling of reading slices in case of sharing --- level0/readbw_multilevel/readbw_multilevel.c | 34 +++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/level0/readbw_multilevel/readbw_multilevel.c b/level0/readbw_multilevel/readbw_multilevel.c index 5740046..5d4ab6e 100644 --- a/level0/readbw_multilevel/readbw_multilevel.c +++ b/level0/readbw_multilevel/readbw_multilevel.c @@ -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 } } } @@ -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 } } }