[parsec-users] load imbalance patch for swaptions

kishore kumar kishoreguptaos at gmail.com
Tue Jan 24 22:50:30 EST 2012


Yep.. you are right..

We also found this issue and used a similar code in the following paper:

K. K. Pusukuri, R. Gupta, L. N. Bhuyan. "Thread Reinforcer: Dynamically
Determining Number of Threads via OS Level Monitoring". In Proceedings of
the 2011 International Symposium on Workload Characterization, October 2011.

Best,
Kishore Kumar Pusukuri
http://www.cs.ucr.edu/~kishore



On Tue, Jan 24, 2012 at 7:37 PM, Mark Roth <mroth at sfu.ca> wrote:

> Hi there, I found a load balance issue with the pthread version of
> swaptions.
>
> This imbalance occurs as the same chunk size is applied for the first
> N-1 thread, and the very last thread picks up all the remaining work.
> For example take the simlarge input with 64 swaptions running on 33
> threads.  The first 32 threads will process 1 swaption each whereas
> the 33rd thread will process 32 swaptions.
>
> - Mark
>
> <<<<<< Begin Patch >>>>>>>>>>>>>>>
>
> From ad398a80714fab491e80e61368ec7fec4c8af0aa Mon Sep 17 00:00:00 2001
> From: Mark Roth <mr.mark.roth at gmail.com>
> Date: Tue, 24 Jan 2012 19:20:00 -0800
> Subject: [PATCH] fixed load balance in pthreads version
>
> ---
>  HJM_Securities.cpp |   16 +++++++++++++---
>  1 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/HJM_Securities.cpp b/HJM_Securities.cpp
> index 1a99735..f5f7632 100644
> --- a/HJM_Securities.cpp
> +++ b/HJM_Securities.cpp
> @@ -80,9 +80,19 @@ void * worker(void *arg){
>   int tid = *((int *)arg);
>   FTYPE pdSwaptionPrice[2];
>
> -  int chunksize = nSwaptions/nThreads;
> -  int beg = tid*chunksize;
> -  int end = (tid+1)*chunksize;
> +  int beg, end, chunksize;
> +  if (tid < (nSwaptions % nThreads)) {
> +    chunksize = nSwaptions/nThreads + 1;
> +    beg = tid * chunksize;
> +    end = (tid+1)*chunksize;
> +  } else {
> +    chunksize = nSwaptions/nThreads;
> +    int offsetThread = nSwaptions % nThreads;
> +    int offset = offsetThread * (chunksize + 1);
> +    beg = offset + (tid - offsetThread) * chunksize;
> +    end = offset + (tid - offsetThread + 1) * chunksize;
> +  }
> +
>   if(tid == nThreads -1 )
>     end = nSwaptions;
>
> --
> 1.7.5.4
> _______________________________________________
> parsec-users mailing list
> parsec-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/parsec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/parsec-users/attachments/20120124/ffb48e77/attachment.htm>


More information about the parsec-users mailing list