[v3] benchmarks/gem_wsim: Perturb static_vcs selection across clients

Submitted by Chris Wilson on May 14, 2019, 11:04 a.m.

Details

Message ID 20190514110450.8449-1-chris@chris-wilson.co.uk
State Accepted
Commit 13632f2414fc911a0e983bb5d5eb644a7c11a1fe
Headers show

Not browsing as part of any series.

Commit Message

Chris Wilson May 14, 2019, 11:04 a.m.
Use the client id to alternate the static_vcs balancer (-b context)
across clients with the round robin flag (-R) - otherwise all clients
end up on vcs0 and do not match the context balancing employed by
media-driver.

v2: Put it behind the -R flag.
v3: Don't skip -R flag for -b context in scripts/media-bench.pl

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 benchmarks/gem_wsim.c  | 6 ++++--
 scripts/media-bench.pl | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index afb9644dd..48568ce40 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -939,7 +939,7 @@  alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags)
 static void
 prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
 {
-	unsigned int ctx_vcs = 0;
+	unsigned int ctx_vcs;
 	int max_ctx = -1;
 	struct w_step *w;
 	int i;
@@ -948,8 +948,10 @@  prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
 	wrk->prng = rand();
 	wrk->run = true;
 
+	ctx_vcs =  0;
 	if (flags & INITVCSRR)
-		wrk->vcs_rr = id & 1;
+		ctx_vcs = id & 1;
+	wrk->vcs_rr = ctx_vcs;
 
 	if (flags & GLOBAL_BALANCE) {
 		int ret = pthread_mutex_init(&wrk->mutex, NULL);
diff --git a/scripts/media-bench.pl b/scripts/media-bench.pl
index 066b542f9..f1cd59a25 100755
--- a/scripts/media-bench.pl
+++ b/scripts/media-bench.pl
@@ -52,7 +52,7 @@  my @balancers = ( 'rr', 'rand', 'qd', 'qdr', 'qdavg', 'rt', 'rtr', 'rtavg',
 		  'context', 'busy', 'busy-avg' );
 my %bal_skip_H = ( 'rr' => 1, 'rand' => 1, 'context' => 1, , 'busy' => 1,
 		   'busy-avg' => 1 );
-my %bal_skip_R = ( 'context' => 1 );
+my %bal_skip_R = ();
 
 my @workloads = (
 	'media_load_balance_17i7.wsim',

Comments

On 14/05/2019 12:04, Chris Wilson wrote:
> Use the client id to alternate the static_vcs balancer (-b context)
> across clients with the round robin flag (-R) - otherwise all clients
> end up on vcs0 and do not match the context balancing employed by
> media-driver.
> 
> v2: Put it behind the -R flag.
> v3: Don't skip -R flag for -b context in scripts/media-bench.pl
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   benchmarks/gem_wsim.c  | 6 ++++--
>   scripts/media-bench.pl | 2 +-
>   2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> index afb9644dd..48568ce40 100644
> --- a/benchmarks/gem_wsim.c
> +++ b/benchmarks/gem_wsim.c
> @@ -939,7 +939,7 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags)
>   static void
>   prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
>   {
> -	unsigned int ctx_vcs = 0;
> +	unsigned int ctx_vcs;
>   	int max_ctx = -1;
>   	struct w_step *w;
>   	int i;
> @@ -948,8 +948,10 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
>   	wrk->prng = rand();
>   	wrk->run = true;
>   
> +	ctx_vcs =  0;
>   	if (flags & INITVCSRR)
> -		wrk->vcs_rr = id & 1;
> +		ctx_vcs = id & 1;
> +	wrk->vcs_rr = ctx_vcs;
>   
>   	if (flags & GLOBAL_BALANCE) {
>   		int ret = pthread_mutex_init(&wrk->mutex, NULL);
> diff --git a/scripts/media-bench.pl b/scripts/media-bench.pl
> index 066b542f9..f1cd59a25 100755
> --- a/scripts/media-bench.pl
> +++ b/scripts/media-bench.pl
> @@ -52,7 +52,7 @@ my @balancers = ( 'rr', 'rand', 'qd', 'qdr', 'qdavg', 'rt', 'rtr', 'rtavg',
>   		  'context', 'busy', 'busy-avg' );
>   my %bal_skip_H = ( 'rr' => 1, 'rand' => 1, 'context' => 1, , 'busy' => 1,
>   		   'busy-avg' => 1 );
> -my %bal_skip_R = ( 'context' => 1 );
> +my %bal_skip_R = ();
>   
>   my @workloads = (
>   	'media_load_balance_17i7.wsim',
> 

This probably means I was thinking -G covers this for -b context, which 
it does. Difference between -R and -G there seems purely in wording 
since clients are initialized sequentially and in deterministic order. 
Hm I guess for heterogeneous clients they would be different. Okay, 
makes sense then.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
Quoting Tvrtko Ursulin (2019-05-14 12:30:10)
> 
> On 14/05/2019 12:04, Chris Wilson wrote:
> > Use the client id to alternate the static_vcs balancer (-b context)
> > across clients with the round robin flag (-R) - otherwise all clients
> > end up on vcs0 and do not match the context balancing employed by
> > media-driver.
> > 
> > v2: Put it behind the -R flag.
> > v3: Don't skip -R flag for -b context in scripts/media-bench.pl
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > ---
> >   benchmarks/gem_wsim.c  | 6 ++++--
> >   scripts/media-bench.pl | 2 +-
> >   2 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> > index afb9644dd..48568ce40 100644
> > --- a/benchmarks/gem_wsim.c
> > +++ b/benchmarks/gem_wsim.c
> > @@ -939,7 +939,7 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags)
> >   static void
> >   prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
> >   {
> > -     unsigned int ctx_vcs = 0;
> > +     unsigned int ctx_vcs;
> >       int max_ctx = -1;
> >       struct w_step *w;
> >       int i;
> > @@ -948,8 +948,10 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)
> >       wrk->prng = rand();
> >       wrk->run = true;
> >   
> > +     ctx_vcs =  0;
> >       if (flags & INITVCSRR)
> > -             wrk->vcs_rr = id & 1;
> > +             ctx_vcs = id & 1;
> > +     wrk->vcs_rr = ctx_vcs;
> >   
> >       if (flags & GLOBAL_BALANCE) {
> >               int ret = pthread_mutex_init(&wrk->mutex, NULL);
> > diff --git a/scripts/media-bench.pl b/scripts/media-bench.pl
> > index 066b542f9..f1cd59a25 100755
> > --- a/scripts/media-bench.pl
> > +++ b/scripts/media-bench.pl
> > @@ -52,7 +52,7 @@ my @balancers = ( 'rr', 'rand', 'qd', 'qdr', 'qdavg', 'rt', 'rtr', 'rtavg',
> >                 'context', 'busy', 'busy-avg' );
> >   my %bal_skip_H = ( 'rr' => 1, 'rand' => 1, 'context' => 1, , 'busy' => 1,
> >                  'busy-avg' => 1 );
> > -my %bal_skip_R = ( 'context' => 1 );
> > +my %bal_skip_R = ();
> >   
> >   my @workloads = (
> >       'media_load_balance_17i7.wsim',
> > 
> 
> This probably means I was thinking -G covers this for -b context, which 
> it does. Difference between -R and -G there seems purely in wording 
> since clients are initialized sequentially and in deterministic order. 
> Hm I guess for heterogeneous clients they would be different. Okay, 
> makes sense then.

Hmm, right there is a subtle difference between context_vcs_rr and
ctx_vcs here. If a client creates an odd number of contexts, but doesn't
use all the VCS engines, it is still possible for -G to end up with all
active workloads on VCS0 and -R avoids that.
-Chris